Today I learned something new about my terminal on OS X; I learned about the pbcopy and pbpaste commands. These two shell commands copy shell output into the clipboard, and pastes the clipboard content into the shell, respectively. I.e., today I needed to grep+cut through some large log files, and the results of these commands I wanted to paste to a spreadsheet. Instead of having to 1) perform the command, and then 2) use the mouse to scroll up and select all of the results to copy-paste them into the spreadsheet, I found that I could use pbcopy to pipe stdout directly to the clipboard:
grep foo logfile.txt | cut -d " " -f1,2,4 | pbcopyAfter running this I could just go to my spreadsheet application and insert the three selected rows.
This little command is a real time saver I can tell you! I must have saved at least an hours work today alone ;-)
No comments:
Post a Comment