Sunday, December 20, 2009

cpio - copy files to and from archives

 

cpio is a tool to copy files from one place to another, and to create archives, (like tar), or extract files from an archive file.

The good thing is that cpio takes its input from other commands like ls, or find

So you can archive all .mp3 in your home directory by entering this command:

ls *.mp3 | cpio -o --format=tar -F mymp3.tar

Or if you want to include subfolders

find $HOME -name "*.mp3" | cpio -o --format=tar -F mymp3.tar

You can list the contents of a .tar file.

cpio -it -F mymp3.tar

And extract them:

cpio -i -F mymp3.tar

Run

info cpio for a complete tutorial.

 
Things You Should Know About Linux !!!