Pipe Output of ls -lR into a tar archive

damon fister damonfister at comcast.net
Fri Jun 18 20:40:09 UTC 2004


Charles Curley wrote:

>On Fri, Jun 18, 2004 at 11:04:36AM -0700, Ow Mun Heng wrote:
>  
>
>>I need help,
>>
>>	EIther google isn't finding the stuffs or my search terms are too
>>muddled.
>>
>>I just want to create a tar archive from a directory file listing.
>>
>>something like
>>
>>ls -laR ~/the/dir/to/list | tar -cvf - /tmp/tarred-dir-list.tar.gz
>>
>>I can't seem to find the correct syntax
>>    
>>
>
>If all you want is a compressed text file with a recursive descent
>listing of a given directory, why bother with tar? Try this:
>
>ls -lR dir | gzip > lslR.gz
>
>  
>
The string you want to execute is:

ls -laR ~/the/dir/to/list > dirlist.txt; gzip dirlist.txt

You first need to output the listing to a plain text file, otherwards gzip will take the filenames as arguments. Remember that tar is only needed if you are grouping several files together i.e. as in compressing a directory structure and all the files within it you would tar -czf mytarball.tar.gz /dir/to/tar . To just compress a single file use gzip.

Damon Fister







More information about the fedora-list mailing list