25

I recently found out about the existence of cpio and how it can be used, among many other things, to extract individual files from an rpm in conjunction with the rpm2cpio tool, like this:

rpm2cpio mypackage.rpm | cpio -idmv ./path/to/individual/file/inside/the/rpm/filename.txt

The problem is that this command will create the directory that matches the file's location inside the rpm, i.e., it will create the directory /path/to/individual/file/inside/the/rpm/ inside the current directory before actually extracting the file.

Is there any way to extract the file to the current directory without creating the whole directory structure?

Thanks in advance!!

1

1 Answer 1

35

You can use --to-stdout for cpio. E.g.:

# rpm2cpio id3lib-3.8.3-28.fc18.x86_64.rpm | cpio -iv --to-stdout ./usr/share/doc/id3lib-3.8.3/README > /tmp/README
./usr/share/doc/id3lib-3.8.3/README
2173 blocks
# 
1
  • this works allright, but please not that the file endings (and maybe other whitespace) might differ with the original file
    – Chris Maes
    Commented Jan 23, 2018 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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