The nano text editor has some really cool tricks up its sleeve. One that you probably weren’t aware of was the ability to execute commands and add the output of those commands into the file you are working with.
SEE: The best programming languages to learn–and the worst (TechRepublic Premium)
Say, for example, you are writing a script or some other file and you needed the contents of your home directory added to it. You could always open a second terminal window, issue the ls command, copy the results, and then paste them into the document. Or, you could use the built-in Execute feature that would paste the output of the command into the document for you. It’s so much easier than the manual method.
Let me show you how it’s done.
Open a terminal window and then issue the command nano to launch the editor. To use the execute feature, hit the Ctrl + T keyboard shortcut. You should now see a Command to execute.
Let’s say you do want to read in the contents of your home directory into the file. For that, you would type ls ~/ and hit enter. Nano would automatically populate the file with the output of that command.
Obviously, some commands aren’t going to work as well as others. For example, you wouldn’t use the top command (because of the real-time output), but you might use the cat command to read the contents of another file into the one you’re currently editing. With nano’s execute feature, you can get really creative with what output you read into your files.
Using this tool can be way more efficient than the old copy/paste method. Give it a try and see if the Execute feature doesn’t become one of your favorites when using the nano text editor.
Subscribe to the Developer Insider Newsletter
From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays