coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Split command wait - Request


From: Bob Proulx
Subject: Re: Split command wait - Request
Date: Fri, 20 Jul 2012 15:46:07 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Quinton Dunning wrote:
> Sometimes when I execute the split command I want to use removable
> media and take a file part over to another machine. To do this, the
> split command would have to have a switch that would pause and wait
> for a keystroke before writing the next file.

I remember having needed to do this type of thing in the past and when
I have needed this I have done it this way:

  dst=/dev/fd0
  for f in x*; do
    mv "$f" "$dst" 2>/dev/null || { rm -f "$dst/$f" ; break ;}
  done

It simply moves files until there is an error moving them.  Then it
stops.  Then media can be changed.  Then the command repeated.
Walking through media until all of the files have been moved.  That
works without too much fuss.

However it is a little inconvenient that 'mv' doesn't behave as nicely
as I think it should.  Without doing the above handling it keeps
going.  Lots of noise.  Lots of cruft left behind.  For example:

  mv x* $dst/
  mv: writing `/mnt/tmp/xaf': No space left on device
  mv: failed to extend `/mnt/tmp/xaf': No space left on device
  mv: writing `/mnt/tmp/xag': No space left on device
  mv: failed to extend `/mnt/tmp/xag': No space left on device
  mv: writing `/mnt/tmp/xah': No space left on device
  ...

And it leaves cruft behind that it created.

  -rw-rw-r-- 1 512000 Jul 20 15:25 xaa
  -rw-rw-r-- 1 512000 Jul 20 15:25 xab
  -rw-rw-r-- 1 512000 Jul 20 15:25 xac
  -rw-rw-r-- 1 512000 Jul 20 15:25 xad
  -rw-rw-r-- 1 512000 Jul 20 15:25 xae
  -rw------- 1 204800 Jul 20 15:25 xaf
  -rw------- 1      0 Jul 20 15:25 xag
  -rw------- 1      0 Jul 20 15:25 xah
  -rw------- 1      0 Jul 20 15:25 xai
  -rw------- 1      0 Jul 20 15:25 xaj
  -rw------- 1      0 Jul 20 15:25 xak
  -rw------- 1      0 Jul 20 15:25 xal
  -rw------- 1      0 Jul 20 15:25 xam
  ...

I think it would be a nice enhancement that if mv created a file and
couldn't write to it that it didn't leave that file behind.

Of course the traditional mv keeps going so not sure there is any way
to improve upon that behavior now.

I was able to manually create a test harness for this by creating a
minimum size lvm partition and then using it as the destination.

  # lvcreate -L4M -nsmall v1
  # mkfs -t ext2 /dev/v1/small
  # mount /dev/v1/small /mnt
  # mkdir /mnt/tmp
  # chmod a+rwxt /mnt/tmp

Then test it like this:

  $ mkdir /tmp/testinput
  $ cd /tmp/testinput
  $ dd if=/dev/zero of=testfile bs=1M count=10
  $ split --bytes=500K testfile

  $ for f in x*;do mv $f /mnt/tmp/ 2>/dev/null || { rm -f /mnt/tmp/$f; break;} 
done

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]