1
vote
1answer
19 views

Proper use of escape characters in desktop file

I have a command with a working .desktop Exec key as follows: Exec=env XDG_CONFIG_HOME=/home/bean/.config/gedit/ gedit %U I would like to use the $HOME variable instead and it works in the terminal ...
4
votes
5answers
213 views

How to use ' in alias?

I have one-line that I want to call using alias. while printf '%s ' "$(df -P / | awk 'NR==2 { print $(NF-1) }')"; do sleep 30; done I tried to escape ' like \' but it didn't work. What is the ...
2
votes
2answers
613 views

Calling bash from sh (dash) with commands read from args, and “Unterminated quoted string”/“unexpected EOF”

Just thought I'd document this: I'm trying something very simple - set env variable in bash, and print it out: $ bash -c "a=1; echo a$a;" a $ bash -c "a=1; echo a\$a;" a1 Now I'd want this same ...
1
vote
1answer
178 views

How to prevent double escaping?

I'm trying to put a bunch of images together into a pdf. I ran gm convert *.jpg out.pdf and it worked, but the images were not in the right order. I found that ls -v orders them correctly so then I ...
2
votes
1answer
133 views

Confused about when to escape metacharacters in pathnames

I'm pretty confused about under which circumstances do I need to escape metacharacters in pathnames. Consider the following example: I'm in the following working directory: $ echo $PWD ...
3
votes
1answer
2k views

Trouble in script with spaces in filename

I've got a script that scp's a file from remote host back to local. Sometimes the file names contain spaces. scp does not like spaces in its file names. For some reason my attempts at handling the ...
2
votes
1answer
637 views

Shell escape characters for sh -c

I need to execute a command with escaped argument(s) using sh -c. I know the string looks pretty ugly but simple ones don't cause a problem. The output of the echo when passed to sh -c is different ...
3
votes
1answer
362 views

Printing colored text using script

When I type below command in the shell I get the OUTPUT in green color. Command echo "\033[32mCONNECTING TO abpwrk\033[m"; Output(in green color) CONNECTING TO abpwrk But if I use the same ...
1
vote
1answer
75 views

Apostrophe appearing as space

I am trying to insert the following message: friend's mobile number from a file over redhat server into sql server 2005. this message is appearing in the sql server as below: friend s mobile ...
3
votes
2answers
1k views

How to escape < or > in a parameter in shell?

I'd like to use grep with a PCRE expression that contains the < character. Bash thinks I want to redirect, but I don't want to. How can I escape <?