LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 04-24-2016, 03:30 PM   #1
PleaseHelpMeUnderstand
Member
 
Registered: Apr 2016
Posts: 32

Rep: Reputation: Disabled
Capturing output of command


If I want to write a command that would capture the output of the command: ls -l /home/newbie to a file named: newbielisting in my current directory; would this command be ok to use?
ls –l /home/newbie >> newbielisting

Last edited by PleaseHelpMeUnderstand; 04-24-2016 at 03:34 PM.
 
Old 04-24-2016, 04:35 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,750

Rep: Reputation: 271Reputation: 271Reputation: 271
Yes, that will work. Each time that you run the command it will add the latest listing to the end of newbielisting.

-------------------------
Steve Stites
 
1 members found this post helpful.
Old 04-25-2016, 12:24 AM   #3
Turbocapitalist
Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 967
Blog Entries: 3

Rep: Reputation: 393Reputation: 393Reputation: 393Reputation: 393
Quote:
Originally Posted by jailbait View Post
it will add the latest listing to the end of newbielisting.
The >> will add to the target file and a single > by itself will simply replace the whole target file.
The > and >> are "redirects" which can get quite fancy as you get more familiar with them.
 
1 members found this post helpful.
Old 04-25-2016, 12:42 PM   #4
PleaseHelpMeUnderstand
Member
 
Registered: Apr 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
The >> will add to the target file and a single > by itself will simply replace the whole target file.
The > and >> are "redirects" which can get quite fancy as you get more familiar with them.
Is there a right or wrong to > and >> in my case?
 
Old 04-25-2016, 12:47 PM   #5
Turbocapitalist
Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 967
Blog Entries: 3

Rep: Reputation: 393Reputation: 393Reputation: 393Reputation: 393
If you want the file to contain only one set then > is right, because it will overwrite the target file each time.

If you want the file to keep growing then >> is right, because it will keep appending the new output to the target file each time.

Your choice, depending on what you want to do.
 
1 members found this post helpful.
  


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
Capturing the Output of the command SoLostNConfused Linux - Newbie 3 04-19-2016 11:09 AM
Capturing output of top command RHCE_ran Linux - Enterprise 2 05-15-2015 09:58 PM
[SOLVED] capturing output of command in vim editor sumeet inani Linux - Newbie 11 03-22-2011 03:01 AM
Capturing Output from net ads dns register Command jfmorales Linux - General 2 04-07-2010 04:07 PM
Capturing output from background FTP command Lazypete Linux - Server 6 05-22-2008 11:41 AM


All times are GMT -5. The time now is 11:05 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration