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 is an extremely useful tool. 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 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:UsersmeMovies
dir > mymovies.txt

Open 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:UsersJimmyJoUserManDocumentsheywhatsinhere.txt

Many 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]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


One response to “Save The Output Of Any Terminal Command With One Parameter”