Linked Questions

44
votes
1answer
3k views

What is the difference between “…”, '…', $'…', and $“…” quotes?

Sometimes I see scripts use all of these different ways of quoting some text: "...", '...', $'...', and $"...". Why are there so many different kinds of quote being used? Do they behave differently ...
9
votes
3answers
1k views

What's the difference betwen " and ' - and when to use it? [duplicate]

I'm used to type strings with quotation marks, but from now and then when I surf through config files and recommendations, I see apostrophes being used. I often copy apostrophe things into my config ...
4
votes
2answers
7k views

Bash : date -d throws “invalid date” when date is parameterized [duplicate]

When I parameterize the date in the code as : str_last_log_date="2017-07-24" last_log_date=$(date -d '${str_last_log_date}' +%s) threshold_days_ago=$(date -d 'now - 2 days' +%s) echo "last_log_date ${...
1
vote
2answers
5k views

Why does a sed command work interactively but not in my script? [duplicate]

SED command not replacing in bash under Debian, but works in command line. Works in command line: sed -i 's|/dev/disk/by-label/SR6D4|/dev/disk/by-label/SR4D4|g' /etc/my/config.xml Not working in ...
1
vote
2answers
1k views

bash - Why does type -a execute “$(printf 'a')” and is it possible to get back the original alias? [duplicate]

After i ask this question 2 days ago, i decided to make this alias in my ~/.bashrc: alias catvu="LC_ALL=C sed \"$(printf 's/[^\t -\176\200-\377]/^&/g')\"|LC_ALL=C tr '\0-\10\13-\37\177' '@-HK-...
1
vote
1answer
209 views

What is the difference between ' and "? [duplicate]

I tried to create a text file in a bash script. The echo command spans multiple lines and has some double quotes "". #!/bin/bash echo "blabla bla bla bla "blabla" bla bla " bla bla bla" and so on ...
2
votes
2answers
142 views

Can someone explain exactly what is happening with single quotes and double quotes with process IDs in the below example? [duplicate]

[root@localhost ~]# echo $$ 16991 [root@localhost ~]# bash -c "echo $$" 16991 [root@localhost ~]# bash -c "echo $$" 16991 [root@localhost ~]# bash -c 'echo $$' 21062 [root@localhost ~]# bash -c 'echo $...
0
votes
2answers
94 views

Bash script doesn't convert variables [duplicate]

I was attempting to create a bash script to run a backup of my Raspberry Pi to my Box account via FTP. Most of it works, but for some reason it won't convert variables to the text they stand for. When ...
1
vote
1answer
56 views

Why does echoing $? vary differently when running in this script? [duplicate]

I have the following in my script: connectionTest=$(sshpass -p "${pass}" ssh -q -o ConnectTimeout=5 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${remoteUser}"@"${IP}" "echo quit | ...
0
votes
0answers
13 views

Interaction of sed and for loop [duplicate]

for i in {1..25}; do cat file$((i)) | sed 's/.*/$((i))/'; done doesn't print the current value of i but just $((i)). How can I make it print the value of i instead?
3
votes
1answer
2k views

How to use a value returned by a script in grep filter?

I'm on FreeBSD's csh. I want to form a row with domains of one user and then use this row to filter exim maillog to get only mail from/to this user's domains. I wrote a script to form a row from a ...
0
votes
1answer
90 views

Replace a number with sed/awk [closed]

I need to replace a number using a script, I am using the following command for ((i=1; i=<10, i=i+1)) sed '244s/0.8/(0.$i)/' analyze3big.f >> $i.f But for some reason it does not work.