Skip to main content

All Questions

0 votes
1 answer
57 views

value of $VAR already contains backtick and/or single quote inside. How to handle it? How to properly pass $VAR to program? [duplicate]

$ bash --version GNU bash, versione 5.2.26(1)-release (x86_64-pc-linux-gnu) I don't know how to deal with $VAR when its value inside contains single quote (') and/or backtick (`). I'm in the need of ...
1 vote
1 answer
202 views

Tab character in exiftool

I need to insert tab character on place of _ between day and hour. exiftool -T -r -filename -CreateDate -d "%Y%"."%m%"."%d_%H%"."%M%"."%S" /Users/***/***/testmapa/mapa2/ > /Users/***/***/testmapa/...
18 votes
2 answers
106k views

How to use a special character as a normal one in Unix shells?

Many questions like 'How to type the double-quote char (")?' are being asked, and we don't want to clutter our community with the same answer (Type it as \" if not enclosed in 's, " if enclosed in 's.)...
188 votes
7 answers
179k views

Can't use exclamation mark (!) in bash?

I'm trying to use the curl command to access a http url with a exclamation mark (!) in its path. e.g: curl -v "http://example.org/!287s87asdjh2/somepath/someresource" the console replies with bash: ....
8 votes
1 answer
5k views

What are curly quotes and can I use them in my code?

Somehow curly quotes got into my code and I'm getting unexpected behavior #!/bin/sh if [ foo = ‘foo’ ]; then echo yes else echo no fi I would expect this to echo yes but instead it echoes no.
7 votes
3 answers
35k views

How to add a line break inside a bash string? [duplicate]

I have the following bash string and I need to add a line break to it, before the 'Hello' string: bash -c "echo 'Hello' > /location/file" I already tried adding it with different variations of ...
0 votes
3 answers
2k views

"bash: !/bin/su": event not found" [duplicate]

I have line in script which is working, but not working from command line. echo "User ALL = NOPASSWD: ALL, !/bin/su" | sudo tee -a /etc/sudoers [user@localhost ~]$ echo "test ALL = NOPASSWD: ALL, !/...
16 votes
4 answers
39k views

How to grep for pipe |

How can I grep for line containing pipe character | or for character >: files content: |this is test where is > this is none now what I need using grep command is grep -iE "<some ...
1 vote
3 answers
205 views

how to filter inner quotes? [closed]

is it possible to filter, i.e to put ESC in front of the inner quotes with sed, awk or other *NIX tool (no perl/python)? Example (revised): $ echo label=\"123 \"456\" 789\" \"AB C\" e f gh | magic-...
7 votes
1 answer
3k views

Representing/quoting NUL on the command line

Can \0 be used on the command line? Background For testing corner cases in GNU Parallel I was curious whether all characters were correctly quoted on the command line. Most of them are: perl -e '...
10 votes
2 answers
5k views

Difference between ' and " on command line (bash)? [duplicate]

I used to use '' and "" (single and double-quotes) interchangeably on the command line, but I recently noticed that '$HOME/some/dir' is not expanded, while "$HOME/some/dir" is. I searched around a ...
2 votes
4 answers
13k views

sh and grep numbers only

I'm facing a problem and trying to find a solution that works in sh. If I could use bash this code would work: ls /a|grep ^[0-9] Unfortunately this is not the case with sh, and yes I need to use sh. ...
2 votes
2 answers
1k views

Problem with spaces when used in find command

I'm trying to place a zip file with the content of the directory in each directory that doesn't contain any subdirectory. The following command works if there's no space in dirnames and/or filenames ...
1 vote
2 answers
2k views

Shell eating `?` characters

This is such a simple question that I'm sure it's been asked somewhere, but I can't find it. My shell, which I have not intentionally set up to do so, seems to eat any words involving question marks: ...
0 votes
2 answers
3k views

Define string with the characters *, single quote and $

I create bash scripts which get sourced from another "main" script to set up variables needed by the main script. These variables need to be able to contain any character and not have them ...

15 30 50 per page