[gradsusr] passing whitespace from bash to grasds run

Huddleston, John Huddleston at cira.colostate.edu
Mon Aug 22 10:02:15 EDT 2011


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




More information about the gradsusr mailing list