How to solve ambigious redirect error?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to solve ambigious redirect error?
# 1  
Old 08-26-2014
How to solve ambigious redirect error?

hi all,
i had the below script
Code:
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
# 2  
Old 08-26-2014
There should also be a command not found error?
Try:
Code:
filename=/osa/data1/output.txt

Without spaces around =
# 3  
Old 08-26-2014
hi ,
ya i am getting the command not found error to for every line ..

like
Code:
/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..?
# 4  
Old 08-26-2014
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"
Code:
printf '%27s%53s\n' ' CURRENT DATE'   26-08-2014  >> "$filename"

then it becomes an empty string and the message would be
Code:
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..

Last edited by Scrutinizer; 08-26-2014 at 02:20 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to solve this Error. I/O Error.?

Hi Guys, I just got this error:- Your "cron" job on server2 /usr/5bin/ssh sysmgr@server1 /usr/local/bin/sudo /opt/local/pdm/bin/mount_pdmprod produced the following output: ** /dev/rdsk/c1t5006016C446023DEd0s2 ** /dev/rdsk/c1t5006016C446023DEd1s2 ** /dev/rdsk/c1t5006016C446023DEd2s2... (2 Replies)
Discussion started by: manalisharmabe
2 Replies

2. Solaris

Howto solve this disk error in Solaris in single user mode

Hi all, OS is Solaros 10 Sparc While doing Netbackup upgradation to 7.5 , the server was asked to reboot. But then it came up in single user mode, and after I typed format command it showed some disk error. bash-3.00# format Searching for disks...WARNING:... (2 Replies)
Discussion started by: manalisharmabe
2 Replies

3. Shell Programming and Scripting

How to solve awk: line 1: runaway string constant error?

Hi All ! I am just trying to print bash variable in awk statement as string here is my script n=1 for file in `ls *.tk |sort -t"-" -k2n,2`; do ak=`(awk 'FNR=='$n'{print $0}' res.dat)` awk '{print "'$ak'",$0}' OFS="\t" $file n=$((n+1)) unset ak doneI am getting following error awk:... (7 Replies)
Discussion started by: Akshay Hegde
7 Replies

4. Shell Programming and Scripting

What is this error log = hda: irq timeout: error=0x00 and how to solve?

what is this error log = hda: irq timeout: error=0x00 and how to solve? every day upon checking the logs i see this error. hda: irq timeout: error=0x00 hda: irq timeout: error=0x00 hda: irq timeout: error=0x00 hda: irq timeout: error=0x00 hw_client: segfault at 0000000000000046 rip... (3 Replies)
Discussion started by: avtalan
3 Replies

5. Linux

Ambiguous redirect error and syntax error when using on multiple files

Hi, I need help on following linux bash script. When I linux commands for loop or while loop on individual file it runs great. but now I want the script to run on N number of files so it gives me ambiguous redirect error on line 12 and syntax error on line 22 : (pls help ); #!/bin/bash #... (16 Replies)
Discussion started by: Madhusudan Das
16 Replies

6. UNIX for Dummies Questions & Answers

i dont know how to solve this error

can while do make aloop as do while in c language ? (1 Reply)
Discussion started by: teefa
1 Replies

7. Shell Programming and Scripting

ambiguous redirect error

This script has ambiguous redirect error. ... cd $HOME cd folder/work # search all subfolders in work directory find -mindepth 1 -maxdepth 1 -type d | while read directory do CUR_FOLDER="${directory#"./"}" cd $CUR_FOLDER chmod 644 * for ff in *; do if ; then ... (5 Replies)
Discussion started by: candyme
5 Replies

8. Shell Programming and Scripting

Test argument error, unable to solve

Here is an awk statement i am using to sum a series of numbers.. awk -F"," '{ for (i=1; i<=NF ; ++i) sum += $i;} # if (i > max) max=i } END { s=""; for (i=1; i<=max; ++i) { printf "%s%s", s, sum; s=","; } printf "\n" }' filename.csv It works fine for the summing part. But since my series... (19 Replies)
Discussion started by: pravsripad
19 Replies

9. Solaris

Where/What/Howto solve warning/error msg about Kernel patch level?

required Solaris 5.10 Kernel patch 137111-03 required Solaris 5.10 Fibre Channel Device Driver patch 125184-08 I want to know about the descriptions and what the patches will do. I searched www.sun.com (patches/updates) but don't see I am looking for. (1 Reply)
Discussion started by: Y4Net
1 Replies

10. Programming

how to solve error : Bind: Address Already in Use

hi i have created socket program with proper IP address and port no client side port no 1085 and 1086 gateway side port no 1086 and 1085 and port no 1087 and 1088 receiver side port no 1088 and 1087 well it works fine on client and gateway side not on receiver and gateway side... (2 Replies)
Discussion started by: bhakti
2 Replies
Login or Register to Ask a Question