Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Reason is I want to make a tidy script instead of

cd /some/dir
cpio -whatever<somefile
cd -
share|improve this question
up vote 5 down vote accepted

There is nothing in GNU cpio to allow for this. This might be a little cleaner:

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

Using the subshell parentheses will preserve the scripts current working directory and using && will ensure that the cpio extraction is only done if you successfully change directories to the target.

share|improve this answer
    
Thanks a lot! Exactly what I needed. – Erik I Aug 6 '09 at 17:41
    
The somefile has to actually reside in /some/dir here. I just tried it and it sayd it couldn't find the files. So you either have to use relative paths back to where the files were or absolute paths. – CMCDragonkai Feb 13 at 11:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.