Celeb Glow
news | March 01, 2026

Save Terminal Output command on OSX

It is simple question but couldn't find the answer, I found and tried tee output.txt and system_profiler > output.txt but no success, they save blank text file. How do I save my terminal output with command in terminal on OSX El Capitan?

5

3 Answers

Assuming command is the command you want to run, you can pipe it's output into the output.txt using:

$ command > output.txt

or

$ command | tee output.txt

If this doesn't hell it may be because the output is not printed on stdout but on stderr. The pipe > is implicit writing for 1> which means "pipe stdout to ...".
If you want to pipe stderr into the file too, you can use

$ command >output.txt 2>&1

This pipes all the output of stderr to the file-descriptor 1 (=stdout) which in turn is piped into the text file.

6

Syntex:

$command > /output/file/location

Example: suppose you want to list out all files and directories of /home/jackson and save its result to /home/jackson/list.txt so command will be--

$ls /home/jackson > /home/jackson/list.txt

but remember if file /home/jackson/list.txt is already exist and contain information, then previous command will erase your previous information and write your command output. so that if you dont want to erase your previous information use ">>" instead of ">". so your command will be.

$ls /home/jackson >> /home/jackson/list.txt

Hope that will help..

1

Q. How do I save my terminal output with command in terminal on OSX El Capitan?

A. Simply give your computer enough time to complete that particular command (1m30s or so).

Your command should run without issue.


On my mac the command:

system_profiler > output.txt

.. Takes about 1m30s to complete.


System profiler also has formatting options and a time-limit if desired.

system_profiler -xml -timeout 3 > textfile.xml
cat ./textfile.xml

Reference:

man system_profiler
system_profiler -usage

Result (with nl to count the line numbers). This file is the same as the command and is about 52000 lines.

system_profiler > output.txt nl output.txt

 1 Accessibility: 2 Accessibility Information: 3 Cursor Magnification: Off 4 Display: Black on White 5 Flash Screen: Off 6 Mouse Keys: Off 7 Slow Keys: Off 8 Sticky Keys: Off 9 VoiceOver: Off 10 Zoom Mode: Full Screen
...
... 51937 Wake On Wireless: Supported 51938 AirDrop: Supported, Channel 0 51939 Status: Off
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy