hi all,
i had the below script
filename = /osa/data1/output.txt
printf '%27s%53s\n' ' CURRENT DATE' 26-08-2014 >> $filename
iam getting the ambigiuos redirect error in the 2nd line of the code...please guide me
regards,
vasa saikumar
hi all,
i had the below script
filename = /osa/data1/output.txt
printf '%27s%53s\n' ' CURRENT DATE' 26-08-2014 >> $filename
iam getting the ambigiuos redirect error in the 2nd line of the code...please guide me
regards,
vasa saikumar
There should also be a command not found error?
Try:
filename=/osa/data1/output.txt
Without spaces around =
hi ,
ya i am getting the command not found error to for every line ..
like
/osa/data1/output.txt : line1: command not found
---------- Post updated at 12:05 AM ---------- Previous update was at 12:03 AM ----------
will it remove the ambigious error..?
Yes sure, because of the first statement $filename
becomes empty therefore the redirect is appending to nothing and becomes ambiguous.
If you use double quotes around "$filename"
printf '%27s%53s\n' ' CURRENT DATE' 26-08-2014 >> "$filename"
then it becomes an empty string and the message would be
No such file or directory
(at least in bash) which is a whole lot more understandable...
---
The necessity of double quotes around the file names are a bash quirk, in other Bourne shell derivatives / POSIX shells this is not necessary..