commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
This command give a human readable result without messing up the sorting.
The following displays only the entries that are duplicates.
Uniq command is mostly used in combination with sort command, as
uniq removes duplicates only from a sorted file. i.e In order for uniq to
work, all the duplicate entries should be in the adjacent lines.
ls -al gives all files, sort +4n sorts by 5th field numerically
Sort using kth column using : delimiter
I had the problem that our monitoring showed that the "/" filesystem is >90% full. This command helped me to find out fast which subdirs are the biggest. The system has many NFS-mounts therefore the -x.
cut -f1,2 - IP range 16
cut -f1,2,3 - IP range 24
cut -f1,2,3,4 - IP range 24
"nl -ba" numbers all lines in the file (including empty lines), "sort -nr"
sorts the lines in descending order, and the "cut" command finally removes
the line numbers again.
here's a version which works on OS X.
M is size in megabytes, man expac to see other sizes
%m is install size
%k is download size
This will list all installed packages on a RedHat/CentOS based system, sort them alphabetically, Parse off the version numbers, and delete any duplicate entries.
This is good if you need to build out a mirrored system or rebuild a failing system.
Uses line-porcelain in git blame, which makes it easier to parse the output.
Watch out if you have several USB drives plugged in: it scans the whole /media/ folder !!! You can replace /media/ by the path of a specific USB drive (something like /media/F77A-530B/)
I use a sound recorder and I want to plug the recorder and grab the most recent sound.
That's what this command does.
Use mv instead of cp to move instead of copy.
Change *.wav to the required file type.
Shows sorted by query time, the headers of mysqlbinlog entries. Then is easy to locate the heavier events on the raw log dump
Sometimes you want to see all of the systcls for a given $thing. I happened to need to easily look at all of the vm sysctls between two boxes and compare them. This is what I came up with.
See the summary.
This doesn't require any non-standard programs.
for those without the tree command.
Per country GET report, based on access log. Easy to transform to unique IP
tree -ifsF --noreport .|sort -n -k2|grep -v '/$'
(rows presenting directory names become hidden)
couldn't stand previous unsortability of at jobs list