Running Tar from a Shell Script.
Dale Farnsworth
dale at farnsworth.org
Tue Jul 27 14:03:42 MST 2010
> If I run "tar -czf /backups/my-backup-$(date +%Y%m%d).tgz /work/dev/"
> from the command line, less the quotes, it runs just fine with the
> exception of the one message that says "tar: Removing leading `/' from
> member names", which I am not sure exactly what that means.
If filenames are stored in a tarball with leading slashes
(as in the first / in /work/dev/foo), then, by default, those files
can only be restored at the same absolute path. Tar is letting
you know that it is storing filenames without the leading slash,
like work/dev/foo.
> If I create a shell script with two lines, as follows:
Bash expects lines to be terminated with the linefeed (newline, \n)
character. It looks like your shell script has lines ending in
a CRLF (\r\n).
> #!/bin/bash
>
> /bin/tar -czf /backups/my-backup-$(date +%Y%m%d).tgz /work/dev/
>
>
> I get the following output:
>
> : command not founde 2:
It's reporting that it can't find a command whose name is a single
carriage return (\r).
> /bin/tar: Removing leading `/' from member names
> /bin/tar: /work/dev/\r: Cannot stat: No such file or directory
Tar is telling you that it can't find /work/dev/\r.
> /bin/tar: Error exit delayed from previous errors
> : command not founde 4:
>
> I am not sure why these errors. Any help is much appreciated.
You need to remove the \r characters at the end of your lines.
Most likely your editor has a command or mode to do that.
-Dale
More information about the PLUG-discuss
mailing list