Excluding a list of files from tar with spaces in filenames

Excluding a list of files from tar with spaces in filenames

Dotan Cohen dotancohen at gmail.com
Fri Feb 5 15:24:10 IST 2010


> OK, fair enough, but why do you need the 'dd' at the end?:
>

Because I know nothing about shell scripting and I am learning by
google, trial and error.


> tar -zcvf - --exclude-from $EXCLUDES * 2>STDERR | openssl des3 -salt
> -k $1 > $(hostname)-$(date +%Y%m%d).tbz
>
> should output tar's stderr to STDERR and tar's output will be piped to openssl.

I am still not clear about STDERR. I need the output (the output from
the v flag) in a variable.


> Notice how I moved the "*" to the end of tar's command line, btw.
>

What is the advantage of this?


> If you want to redirect the entire command line output to STDERR use
> parenthesis around it:
>
> (tar -zcvf - --exclude-from $EXCLUDES * | openssl des3 -salt -k $1 >
> $(hostname)-$(date +%Y%m%d).tbz) 2>STDERR
>

How about if I need it in the variable COPIED instead of STDERR?


>>> Another error I noticed is that you provide the --exclude-from after
>>> the '*' which expands to input file names.
>>> Then you can redirect stderr to stdout in order to fetch it using back-ticks:
>>>
>>> tar_stdout_and_stderr=`tar -zcvf out.tar --exclude-from $EXCLUDES * 2>&1`
>>>
>>
>> This is something that I cannot do because of the pipe to encryption.
>
> I don't see the connection between piping vs. specifying an output
> file and putting the list of files to include in the tar at the end of
> the line.
>

I don't either, really, but it looked like a limitation that I was
coming up against. Maybe there is a way to do what I need and I don't
know it.

Thanks.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

Please CC me if you want to be sure that I read your message. I do not
read all list mail.



More information about the Linux-il mailing list