开发者

tarring a file with shell not working [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 12 years ago.

Improve this question

I'm trying to tar a two files into one, so I have this:

tar -zcvfW "${DATADIR}daily_data_files/LeveL_EOD_VOL_${1}.tar.gz" -C "${DATADIR}temp/LeveL_EOD_VOL_*_${1}.csv" >> "${DATADIR}temp/email.log"

However, I'm getting these errors:

tar: Removing leading '/' from member names
tar: /var/www/vhosts/levelats/data/daily_data_files/LeveL_EOD_VOL_20110121.tar.gz: Cannot stat: No such file or direct开发者_C百科ory
tar: LeveL_EOD_VOL_*_20110121.csv: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors

I'm not sure why the tar isn't getting created, is it because it can't find the two Level_EOD files? Is the wildcard(*) wrong?


I think what is happening is that the -C option is trying to change directory into the first directory expanded by your glob pattern; I think you want:

tar -zcvfW "${DATADIR}daily_data_files/LeveL_EOD_VOL_${1}.tar.gz" -C "${DATADIR}temp/" "LeveL_EOD_VOL_\*_${1}.csv" >> "${DATADIR}temp/email.log"

Note that I split the -C option from the list of CSV files that comes after it.


The order of the option flags is significant (at least the f needs to precede the filename). Try changing from -zcvfW to -zcvWf.

Also -C takes a directory as an argument.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜