I want to make /lib/modules compress copy and move to /opt directory. using cpio

I try this

 cpio /lib/modules > directory.cpio | mv directory.cpio /opt
  • 1
    any particular reason you want to use age old cpio ? (besides cpio is not a compress tool)
    – Archemar
    Jan 4 '19 at 13:51
  • cd /lib/modules | ls | cpio -ov > directory.cpio like this
    – Top Music
    Jan 4 '19 at 13:56
  • why not cd /lib/modules ; ls | cpio -ov > /opt/directory.cpio then ? (note the ; after cd)
    – Archemar
    Jan 4 '19 at 13:58
  • this ? find /lib/modules > iraklsssi.cpio | cp iraklsssi.cpio /opt
    – Top Music
    Jan 4 '19 at 14:06
  • ; is used to separate commands, while |is used to pipe previous command's output to next's input, it can also separate command, but if they produce not output, execution will halt.
    – Archemar
    Jan 4 '19 at 14:10

Create a compressed cpio archive using file to locate the input files

Backup up some files:

find *.txt -depth|cpio -oc|gzip -q -9 -c >/tmp/a.gz

List the contents:

gzip -d a.gz -c|cpio -it

Extract the contents:

gzip -d /tmp/a.gz -c|cpio -imVd

I grew up creating backups and software distributions on 8" mag tapes to be sent by courier around the world. I still have great love for cpio and find, but my memory is significantly jaded. I'd have used compress/uncompress, but I did not find these in the RHEL7 that I use in the office. Zcat works just as well, because these are pretty much the same thing nowadays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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