[gradsusr] passing whitespace from bash to grasds run
Simon Kiertscher
simon.kiertscher at gmx.de
Wed Aug 24 06:14:34 EDT 2011
Hi John,
thx for your idea with the IFS. But i think this does not because i pass
the arguments to a GrADS Skript and i think GrADS will separate the
arguments, thus i had to manipulat the IFS of GrADS or not?
However, export IFS=$'\n' before my grads call does not work.
I also tried already escaping ticks like \"$two_arguments\" or
\'$two_arguments\'.
If i do it like that, i get (if two_arguments=foo bar) "foo as the
first argument and bar" as the second one.
Any other idea what i could do?
Thx again and Best Regards,
Simon
> Simon
>
> Bash scripts treat any white space as delimiters so set the following to limit it to linefeeds:
> export IFS=$'\n'
>
> Next, put your two word arguments in single quotes:
> 'foo bar'
>
> John Huddleston
>
> Here is a test script testIFS.sh, run it by typing ./testIFS.sh one 'foo bar'
>
> #!/bin/bash
> if [ $# -lt 2 ];then
> echo "pass at least two arguments"
> exit
> fi
> export IFS=$'\n'
> icnt=0
> for i in $*
> do
> icnt=`expr $icnt + 1`
> echo "$icnt: $i"
> done
>
>
> -----Original Message-----
> From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Simon Kiertscher
> Sent: Monday, August 22, 2011 2:54 AM
> To: gradsusr at gradsusr.org
> Subject: [gradsusr] passing whitespace from bash to grasds run
>
> Hi all,
>
> is it possible to pass arguments with a whitespace from a bashscript to a grads script?
> I want to do something like this:
> grads -lbxc "run $var_1 $var_2 ... $var_n" but some of the var_x variables looks like "foo bar"
>
> Any ideas?
>
> Best Regards,
> Simon
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
More information about the gradsusr
mailing list