Searches for dates on lines by themselves. Uses that date to prepend all rows that contain SEARCHSTRING with the date, until it reaches another line with a date by itself. This fixed an issue with a specific log export where there would be a date, followed by all of the entries for that date.
I use this to generate a playlist with all the podcasts I listen to. Ordered from most recent to older. Show Sample Output
connects to all the screen instances running.
Prefixes each output line with time between it and the previous one. Show Sample Output
Prints the path/filename and sparseness of any sparse files (files that use less actual space than their total size because the filesystem treats large blocks of 00 bytes efficiently).
Scrap everything and use `gawk` to do all the magic, since it's like the future or something.
gawk 'match($11, /[a-z]{3}$/) && match($9, /^ata-/) { gsub("../", ""); print $11,"\t",$9 }'
Yank out only ata- lines that have a drive letter (ignore lines with partitions). Then strip ../../ and print the output.
Yay awk. Be sure to see the alternatives as my initial command is listed there. This one is a revision of the original.
Show Sample Output
On a Gentoo system, this command will tell you which packets you have installed and sort them by how much space they consume. Good for finding out space-hogs when tidying up disk space. Show Sample Output
A little bit smaller, faster and should handle files with special characters in the name.
While the posted solution works, I'm a bit uneasy about the "%d" part. This would be hyper-correct approach:
lsof|gawk '$4~/txt/{next};/REG.*\(deleted\)$/{sub(/.$/,"",$4);printf ">/proc/%s/fd/%s\n", $2,$4}'
Oh, and you gotta pipe the result to sh if you want it to actually trim the files. ;)
Btw, this approach also removes false negatives (OP's command skips any deleted files with "txt" in their name).
get a list of temps of your hard-drives. Show Sample Output
You need sysstat and gawk for this to work. Show Sample Output
Among other things, this allows the sorting of comment descriptions and command lines retrieved as text from CommandLineFu.com. Show Sample Output
Sorts blank line delimited paragraphs. '-i' -- case insensitivity option -- removes redundant paragraphs in a case insensitive way, and then sorts in a case insensitive way. If you search CommandLineFu with multiple anded terms searches, redundancy can ensue. This sorts the retrieved text (among other kinds of data), and removes the redundancy. Show Sample Output
You can also use gawk: ps auxww | gawk '/application/' | gawk '/processtobekilled/' | gawk '{print $2}' | grep -v grep | xargs kill -9
Now we can capture only a specific window (we have to chose by clicking on it) ffmpeg complains about "Frame size must be a multiple of 2" so we calculate the upper even number with (g)awk trickery. We remove the grep, we are already using (g)awk here ....why losing time with grep !!! ;) Show Sample Output
This command will find the highest context switches on a server and give you the process listing. Show Sample Output
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.
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
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: