Monday, December 13, 2010

25 EVEN MORE – SICK LINUX COMMANDS

1) MONITOR PROGRESS OF A COMMAND

pv access.log | gzip > access.log.gz

Pipe viewer is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. Source: http://www.catonmat.net/blog/unix-utilities-pipe-viewer/

2) GRAPHICAL TREE OF SUB-DIRECTORIES

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
Prints a graphical directory tree from your current directory

3) DELETE ALL FILES IN A FOLDER THAT DON’T MATCH A CERTAIN FILE EXTENSION

rm !(*.foo|*.bar|*.baz)
Deletes all files in a folder that are NOT *.foo, *.bar or *.baz files. Edit the pattern inside the brackets as you like.

4) EASY AND FAST ACCESS TO OFTEN EXECUTED COMMANDS THAT ARE VERY LONG AND COMPLEX.


some_very_long_and_complex_command # label
When using reverse-i-search you have to type some part of the command that you want to retrieve. However, if the command is very complex it might be difficult to recall the parts that will uniquely identify this command. Using the above trick it’s possible to label your commands and access them easily by pressing ^R and typing the label (should be short and descriptive).

5) DEFINE A QUICK CALCULATOR FUNCTION

? () { echo "$*" | bc -l; }
defines a handy function for quick calculations from cli.

once defined:

? 10*2+3
6) DISPLAY A COOL CLOCK ON YOUR TERMINAL

watch -t -n1 "date +%T|figlet"
This command displays a clock on your terminal which updates the time every second. Press Ctrl-C to exit.

A couple of variants:

A little bit bigger text:

watch -t -n1 "date +%T|figlet -f big"You can try other figlet fonts, too.

Read more: urfix's blog

Posted via email from .NET Info