Commands tagged split (15)

  • 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 -` Show Sample Output


    17
    tar cf - <dir>|split -b<max_size>M - <name>.tar.
    dinomite · 2009-11-11 01:53:33 5
  • 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.


    10
    base64 /dev/urandom | head -c 33554432 | split -b 8192 -da 4 - dummy.
    pdxdoughnut · 2013-11-12 17:56:23 8
  • -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.


    7
    vim -o file1 file2...
    rkulla · 2010-04-13 22:09:47 4
  • 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: hexdump /dev/loop4 . gzip -9 < /dev/loop6 > part6.gz . cat /dev/loop10 > /media/usb/part10.bin Show Sample Output


    5
    FILE=file_name; CHUNK=$((64*1024*1024)); SIZE=$(stat -c "%s" $FILE); for ((i=0; i < $SIZE; i+=$CHUNK)); do losetup --find --show --offset=$i --sizelimit=$CHUNK $FILE; done
    flatcap · 2014-10-03 13:18:19 10
  • 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


    2
    dd if=inputfile of=split3 bs=16m count=32 skip=64
    jearsh · 2010-02-21 10:09:46 3
  • 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 =) Show Sample Output


    2
    ffmpeg -i 100_0029.MOV -ss 00:00:00 -t 00:04:00 100_0029_1.MOV
    nickleus · 2010-08-08 23:43:28 3
  • 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. Show Sample Output


    2
    vim -d '+diffoff!' file1 file2
    greggster · 2012-08-30 07:51:41 6
  • Is this not the same


    2
    vim -O file1 file2
    trantorvega · 2012-09-06 14:52:50 4
  • 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


    0
    rar a -m5 -v5M -R myarchive.rar /home/
    piovisqui · 2009-05-27 15:53:18 9
  • Will split the std input lines into files grouped by the 5th column content.


    0
    awk -F'\t' '{print $0 >>$5.tsv}'
    pykler · 2012-05-16 18:18:16 3
  • 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.


    0
    convert yourdoublewideimage.jpg -crop 50%x100% +repage output.jpg
    pagesix1536 · 2014-01-15 15:34:41 8
  • IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type powershell 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. Show Sample Output


    0
    sajb {$ip="192.168.100.1";$old=0;while(1){$up=test-connection -quiet -count 1 $ip;if($up-ne$old){$s=(date -u %s).split('.')[0]+' '+(date -f s).replace('T',' ')+' '+$ip+' '+$(if($up){'Up'}else{'Down'});echo $s|out-file -a $home\ping.txt;$old=$up}sleep 10}}
    omap7777 · 2015-12-28 20:33:08 15
  • 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)


    -1
    split -b4m file.tgz file.tgz. ; for i in file.tgz.*; do SUBJ="Backup Archive"; MSG="Archive File Attached"; echo $MSG | mutt -a $i -s $SUBJ YourEmail@(E)mail.com
    tboulay · 2010-03-20 16:49:19 8
  • Open files in tabs


    -2
    vim -p file1 file2 [...]
    richard · 2010-04-15 11:40:19 3
  • 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 set ARRAY[0]=test1,100 and set ARRAY[1]=test2,200 Be sure to replace %A, %B, etc. with %%A, %%B, etc. when using this from inside of batch files. Show Sample Output


    -2
    FOR /F "tokens=3* delims=[]=," %A IN ('SET ARRAY[') DO ( echo %A -- %B )
    Marco · 2010-08-10 12:12:27 5

What's this?

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.

Share Your Commands


Check These Out

Watch active calls on an Asterisk PBX
Only the number of calls nothing else.

mirrors directory to a ftp server
http://lftp.yar.ru/

list files recursively by size

github push-ing behind draconian proxies!
If you are behind a restrictive proxy/firewall that blocks port 22 connections but allows SSL on 443 (like most do) then you can still push changes to your github repository. Your .ssh/config file should contain: Host * ForwardX11 no TCPKeepAlive yes ProtocolKeepAlives 30 ProxyCommand /usr/local/bin/proxytunnel -v -p -d %h:443 Host User git Hostname ssh.github.com ChallengeResponseAuthentication yes IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes Basically proxytunnel "tunnels" your ssh connection through port 443. You could also use corkscrew or some other tunneling program that is available in your distro's repository. PS: I generally use "github.com" as the SSH-HOST so that urls of the kind git@github.com:USER/REPO.git work transparently :) You

list files recursively by size

list files recursively by size

Create QR codes from a URL.
QR codes are those funny square 2d bar codes that everyone seems to be pointing their smart phones at. Try the following... $ qrurl http://xkcd.com Then open qr.*.png in your favorite image viewer. Point your the bar code reader on your smart phone at the code, and you'll shortly be reading xkcd on your phone. URLs are not the only thing that can be encoded by QR codes... short texts (to around 2K) can be encoded this way, although this function doesn't do any URL encoding, so unless you want to do that by hand it won't be useful for that.

host - DNS lookup utility
host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa. When no arguments or options are given, host prints a short summary of its command line arguments and options.

power off system in X minutes
Replace 60 with the number of minutes until you want the machine to shut down. Alternatively give an absolute time in the format hh:mm (shutdown -h 9:30) Or shutdown right away (shutdown -h now)

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: