Wednesday, September 4, 2013

Save the Output of Any Terminal Command with One Parameter

Save the Output of Any Terminal Command with One Parameter

Windows/Mac/Linux: The command line (or terminal) is an extremely useful tool, but if you have a command that returns a wall of text, you can save it to a single text file with this simple parameter.

By using a single parameter at the end of your normal commands, you can pipe the output directly into a basic text file. Just add "> FILENAME.txt" (no quotes) to the very end of your command. This will create a .txt file with everything you would have seen on the screen in an easy-to-copy form. So, if you wanted a list of all the files in your Movies directory, you would run the "dir" command with this parameter (for Windows users):

CD C:\Users\me\Movies
dir > mymovies.txtOpen up mymovies.txt, and you'll see a list of every file in that Movies folder.

If you want to put the file somewhere other than your working directory, you can spell out the location in it's entirety. For example:

dir > C:\Users\JimmyJoUserMan\Documents\heywhatsinhere.txtMany of you command line veterans are very familiar with this trick, but for those still learning their way around, it's a great shortcut to have on hand.

How to copy command prompt outputs to the Windows Clipboard | Ghacks

No comments:

Post a Comment