0

I want to pass a string like "('a','a');('a','!a');('a', '!d');('b', '!e');('c','a')" from the command line. But i recieve an error: -bash: syntax error near unexpected token '(\'

Is there a way, how i can avoid this without adding terminal symbols?(maybe specifieng a flag)

Also, putting \ befor brackets didn't help - which characters should i prefix with '\' in the string with no spaces?

Ladenkov Vladislav
  • 1,247
  • 2
  • 21
  • 45
  • My questing has a very general title. That makes it easier to find it, opposite to other questions – Ladenkov Vladislav Oct 24 '17 at 19:56
  • Your problem seems to be with the exclamation point, which is used for bash history searching. The question I linked to has a title specific to that. – Barmar Oct 24 '17 at 21:24
  • @Barmar No, my problem was not with the exclamation point – Ladenkov Vladislav Oct 25 '17 at 19:50
  • What was the problem? None of the other punctuation characters you show have any special meaning inside double quotes. – Barmar Oct 25 '17 at 20:20
  • The error message you show doesn't make any sense. It has a backslash, but there's no backslash in your string. Can you edit the question and show the actual command you were trying to enter? – Barmar Oct 25 '17 at 20:22

2 Answers2

0

Bash won't interpret strings inside single quotes so if you could switch:

"('a','a');('a','!a');"

for

'("a","a");("a","!a");'

the later with double quotes inside single quotes will work and you don't have to look at nasty escapes.

River
  • 8,585
  • 14
  • 54
  • 67
Travis Walsh
  • 16
  • 1
  • 3
0

You could use ANSI-C quoting, but it looks like hell:

$ echo "('a','a');('a','!a');('a', '!d');('b', '!e');('c','a')"
bash: !a': event not found

$ echo $'(\'a\',\'a\');(\'a\',\'!a\');(\'a\', \'!d\');(\'b\', \'!e\');(\'c\',\'a\')'
('a','a');('a','!a');('a', '!d');('b', '!e');('c','a')
glenn jackman
  • 238,783
  • 38
  • 220
  • 352