use a wildcard, but be careful to protect it from the shell:
rpm2cpio rpm_name | cpio -ivd './a/b/c/*'
Not directly, but
cpio does have a
-r/--rename switch. There are unfortunately two problems with that: it asks about each file and it takes input from
/dev/tty directly. Which means it's not easy to automate it. You could use the
expect program if you really wanted to do it. Warning: not for the faint of heart ;) Note that it doesn't handle files with quotes (or possibly spaces) properly. It expects the name of the rpm file, a pattern for the files to extract and a
sed command to transform each file. Usage example:
cpio.sh rpm_name './a/b/c/*' 's#^./a/b/#foo/#'
Theoretically the script could be piped into
expect but that's left as an excercise for the reader.
echo "spawn sh -c \"rpm2cpio \\\"$RPM\\\" | cpio -ird '$FILES'\"" > "$SCRIPT"
rpm2cpio "$RPM" | cpio -it "$FILES" 2>/dev/null | sed "$TRANSFORM" | while read line
echo "send \"$line\\r\"" >> "$SCRIPT"
echo "wait" >> "$SCRIPT"
rm -f "$SCRIPT"