- Forums
- Linux Systems
- How To Pass Or Redirect Output From Shell Command To A File
This Page Contains information about How To Pass Or Redirect Output From Shell Command To A File By tomas in category Linux Systems with 0 Replies. [2889], Last Updated: Sat May 18, 2024
tomas
Sun Feb 25, 2007
0 Comments
658 Visits
Redirecting output from a utility to to a file:
when you tell the shell to execute a command, for example who, teh code for who runs and outputs a listing or furrent users. teh process running the who utilty locates the needed information and formats the report. the defulat output destination for the formatted results of running the who utitly is your screen.
you can tell the shell to redirect the otup of a command awasy from your screent to a file
just follow these steps and i will show you how you can do this:
1. look at the files in your current directory:
ls
2. Type the this command line that includes the > symbol:
who > logged_users
Nothing appears on the screen except the next shell prompt. there is no confimation or acknowledgement that your command went through ok. In UNIX or Linux, "nothing" is good, it usually means the command went through without any problems. You have just instructed the shell to craete a new file and connect it to the output of the process that is running the who utitly.
3. Check that the file you created now exists with this commnad:
ls
now you should see a file called logged_users
4. see the contents of the logged_users file
cat logged_users
thats it
remember, you use the > symbol to redirct information from a command to a file