LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-13-2011, 05:04 AM   #1
daredevil_1981
LQ Newbie
 
Registered: Oct 2011
Posts: 6

Rep: Reputation: Disabled
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
 
Old 10-13-2011, 05:53 AM   #2
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
I'm really confused, what are you trying to achieve with that command???
why all those redirections???
 
Old 10-13-2011, 06:04 AM   #3
daredevil_1981
LQ Newbie
 
Registered: Oct 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.
 
Old 10-13-2011, 06:14 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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

Last edited by colucix; 10-13-2011 at 06:17 AM.
 
Old 10-14-2011, 12:56 PM   #5
daredevil_1981
LQ Newbie
 
Registered: Oct 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thumbs up Thanks

Hi colucix,

its working fine thank you very much.

Regards,
MSK
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash concatenating string to variable abercrombieande Programming 4 01-19-2011 07:04 AM
[SOLVED] Concatenating an integer to a string mohabic Programming 5 10-19-2010 01:34 AM
possible with grep? find string and then output that and the rest of the file captain_cthulhu Linux - Newbie 4 05-18-2009 12:09 PM
Problem concatenating a string in perl Singist Programming 4 03-22-2006 06:15 PM
Using echo to output a string to a file with forward slashs chrisk5527 Linux - General 15 06-21-2003 02:04 PM


All times are GMT -5. The time now is 12:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration