[NCLUG] tar

Aaron D. Johnson adj at fnord.greeley.co.us
Mon Oct 8 09:45:52 MDT 2012

Kerry Miller writes:
> I created a shell script:
> !#/bin/sh
> #
> #File: BK-Kerrym2Documents.sh
> #
> cd /home/kerrym2/Documents
> #
> tar --recursion -czvpf /mnt/UserBackup/BK-Kerrym2Documents.tar.gz ./
> #
> echo
> echo BKDocuments *** Done ***
> #
> cd /root
> When I run this shell script I get the activity list in my terminal
> window but I don't the terminating echos I have tried to display I
> get a list of files that are in the archive.  I have done a man tar
> and don't see any distinction between seeing the list of files and
> not seeing the list of files.  Is there something I might be missing
> about tar?

That first line should probably read 


(Transpose the # and the !.)  After tar's list of files, you're
probably seeing a "BKDocuments" followed by a list of files in /root,
followed by "Done", followed by a list of files in /root, all on one
(probably wrapped) line.

I don't think you're missing something about tar, instead you're
probably missing something about how wildcard expansion works.

Try the following:

    cd /root
    echo Done
    echo ***
    echo '***'
    echo BKDocuments ***
    echo BKDocuments *** Done ***
    echo BKDocuments '***' Done '***'

You should be able to see what you need to change in your script from

- Aaron

More information about the NCLUG mailing list