I have a shell script which copies a few files to the current directory, compresses them, and streams the compressed file to stdout.
On the client side I use plink to execute the script and stream stdin to a file.
This almost works.
It seems that the cp command outputs the file name being copied when its executed from inside the script. If I execute ‘cp /path/to/file1 .‘ in the shell it does it quietly; if I execute it in a script it outputs ‘file1’.
How do I prevent this? I’ve tried piping the output of the cp command to /dev/null and to a dummy text file but with no luck.
thanks for any help.
the script
#!/bin/bash cp /path/to/file1 . cp /path/to/file2 . cp /path/to/file3 . tar -cvzf package.tgz file1 file2 file3 cat package.tgz
the output
file1 file2 file3 <<binary data>>
It’s not cp, it’s tar. You are passing it -v, which makes it print the names of the files.