Re: can anyone see the error in this script please I am BASHing my head LOL



On 2006-03-11, Mike wrote:
can anyone see the error in this script please I am BASHing my head LOL


while read line
do # For as many lines as the input file has...
$tmp=${line:0:1}

Do not precede a variable with '$' on the left-hand side of an assignment.

if [$tmp -ne $comma]; # if tmp is not a , then

You need spaces around '[' and ']'

then
$getdate=${line:0:9}
$theday=`date +%A -d $getdate`

See above.

$theLine=$theday "-" $thecount "," ${line:10:20}

See above, and you need to quote the entire assignment if it
contains spaces, not the individual elements.

else
$theLine=$line

See above.

fi
echo $theLine >> testoutput.txt
done < testtides.csv
exit


while read line
do # For as many lines as the input file has...
tmp=${line:0:1}
if [ "$tmp" -ne "$comma" ]; # if tmp is not a , then
then
getdate=${line:0:9}
theday=`date +%A -d $getdate`
theLine="$theday - $thecount , ${line:10:20}"
else
theLine=$line
fi
echo theLine >> testoutput.txt
done < testtides.csv
exit


--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.



Relevant Pages

  • Re: HELP!!!
    ... & sort the input file into 3 output files by ... Code the problem in Java using 1 file input stream and 3 file output ... Submit your 3 output files. ... Turn in your assignment by the end of class tonight for full credit. ...
    (comp.lang.java.help)
  • Re: Howto construct a message for a simple WebService call?
    ... A very good answer, but still, I would like to see sample code to that ... >> to use the construct message shape to transform the input FILE to a web ... > When BizTalk imports a WSDL, it will create Multi-part message types for the ... > Assignment shape. ...
    (microsoft.public.biztalk.general)
  • Re: HELP!!!
    ... (note file path when copying file from web to your usb) ... & sort the input file into 3 output files by ... Submit your 3 output files. ... Turn in your assignment by the end of class tonight for full credit. ...
    (comp.lang.java.help)
  • Re: HELP!!!
    ... (note file path when copying file from web to your usb) ... & sort the input file into 3 output files by ... Submit your 3 output files. ... Turn in your assignment by the end of class tonight for full credit. ...
    (comp.lang.java.help)
  • Re: Change Table Structure
    ... I suggest you just parse the input file (I assume it's some kind of text ... a$ = GetOneLine ... if len=0 then exit do ... ' prepare the command; ...
    (microsoft.public.access.modulesdaovba)