if its bash, its suggested to use $() rather than ``.
So it'll be:
One can simplify to:
$LIST can be expanded to anything that be output'ed from within a $() or ``, just as you do.
Depending on the content of imagined $LIST, you would need to put quotes around: "$( code )".
Saying: Quoteing is just around the $LIST, not around the for.
As it is: yes. You have been given ample help already on how to construct the for-loop syntactically correct. IMHO this is one side of the story. My advice is to avoid for-loops for things like yours altogether and use while-loops instead:
instead of
do
There are two reasons for this:
first, "for" parses words, not lines. If one of the list of items the command produces contains a whitespace it will break. The "while read ..." will parse on lines and as long as on each line is only one value you are fine even if the values themselves contain whitespace.
second, there is a maximum line length and a maximum number of arguments a command can take in place. These values have been increased with the advent of 64-bit OSes but they are still there and whatever you feed into "for" is an argument to it. For instance:
gives 5 arguments, "1", "2", etc., to "for". Because your process substitution ("$(...)" or backticks) can produce any number of arguments without you having control over the process. It may never really hit you but why the take the risk? The while-loop will have no restriction in the number of elements it can process because it handles one item at a time.
Hi Everyone,
my script was running Ok, but suddenly it started giving this error.
./update_env_bi.sh: line 54: syntax error near unexpected token `)'
./update_env_bi.sh: line 54: `sed -i "s/PORT=*1/PORT=$2/" repository.xml'
The line 54 has this code.
sed -i "s/PORT=*1/PORT=$2/"... (2 Replies)
I have written this in my script but while running i am getting syntax error `(' unexpected.
unload to "$BACKUP_DIR/n_fac_fid-$clliname" select * from n_fac_fid where fac_accesskey in (select fac_accesskey From n_fac_ap_fid where ap_clli="$clliname");
Any help appreciated. (3 Replies)
unzip file.zip
if ] ; then
echo "Success"
else
echo "Some failure."
fi ;
I tried many time to detect the unzip error, but it keep show the syntax error wherever how I change the syntac. Hope someone can help me fix the issue, thanks.
Please use code tags next time for your code and... (5 Replies)
Hello,
I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time.
My script:
returned=`tail -50 SapLogs.log | grep -i "Error"`
echo $returned
if ; then
echo "There is no errors in the logs"
fi
And after... (10 Replies)
Hi All,
I am writing one script to automate one of the process and for that I am using below command at one line :
uncompress `cat tmp`
content in tmp file are :
/home/vas/aqbatch/newbatch/archive/output/RIM_GUIDEPRICE_AQ_02108.DAT.Z... (5 Replies)
When I typed
#svcs -x sma
I received this following error,
svcs: svcs.c:335: Unexpected libscf error: invalid argument. Exiting.
I have googled around but could not find a solution.
IS this a bug?
I am using
Solaris 5.10 Generic_137137-09 sun4v sparc... (2 Replies)
My script is throwing the error 'Syntax error: redirection unexpected'
My line of code..
cat nsstatustest.html | sed s/<tr><td align="left">/<tr><td align="left" bgcolor="#000000"><font color="white">/ > ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3
HTML tags are getting in the way but they're needed to... (3 Replies)
./sample.5: syntax error: `(' unexpected
I get this error and Im trying to solve it but the line that it refering to is a notation so I don't understand why it is affecting the program. (2 Replies)
hi there
i write one awk script file in shell programing
the code is related to dd/mm/yy to month, day year format
but i get an error
please can anybody help me out in this problem ??????
i give my code here including error
awk `
# date-month -- convert mm/dd/yy to month day,... (2 Replies)
I am trying to run the script bellow but its given me "syntax error at line 20 :'done' unexpected." error message"
can someone check to see if the script is ok? and correct me pls.
Today is my first day with scripting.
Gurus should pls help out
#!/bin/ksh
# Purpose: Check to see if file... (3 Replies)