Il blog di Gas

Solo un altro sito WordPress

Move files in bash with tar and progress bar

with 4 comments

Example
gas@caldaia ~ $ my_move source_dir/ dest_dir/
43.5GB at 61.0MB/s eta: 59s 91% [=========== ]

You need to install “command line progress bar”, in gentoo it can be installed with emerge bar in ubuntu the deb can be grabbed here and installed with gdebi.

my_move:
#! /bin/sh
SOURCE="$1"
DEST="$2"
SIZE=$(du -sb "$SOURCE"|awk '{print $1}')
(cd "$SOURCE" && tar -cf - *)|bar -s $SIZE| (cd "$DEST" && tar -xBpf -)

Written by gas

settembre 11th, 2010 at 3:14 pm

Posted in English,Linux

Tagged with , ,

4 Responses to 'Move files in bash with tar and progress bar'

Subscribe to comments with RSS or TrackBack to 'Move files in bash with tar and progress bar'.

  1. see-also:

    [I] sys-apps/pv
    Available versions: 1.1.4 {debug nls}
    Installed versions: 1.1.4(02:54:46 PM 08/30/2010)(nls -debug)
    Homepage: http://www.ivarch.com/programs/pv.shtml
    Description: Pipe Viewer: a tool for monitoring the progress of data through a pipe

    Smorg

    11 set 10 at 17:04

  2. Very nice, thanks. Have you thought about using rsync instead of tar? rsync works well as an improved copy command. I’m not sure how you would get passwords into the pipe for the nifty progress bar but it would be nice to be able to copy over a network like this.

    twitter

    12 set 10 at 17:11

  3. Isn’t this more like a copy since tar doesn’t remove the source? It’s also good practice to quote $SOURCE and $DEST.

    Ewoud Kohl van Wijngaarden

    15 set 10 at 04:47

  4. for such things i like to use
    rsync -av –progress src/ dst/

    flux

    20 set 10 at 23:15

Leave a Reply