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:
The command will make it easy to determine free IP ranges in a crowded sub-net.
Need admin right to run dpkg-query
Get link to external sites of a url
This sorts files in multiple directories by their modification date. Note that sorting is done at the end using "sort", instead of using the "-ltr" options to "ls". This ensures correct results when sorting a large number of files, in which case "find" will call "ls" multiple times.
Get a list of all the unique hostnames from the apache configuration files. Handy to see what sites are running on a server. When i saw the command i had some ideas to make it shorter. Here is my version.
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.