10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
(This is Don's domain.)
I have come across an anomaly in sh and dash compared to bash.
It involves echoing a character set to a file in sh and dash compared to bash.
It is probably easier to show the code and results first.
echo... (4 Replies)
Discussion started by: wisecracker
2. Shell Programming and Scripting
I'd like to print line if column 5th doesn't match with exm. But to reach there I have to make sure I match single quote.
I'm struggling to match that.
I've input file like:
Warning: Variants 'exm480340' and '5:137534453:G:C' have the same position.
Warning: Variants 'exm480345'... (9 Replies)
Discussion started by: genome
3. Shell Programming and Scripting
1,2,3,4,5,This is a test
6,7,8,9,0,"This, is a test"
1,9,2,8,3,"This is a ""test"""
1,2,3,4,5,This is a test
6,7,8,9,0,"This; is a test"
1,9,2,8,3,"This is a ''test''"
4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
4. Shell Programming and Scripting
I have a file as:
I need o/p as:
'New' (12 Replies)
Discussion started by: karumudi7
5. Shell Programming and Scripting
i have a data in the file which of the formate :
and the required formate is
Idealy we need to replace , with \',\'
arkesh (2 Replies)
Discussion started by: arkeshtk
6. Shell Programming and Scripting
Hi I want to replace single quote with two single quotes in a perl string.
If the string is <It's Simpson's book> It should become <It''s Simpson''s book> (3 Replies)
Discussion started by: DushyantG
7. Shell Programming and Scripting
I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file:
Name = "abc"
The regex I'm using to match the same is:
egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
8. Shell Programming and Scripting
echo 'abc' will give output abc
how can i get output as 'abc'
plz help. thanks in advance (3 Replies)
Discussion started by: javeed7
9. Shell Programming and Scripting
I have a shell script with many lines as below:
comment on column dcases.proj_seq_num is dcases_1sq;
I want the above script to be as below:
comment on column dcases.proj_seq_num is 'dcases_1sq';
I want to have single quotes like that as above for the entire shell... (2 Replies)
Discussion started by: dreams5617
10. Shell Programming and Scripting
I have a data file like so below
'A/1';'T100002';'T100002';'';'01/05/2004';'31/05/2004';'01/06/2004';'08/06/2004';'1.36';'16';'0.22';'0';'0';'1.58';'0';'0';'0';'0';'0';'0';'clientes\resumen\200405\resumen_T100002_T100002_1.pdf';'';'0001';'S';'20040501';'';'02';'0';'S';'N'... (3 Replies)
Discussion started by: rjsha1
SHELL-QUOTE(1) User Contributed Perl Documentation SHELL-QUOTE(1)
shell-quote - quote arguments for safe use, unmodified in a shell command
shell-quote [switch]... arg...
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
[ -z "$debug" ] || shell-quote "debug:" "$@"
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
while [ $# != 0 ]
case x$1 in
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
# process other switches
eval "shell-quote some-command $user_switches my args"
Turn debugging on.
Show the usage message and die.
Show the version number and exit.
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
Roderick Schertler <firstname.lastname@example.org>
perl v5.16.3 2010-06-11 SHELL-QUOTE(1)