MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
March
Sun Mon Tue Wed Thu Fri Sat
23
       
2015
Months
Mar


Mon, Mar 23, 2015 10:53 pm

Capturing output from Terminal on OS X

If you wish to capture the contents of the Terminal window on OS X, e.g., if you are running the top command and would like to capture a snapshot of what is in the terminal window, but would like to have that information in text format, rather than as an image file, which is what you would get if you used Preview and chose "File" and then "Take Screen Shot", you can use Command-S from the Terminal window. You will be prompted as to where you wish to save the file; the default file name is Terminal Saved Output in the Documents folder for the account you are logged in under. When you choose "Save", if the file exists, you will see the message below:

"Terminal Saved Output" already exists.

A file or folder with the same name already exists in the folder Documents. Replacing it will overwrite its current contents.

Cancel   Replace

If you choose "Replace" the contents of the current Terminal tab will be written to the file, including the scrollback buffer, i.e., all of the information displayed in the window for the current Terminal tab, even what is not shown on the screen unless you scroll upwards, is recorded to the file.

So, if I wanted to capture the current output of top -o cpu, I could hit the Command and S keys to save the displayed information and then edit out anything from the scrollback buffer to have something like what is shown below.

$ top -o cpu

Processes: 147 total, 7 running, 3 stuck, 137 sleeping, 831 threads   22:35:37
Load Avg: 3.28, 3.22, 3.24  CPU usage: 84.86% user, 15.13% sys, 0.0% idle
SharedLibs: 484K resident, 0B data, 0B linkedit.
MemRegions: 147433 total, 1663M resident, 37M private, 558M shared.
PhysMem: 849M wired, 1613M active, 1597M inactive, 4059M used, 36M free.
VM: 318G vsize, 1026M framework vsize, 33663121(1) pageins, 8539859(0) pageouts
Networks: packets: 19460598/11G in, 27466428/5435M out.
Disks: 19736694/473G read, 9899513/434G written.

PID    COMMAND      %CPU TIME     #TH  #WQ  #PORT #MREGS RPRVT  RSHRD  RSIZE
215    firefox      83.9 308 hrs  71/1 3    428+  90860- 967M-  82M    1143M-
27     opendirector 66.7 61:34:17 12/1 12/1 709   229    3780K  1936K  7116K
33110  top          21.3 00:02.19 1/1  0    24    33     1904K  216K   2652K
124    WindowServer 12.6 15:23:27 4/1  1    738+  23303+ 15M-   172M+  141M+
213    Terminal     6.0  09:50.46 10   5    214   933+   16M+   12M+   35M+
13601  Preview      5.4  01:11.19 3    1    661   2642+  45M-   69M+   86M+
0      kernel_task  2.5  06:57:45 87/2 0    2     851    30M    0B     461M+
29265- Microsoft En 1.4  12:06:51 14   3    440   2139   100M   65M    163M
55     hidd         0.6  27:51.88 5/1  3/1  92    67     620K   312K   1788K
15258- Microsoft Po 0.3  73:07.63 5    3    188   986    12M    36M    33M
221-   Microsoft Wo 0.3  01:54:36 5    3    155   963    31M    45M    57M
229-   My Day       0.2  01:46:08 6    1    167   447-   13M-   33M    36M-
210-   Microsoft Ex 0.1  77:31.36 5    3    206   2356   58M    93M    101M
68-    dsAccessServ 0.1  51:10.38 14   3    152   204    1456K  1764K  6032K
71-    LANrev Agent 0.0  27:48.38 13   2    242+  90+    2540K+ 1932K  2912K+
69     SymDaemon    0.0  05:33:54 16   1    1187  434    18M    2568K  26M
651    java         0.0  26:11.37 20   1    274   331    17M    4196K  20M
10267  VMware Fusio 0.0  03:59.72 9    1    265   529    3900K  17M    13M
613-   Microsoft Da 0.0  64:23.94 3    1    106   239    76M    22M    93M

[/os/os-x] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo