commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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:
Create a bunch of random files with random binary content. Basically dd dumps randomly from your hard disk to files random-file*.
The command `cat file >> file` failes with the following error message:
cat: file: input file is output file
`tee` is a nice workaround without using any temporary files.
If you use newsgroups then you'll have come across split files before. Joining together a whole batch of them can be a pain so this will do the whole folder in one.
Say you want to execute 'file' on the command 'top' (to determine what type of file it is); but you don't know where 'top' resides: preface the argument with = and zsh will implicitly prepend the path.
you don't need to echo, just a plain redirect is enough to empty the file
Empties all files in /var/log over 5000k. Useful if /var goes crazy or if you just haven't cleaned up in a while.
When you don't have c_rehash handy. Really simple - if you have a .pem file that doesn't really contain a x509 cert (let's say, newreq.pem), it will create a link, simply called '.0', pointing to that file.
Works in Ubuntu, I hope it will work on all Linux machines. For Unixes, tail should be capable of handling more than one file with '-f' option.
This command line simply take log files which are text files, and not ending with a number, and it will continuously monitor those files.
Putting one alias in .profile will be more useful.
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.
This command is useful if you accidentally untar or unzip an archive in a directory and you want to automatically remove the files. Just untar the files again in a subdirectory and then run the above command e.g.
for file in ~/Desktop/temp/*; do rm ~/Desktop/`basename $file`; done
You can use multiple field separators by separating them with | (=or).
This may be helpful when you want to split a string by two separators for example.
#echo "one=two three" | awk -F "=| " {'print $1, $3'}
one three
Split File in 19 MB big parts, putting parts together again via
cat Nameforpartaa Nameforpartab Nameforpartac >> File
You can read, add, delete and modify Windows permissions from Linux using smbcacls from the smb-client package.
Just a quick and simple one to demonstrate Bash For loop. Copies 'file' to multiple ssh hosts.
(relies on 'imagemagick')
Convert all .png files to .gif. This can also go the other way if you reverse the file extensions in the command, e.g.:
for file in *.gif; do convert "$file" "$(basename $file .gif).png"; done
If the file is named 'example1.png' it will be named 'example1.gif' when it is complete.
(relies on 'imagemagick')
This command will convert all .pdf files in a directory into a 800px (wide or height, whichever is smaller) image (with the aspect ratio kept) .jpg.
If the file is named 'example1.pdf' it will be named 'example1.jpg' when it is complete.
This is a VERY worthwhile command! People pay hundreds of dollars for this in the Windows world.
My .jpg files average between 150kB to 300kB, but your's may differ.
`split -b 1k file` splits files into 1k chunks. Rejoin them with `cat x* > file`.
Bash shortcut to work with the last argument of your last command
This command creates a file of arbitrary size in a windows environment.