It happened to me that I got a season of a tv-show which had all files under the same folder like /home/blah/tv_show/season1/file{1,2,3,4,5,...}.avi
But I like to have them like this:
/home/blah/tv_show/season1/e{1,2,3,4,5,...}/file{1,2,3,4,5,...}.avi
So I can have both the srt and the avi on one folder without cluttering much. This command organizes everything assuming that the filename contains Exx where xx is the number of the episode.
You may need to set:
IFS=$'\n'
if your filenames have spaces.
You can replace "sort -nu" with "sort -u" for a word list sorted or "sort -R" for a random-sorted line (edit: corrected) Show Sample Output
using awk missed the last char thanks @Josay Show Sample Output
search argument in PATH accept grep expressions without args, list all binaries found in PATH Show Sample Output
Searches in order of the directories of $PATH. Stops after finding the entry; looks for only that fileName. Works in Bourne, Korn, Bash and Z shells. Show Sample Output
Handles everything except octets with 255. Ran through ip generator with variable octet lengths.
Bash 4 will let you do {00..19} to get leading zeros, but Bash 3 doesn't have that feature. This technique gets you partway there (the sequences need be such that the last digit ranges from zero to nine - you can't use this for something like Bash 4's {03..27}, for example). When this limitation is not a problem, you can avoid some complicated string manipulation for concatenating leading zeros.
You can add more digits like this: {0..1}{0..9}{0..9} (ranges from 0 to 99 with up to two leading zeros). To pad with additional zeros:
for i in 000{0..1}{0..9}; do echo $i; done
or
for i in {0..1}{0..9}; do echo "000$i"; done
This is useful for creating values to sort or for creating filenames with a fixed format. Note that this will also work:
touch {0..1}{0..9}
Show Sample Output
Email if you disk is over 90% - www.fir3net.com
This is a bit hacky, but if you're setting up a bunch of new LUNs, it can save a bunch of time. Also check out sfdisk. The fdisk will fail if, for example, a partition table already exists.
make password randomly, default 8 char
This will give you a friendly warning if a command doesn't exists. Show Sample Output
For vi(m) users : Add it in your ~/.bashrc Add an "exit" @ the end if you are masochist ;) Show Sample Output
Yep, is hard, but is a way more flexible using pipe.
Hi glaudiston, you can save a few chars by leaving out cat and pipe and still enjoy the added flexibility.
Whenever you compile a new kernel, there are always new modules. The best way to make sure you have the correct modules loaded when you boot is to add all your modules in the modules.autoload file (they will be commented) and uncomment all those modules you need. Also a good way to keep track of the available modules in your system. For other distros you may have to change the name of the file to /etc/modprobe.conf Show Sample Output
This will send the web page at $u to recipient@example.com . To send the web page to oneself, recipient@example.com can be replaced by $(whoami) or $USER. The "charset" is UTF-8 here, but any alternative charset of your choice would work. `wget -O - -o /dev/null $u` may be considered instead of `curl $u` . On some systems the complete path to sendmail may be necessary, for instance /sys/pkg/libexec/sendmail/sendmail for some NetBSD.
Will create a graph of the results for "x bottles of beer on the wall". Requires Gnuplot. Inspired by an xkcd comic: http://xkcd.com/715/ For sample output see: http://tr.im/xbottlesofbeer Show Sample Output
This is just a little snippit to split a large file into smaller chunks (4mb in this example) and then send the chunks off to (e)mail for archival using mutt.
I usually encrypt the file before splitting it using openssl:
openssl des3 -salt -k <password> -in file.tgz -out file.tgz.des3
To restore, simply save attachments and rejoin them using:
cat file.tgz.* > output_name.tgz
and if encrypted, decrypt using:
openssl des3 -d -salt -k <password> -in file.tgz.des3 -out file.tgz
edit: (changed "g" to "e" for political correctness)
The shell has perfectly adequate pattern matching for simple expressions. Show Sample Output
Disable randomisation address 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: