Commands by tamasrepus (3)

What's this? 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

Randomize lines in a file
This appends a random number as a first filed of all lines in SOMEFILE then sorts by the first column and finally cuts of the random numbers.

Record camera's output to a avi file
video.avi is the resulting file. Press Ctrl+c to stop the recording. You can change the OVC option to another to record into a different format.

Binary clock
displays current time in "binary clock" format (loosely) inspired by: "Decoding": 8421 .... - 1st hour digit: 0 *..* - 2nd hour digit: 9 (8+1) .*.. - 1st minutes digit: 4 *..* - 2nd minutes digit: 9 (8+1) Prompt-command version: PROMPT_COMMAND='echo "10 i 2 o $(date +"%H%M"|cut -b 1,2,3,4 --output-delimiter=" ") f"|dc|tac|xargs printf "%04d\n"|tr "01" ".*"'

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

get all Amazon cloud (amazonws etc) ipv6 subnets

grab all commandlinefu shell functions into a single file, suitable for sourcing.
Much simpler but not as many features as the alternative.

Losslessly rotate videos from your phone by 90 degrees.
Takes all the .3gp files in the directory, rotates them by 90 degrees, and saves them in the lossless ffv1 encoding. If this rotates in the wrong direction, you may want transponse=1 Re-encoding to ffv1 may result in a significant increase in file size, as it is a lossless format. Other applications may not recognize ffv1 if they don't use ffmpeg code. "huffyuv" might be another option for lossless saving of your transformations. The audio may be re-encoded as well, if the encoding used by your 3gp file doesn't work in a avi container.

For a $FILE, extracts the path, filename, filename without extension and extension.
Useful for use in other scripts for renaming, testing for extensions, etc.

(DEBIAN-BASED DISTROS) Find total installed size of packages given a search term
Replace \-dev with whatever you wanna search for

Add a line to a file using sudo
This is the solution to the common mistake made by sudo newbies, since $ sudo echo "foo bar" >> /path/to/some/file does NOT add to the file as root. Alternatively, $ sudo echo "foo bar" > /path/to/some/file should be replaced by $ echo "foo bar" | sudo tee /path/to/some/file And you can add a >/dev/null in the end if you're not interested in the tee stdout : $ echo "foo bar" | sudo tee -a /path/to/some/file >/dev/null

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.


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: