#!/bin/sh ofile="/bin/ping" c_opts="--xattrs -Scpf -" x_opts="--xattrs -Sxpf -" [ "$(id -u)" != "0" ] && { echo "must be root to preserv xattrs"; exit 1; } echo "$ ls -l $ofile" ls -l "$ofile" echo "$ attr -l $ofile" attr -l "$ofile" tmpd=$(mktemp -d) echo "$ tar -C / $c_opts "${ofile#/}" | tar -C "\$tmpd" $x_opts" tar -C / $c_opts "${ofile#/}" | tar -C "$tmpd" $x_opts rsync -aXHAS "$ofile" "$tmpd/${ofile##*/}_rsync" echo "$ ( cd \$tmpd && attr -l ${ofile#/} )" ( cd "$tmpd" && attr -l "${ofile#/}" ) echo "$ ( cd \$tmpd && attr -l ${ofile##*/}_rsync )" ( cd "$tmpd" && attr -l "${ofile##*/}_rsync" ) rm -Rf "$tmpd"