如何获取cpio(gnu,rhel 4)提取到指定目录?


9

原因是我要整理一个脚本而不是

cd /some/dir
cpio -whatever<somefile
cd -

Answers:


10

GNU cpio中没有任何东西可以允许这样做。这可能会更清洁一些:

(cd /some/dir && cpio -whatever < /some/file)

使用subshel​​l括号将保留脚本当前的工作目录,而使用&&将确保仅在成功将目录更改为目标后才进行cpio提取。


3
somefile有实际居住在/some/dir这里。我只是尝试过,它说找不到文件。因此,您必须使用返回文件所在位置的相对路径或绝对路径。
CMCDragonkai

0

在TCampbell所做的工作中增加了一些内容:

(cp / some / file / some / dir && cd / some / dir && cpio-无论<file && rm -f file)

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.