LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Issue String concatenating in output file (https://www.linuxquestions.org/questions/linux-newbie-8/issue-string-concatenating-in-output-file-907919/)

daredevil_1981 10-13-2011 05:04 AM

Issue String concatenating in output file
 
Hi friends,

i am having issue in the below statement in Linux

mv a.txt /home/app 1>> `echo "file moved.." >> b.out` 2>> b.out

when i execute the above statement the below error appears

`echo "file moved.." >> b.out`: ambiguous redirect


Kindly provide your comments.

Thanks in advance
MSK

16pide 10-13-2011 05:53 AM

I'm really confused, what are you trying to achieve with that command???
why all those redirections???

daredevil_1981 10-13-2011 06:04 AM

hi,

i have to move a.txt file to the specified location on successful movement,am writing a message in the output file b.out .
if there is any system errors i am writing into the same file using 2>> b.out

In general normal redirect is 1>>
and for system errors 2>>

Please correct me if i am wrong.

colucix 10-13-2011 06:14 AM

Code:

if mv a.txt /home/app 2>> b.out
then
  echo "file moved.." >> b.out
fi

or
Code:

mv a.txt /home/app 2>> b.out && echo "file moved..." >> b.out

daredevil_1981 10-14-2011 12:56 PM

Thanks
 
Hi colucix,

its working fine thank you very much.

Regards,
MSK


All times are GMT -5. The time now is 09:22 PM.