Quoting and escaping is really an important way to influence the way, Bash treats your input. There are three recognized types:
* per-character escaping using a backslash: \$stuff
* weak quoting with double-quotes: "stuff"
* strong quoting with single-quotes: 'stuff'
I recently had trouble with some regex on the command-line, and
found that for matching a backslash, different numbers of
characters can be used. This number depends on the quoting used for
the regex (none, single quotes, double quotes).
I needed to write a that behaves correctly with nasty (spaces, braces, etc..)
filenames.
scp -rv "$1" shiny:/Volumes/Seagate3To/\"$1\"
This function works, but I don't understand why the quotes need escaping in the second argument of scp.
What is the deal with explanation point in bash? I thought only dollar sign ($), the back-tick (`) and the backslash (\) were special in double quotes. Can someone please explain what is going on here? Why do I have to use single quotes or backslash the "!"?
Code:
$ vlc "/media/Part 1/stuff/bucks!395201.flv"
bash: !395201: event not found
If you’ve come to the sad realization that your quotes and proposal do in fact suck, that’s okay. You’re not alone. We talk to thousands of technology business, and lots of people struggle with this. The good news is, now that you know you quotes suck, you can start to fix them!
It takes focus to really get the sales and quoting process right.
"effective awk programming" book has an example on Field-Splitting. here is the example:
If you want fields to be separated by a literal period
followed by any single character, use ‘FS = "\\.."’.
Why it is double backslash? shouldn’t it be \..?
If I do:
ssh-keygen -N password123\$ -f bobskeys
Is \ escaping the $ character or becoming part of the password?
Or rather, will bash be doing any escaping before ssh-keygen gets the password value?
Do I need to escape the $ character?
I'm running Centos 5.5 x64 and bash 3.2.25
At this moment I have:
#!/bin/bash
screen -p 'ScreenName' -x eval 'stuff '"'"$@"'"'\015'
echo eval 'stuff '"'"$@"'"'\015'
But when I call my script as:
# script.sh asd "asd" 'asd'
my arguments passed as: asd asd asd
and I get output:
eval stuff 'asd asd asd'\015
I except a: asd "asd" 'asd'
How I can change my script to pass whole arguments line with all quotes?
I have a input file delimited with comma (,). There are some fields enclosed in double quotes that are having a comma in them. Here is the sample row
123,"ABC, DEV 23",345,534.202,NAME
I need to remove all the comma's occuring within inside the double quotes and the double quotes as well.