[Lilug] Quick question about find tar, and netcat

Akira public at raideen.org
Sun Feb 22 21:26:31 PST 2009


~ ~ wrote:
> I'm attempting to salvage some media files from a laptop that had 
> windows running on it. I've booted a livecd an I've connected another 
> laptop to dump to via firewire (works pretty awesome with eth1394) so 
> I'm  using netcat for speed (over 10gb of media) . I want to do 
> something along the lines of:
> find . -name \*.mp3 -exec tar cfv - '{}' | netcat hostip 1234
> receiving machine is doing :
> netcat -l -p 1234 > Mp3.tar
> but it's not working, mainly I think because I'm attempting to just 
> create with one file as oppossed to append them to the archive. so I've 
> tried tar with -r or -A but still no dice. What am I doing wrong here?

You forgot to escape the exec command:
find . -name \*.mp3 -exec tar -cv {} \; | netcat hostip 1234

Besides that, -exec will also call tar for every file unless you terminate it 
with a + so in your example, you're creating a new file every time. Appending 
doesn't work when outputting to stdout so you could do something like this instead.

find . -name \*.mp3 -exec tar -cv {} + | netcat hostip 1234

However, with 10GB of MP3s, I'd imagine that the file list would be very long 
so that's probably not a good idea. If you don't mind having the files 
extracted at the other end, you could do something like this:

on the sender:
find . -name \*.mp3 -exec tar -c {} \; | netcat hostip 1234

on the receiver:
netcat -l -p 1234 | tar -xv

--Akira




More information about the Lilug mailing list