LinuxQuestions.org
Help answer threads with 0 replies.
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 05-07-2012, 07:54 PM   #1
romeo0307
LQ Newbie
 
Registered: Apr 2012
Posts: 16

Rep: Reputation: Disabled
Adding output of one command to the bottom of another file?


Hi guys. It's me again

Here is what I have this time:

paste -d: file1 file 2

This needs to be combined with another command to make it 1 command using either | or > or something like that.

And it needs to go to the bottom of file3

Please help!
 
Old 05-07-2012, 07:56 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143
You need to be more specific. What is the other command? What are you trying to put into file3? The more specific you are, the faster and more accurate the advice will be.

In general, ">>" will append the output of a command to the end of a file, IE: "ls >> outfile"

Last edited by suicidaleggroll; 05-07-2012 at 07:57 PM.
 
Old 05-07-2012, 07:59 PM   #3
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Yes, you are on the right track. Apart from the piper character '|', make sure you know the difference between > and >>
 
Old 05-07-2012, 08:00 PM   #4
romeo0307
LQ Newbie
 
Registered: Apr 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
You need to be more specific. What is the other command? What are you trying to put into file3? The more specific you are, the faster and more accurate the advice will be.

In general, ">>" will append the output of a command to the end of a file, IE: "ls >> outfile"
Duh! Thanks, that was so simple.
 
Old 05-08-2012, 02:09 PM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Yes, the usual, recommended way is just to do something like this:

Code:
command1 > file
command2 >> file
It's also possible to use command grouping or subshells to direct the output of multiple commands at once.

Code:
{ command1 ; command2 ; } > outfile

( command1 ; command2 ) > outfile
Finally, you can use cat and process substitution to combine multiple inputs together. This works well when you want to combine output form both files and commands.

Code:
cat infile1 <(command1) infile2 <(command2) >outfile
 
  


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
DD command output to file jonny1517 Linux - Newbie 6 11-21-2009 10:10 AM
[SOLVED] append command output to file by giving command in terminal sumeet inani Linux - Newbie 4 07-03-2009 10:36 AM
grep command from bottom to top of a file. b3nder Linux - Newbie 3 06-30-2008 08:08 AM
command output to text file? meniscus Linux - Newbie 4 10-05-2006 05:29 AM
Help: Command Output to File. rvijay Linux - Newbie 3 09-30-2003 09:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:03 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration