Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi.

How should the output of Linux command ( $PS -e ) save in text files ?
Posted
Comments
Sergey Alexandrovich Kryukov 27-Nov-15 1:52am    
Script? In which is scripting language or command shell interpreter? There are quite a few. What have you tried so far?
—SA

The Bash/KSH and POSIX shell provides a file redirection option to redirect the output of commands to a file using the following two operators:

1. > is output redirection symbol.
2. >> is append output redirection symbol.

So Your command would be

$PS -e > /root/output.txt

Please note that output.txt file will be created if it doesn't exist. And if file output.txt exist it will be overwritten.
 
Share this answer
 
I would read up on using the pipe character '>' for redirecting stdout/console output - for example

$PS -e >Process-data.txt


or

$PS -e >> Process-data.txt


a single '>' creates a file and stores the output to it (from the stdout of the ps command)
a double '>' ie '>>' appends stdout data to the 'redirection target'

does that help ?
 
Share this answer
 
Comments
Richard MacCutchan 27-Nov-15 3:23am    
That's a redirection character, a pipe is '|'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900