

bash_history” again.)Īnd finally, it wouldn’t be a command-line tip if I didn’t offer the usual disclaimers-be very careful of what you type, always copy and paste commands if you aren’t confident in your skills, blah de blah blah. (If the command above didn’t work, you may have navigated away from your user folder within Terminal, and if so, you can use the “cd ~” command before running “open. That should open your list of previously entered commands within your default text editor, and you can search through it at your leisure. You could just open the file containing your history and view it as text! Unsurprisingly, though, that file is hidden by default, so to access it, open a new Terminal window, type this command in, and press Return: open. You could just open the file containing your history and view it as text Unsurprisingly, though, that file is hidden by default, so to access it, open a new Terminal window, type this command in. If you want to add to existing text instead of replacing it, type “greater than” twice (“>”).įinally, there is one more method I’m going to suggest, and I think it’s the simplest of all. …means “run the ‘history’ command, and then create a new file on Melissa’s desktop called ‘history.txt’ with the results.” That little “greater than” symbol is handy for all sorts of stuff within Terminal, but be aware of its one big caveat: If there is already an existing file in your requested location with the same name, using the command above will replace it.

So this example… history > /Users/melissa/Desktop/history.txt

If you’re familiar with using the “greater than” (“>”) symbol in Terminal, that’s an easy way to make “history” easier to read-it’ll take the command and create a file you designate with the output. To do the former, simply type “history” in at the prompt, and you’ll get what you’re looking for. However, you could also just view your history in either the Terminal window or as a text file. 2) Your entire command line history up to the last clear. To view your command history in the Terminal app, follow these steps: 1) Launch the Terminal app and enter the following command and then press the Return key on your keyboard. There are quite a few ways you could go about this I mentioned one method a couple of years ago that’ll help you search through the history, which is useful if you at least know a keyword in the command you’re trying to find. This command will let you see all the commands entered since the most recent clear command was used.
#Terminal mac os list command results how to#
So if, for example, he’d used a “defaults write” command to alter how OS X looks or acts, he could find exactly what he did in his history to know how to reverse the changes. You might consider doing it periodically, in the future, given that your terminal's history appears to have some significant value.Last week, I had a very nice reader email me to ask a question about how to look through the commands he’d previously typed into Terminal. These saved state files use a custom binary format, that you can't be read otherwise than by the Terminal program itself.īy the way, it might be worth mentioning that you can, at anytime, save the content of a Terminal window to a text file, from the Shell menu. Note the spaces between the different components of the command. The l option requests a long listing, and the A option omits the. Option(s): Options add conditions, limits, or other modifiers to the BSD command. The procedure for this should be that you first quit Terminal, then restore the whole directory (for example using Time Machine), then simply launch Terminal. BSD command: ls is the command to display a list of a folder’s contents. You could even try some "file undelete" tools in that directory, though these tools are rather rare on OS X. Therefore, it seems that if you can restore files in this directory from some former backup, you should get back your history. The new thread, if you want to comment on it is: Activate/Deactivate USB connected device. Files in this directory are modified in real time whenever new events occurs in the terminal window, and unless I am mistaken, should be included in Time Machine backups. This won't help in your situation.įrom what I can see, it appears that Terminal store save window's state (including console history) inside directory /Users//Library/Saved Application State//. Bash's history only store executed commands, not their output, and only a limited number of them (usually 500, as defined by environment variable HISTFILESIZE).
