LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-19-2011, 06:57 AM   #1
ankitm
Member
 
Registered: Sep 2011
Posts: 33

Rep: Reputation: Disabled
output of the command


fname=try.tmp.$$
ps -C a.out -o pid= | grep -v $$ > ${fname} 2 > /dev/null

Could anyone tell the output of this command
what does 2 here signifies as there are two redirection statements

When I executed it in commna dline it showed Ambigous redirection.
However when "I executed it in a script it worked but I am unable to figure out what this actually does

Please help.....
 
Old 10-19-2011, 07:49 AM   #2
aav
LQ Newbie
 
Registered: Sep 2011
Posts: 1

Rep: Reputation: Disabled
2 is for stderr (standard error).
 
Old 10-19-2011, 08:08 AM   #3
jrhorn424
LQ Newbie
 
Registered: Oct 2011
Location: Virginia
Posts: 20

Rep: Reputation: Disabled
Quote:
Originally Posted by aav View Post
2 is for stderr (standard error).
These numbers are called file descriptors, and 1 is for standard output. 0 is for standard input. Have a look at the bash manual and search for "file descriptor" and "redirection" for more information.
 
1 members found this post helpful.
Old 10-19-2011, 08:09 AM   #4
goossen
Member
 
Registered: May 2006
Location: Bayern, Germany
Distribution: Many
Posts: 224

Rep: Reputation: 41
From man ps:
Quote:
Print only the process IDs of syslogd:
ps -C syslogd -o pid=
And "grep -v" means print the not matching lines.
 
Old 10-19-2011, 08:36 AM   #5
ankitm
Member
 
Registered: Sep 2011
Posts: 33

Original Poster
Rep: Reputation: Disabled
Thanks for help

This means this should store the pid of a.out in the file ,but on executing it , i checked that the file was empty .

I have a process named a.out created and running in the background.

So what might be the reason fot it?
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect the output of exec command output in perl? sudhap85 Linux - Newbie 3 08-28-2009 03:35 PM
[SOLVED] append command output to file by giving command in terminal sumeet inani Linux - Newbie 4 07-03-2009 10:36 AM
Grep on output of command returns all output traigo Linux - Newbie 2 02-24-2009 05:15 PM
how to get the absolute path information of a command from ps command output ratul_11 Linux - General 1 08-06-2008 02:10 AM
How do I parse the output of a command that output to standard out? gauol Programming 9 01-17-2008 01:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:04 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
Open Source Consulting | Domain Registration