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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type
Uses sajb to start a PowerShell background job that pings an IP host every 10 seconds.
Any changes in the host's Up/Down state is time-stamped and logged to a file.
Date/time stamps are logged in two formats: Unix and human-readable.
A while(1) loop repeats the test every 10 seconds by using the sleep command.
See the Sample Output for more detail.
I use this command to log Up/Down events of my Motorola SB6141 cable modem (192.168.100.1).
To end the logging, close the PowerShell window or use the "exit" command.
It's common to want to split up large files and the usual method is to use split(1).
If you have a 10GiB file, you'll need 10GiB of free space.
Then the OS has to read 10GiB and write 10GiB (usually on the same filesystem).
This takes AGES.
The command uses a set of loop block devices to create fake chunks, but without making any changes to the file.
This means the file splitting is nearly instantaneous.
The example creates a 1GiB file, then splits it into 16 x 64MiB chunks (/dev/loop0 .. loop15).
Note: This isn't a drop-in replacement for using split. The results are block devices.
tar and zip won't do what you expect when given block devices.
These commands will work:
gzip -9 < /dev/loop6 > part6.gz
cat /dev/loop10 > /media/usb/part10.bin
Output should be two JPG files named like "output-1.jpg" and "output-2.jpg". The convert command is part of ImageMagick so you'll need that and dependent packages installed to use it.
Avoiding a for loop brought this time down to less than 3 seconds on my old machine. And just to be clear, 33554432 = 8192 * 4086.
Is this not the same
Use vim's diff mode to edit two or more files in one window. The '+diffoff!' turns off diff highlighting when the session is started.
Use ctrl+w + ctrl+w to switch between windows.
Will split the std input lines into files grouped by the 5th column content.
Loops over array of a system var, splits its values and puts the values into %A, %B, %C, %D, and so on.
Create array before, like
Be sure to replace %A, %B, etc. with %%A, %%B, etc. when using this from inside of batch files.
i have a large video file, 500+ MB, so i cant upload it to flickr, so to reduce the size i split it into 2 files. the command shows the splitting for the first file, from 0-4 minutes. ss is start time and t is duration (how long you want the output file to be).
credit goes to philc: http://ubuntuforums.org/showthread.php?t=480343
NOTE: when i made the second half of the video, i got a *lot* of lines like this:
frame= 0 fps= 0 q=0.0 size= 0kB time=10000000000.00 bitrate= 0.0kbit
just be patient, it is working =)
Open files in tabs
-o acts like :spit. Use -O (capital o) for side-by-side like :vsplit. Use vim -d or vimdiff if you need a diff(1) comparison.
To split gnu Screen instead of vim, use ^A S for horizontal, ^A | for vertical.
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)
bs = buffer size (basically defined the size of a "unit" used by count and skip)
count = the number of buffers to copy (16m * 32 = 1/2 gig)
skip = (32 * 2) we are grabbing piece 3...which means 2 have already been written so skip (2 * count)
i will edit this later if i can to make this all more understandable
Create a tar file in multiple parts if it's to large for a single disk, your filesystem, etc.
Rejoin later with `cat .tar.*|tar xf -`
a - archive
m5 - compression level, 0= lowest compression...1...2...3...4...5= max compression
-v5M split the output file in 5 megabytes archives, change to 700 for a CD, or 4200 for a DVD
R recursive for directories, do not use it for files
It's better to have the output of a compression already split than use the 'split' command after compression, would consume the double amount of disk space. Found at http://www.ubuntu-unleashed.com/2008/05/howto-create-split-rar-files-in-ubuntu.html