Commands by aimaz (1)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Using a single sudo to run multiple && arguments
This will also work with bash instead of sh shell sudo bash -c 'apt update -y && apt upgrade -y'

Prints total line count contribution per user for an SVN repository
make usable on OSX with filenames containing spaces. note: will still break if filenames contain newlines... possible, but who does that?!

Make all GUI stuff show up on the display connected to the computer (when you're logged in via SSH)
If you have multiple displays or monitors the DISPLAY environment variable will tell X where to send the output. This is very handy for setting up a mediacenter at home. You can plugin the computer to the TV and then ssh to the computer and set the DISPLAY as above, then run your program and it will show up on the TV.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Convert JSON to YAML
You need to install the Catmandu Perl module via `cpanm Catmandu`

replace a character/word/string in a file using vim
Replace all ocurrences in the file. The g option is to replace more than one occurrence in the same line. Whitout the g option, it only replace the first occurrence in the line.

Create a tar of directory structure only
The original suggestion did not work for me, when operating on folders located on an external mount (ie other than the root device) in Ubuntu. A variation using xargs does the trick.

Stat each file in a directory
Possible simplification of egrep-awk-sort with find and -exec with xargs.

modify a file in place with perl
changes THIS to THAT in all files matching fileglob* without using secondary files

Send an email from the terminal when job finishes
Might as well include the status code it exited with so you know right away if it failed or not.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: