Thursday, November 10, 2011

Solaris: copy or moving file using cpio

Why is cpio better than tar? A number of reasons.
  1. cpio preserves hard links, which is important if you're using it for backups.
  2. cpio doesn't have that annoying filename length limitation. Sure, gnutar has a "hack" that allows you to use longer filenames (it creates a temporary file in which it stores the real name), but it's inherently not portable to non-gnu tar's.
  3. By default, cpio preserves timestamps
  4. When scripting, it has much better control over which files are and are not copied, since you must explicitly list the files you want copied. For example, which of the following is easier to read and understand? 

root@server # pwd
/ftp/data/pdu-msa/EDA-SLS
root@server #


mkdir /opt/openwin
cd /usr/openwin
find . | cpio -pdumv /opt/openwin
find /usr/openwin | cpio -pdumv /opt/openwin


cd /ftp/data/pdu-msa/EDA-SLS

find . -depth -print | cpio -pudmv /ftp/data2/pdu-msa/EDA-SLS

*** using -print will get you defunct when you exit the shell, use find . only

No comments:

UNIX: How to print column nicely using printf

[user@hostfwnms1-oam tmp]# cat b.sh printf "%-26s %-19s %-8s %-8s %-s %-s\n" HOSTNAME IP PING SNMPWALK 0-ok 1-fail for i in `cat n...