4

I am needing to run:

rpm2cpio mypackage.rpm | cpio -idmv

However, I need the output to be in a different directory. Is there a more elegant solution than doing

mv <output> <to/other/directory>

after performing the extraction?

Jens Petersen
  • 189
  • 2
  • 11

2 Answers2

5

Since cpio is just reading from standard input, you can change to another directory before running it:

rpm2cpio mypackage.rpm | (cd /to/other/directory; cpio -idmv)

This is a general solution that will work with a variety of tools. The cpio command has a --directory (-D) option that will accomplish the same thing:

rpm2cpio mypackage.rpm | cpio -D /to/other/directory -idmv
larsks
  • 277,717
  • 41
  • 399
  • 399
1

Or even easier:

rpmdev-extract -C DIR mypackage.rpm

msuchy
  • 5,162
  • 1
  • 14
  • 26