You are not logged in.
I need some help. I just can't figure out the syntax to do this. If I have a directory which contains both files and directories, how can I use install to copy everything to another directory?
The closest I've come is this:
install -Dm644 $srcdir/foo/bar/* -t $pkgdir/foo/bar
which copies the files but it omits all directories in $srcdir/foo/bar. I've tried using the "-d" option but I'm not sure what that actually does. Can this be done with a single "install" command? It would be trivial to do this using other commands but that feels ungainly.
Thanks for any suggestions.
*edit*
Here's what I'm using as a (temporary) solution:
function _install_dir {
_src_dir=$1
_dest_dir=$2
_n=${#_src_dir}
for _file in $(find $_src_dir -type f)
do
_dest_file=${_dest_dir}${_file:$_n}
install -Dm644 $_file $_dest_file
done
}
Last edited by Xyne (2009-04-11 01:02:13)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I've tried using the "-d" option but I'm not sure what that actually does. Can this be done with a single "install" command?
There isn't really a way to do it with 1 command because 'install' isn't recursive.
'install -d' is basically just a drop-in for mkdir. This will install a directory /path/to/dir with 755 perms:
install -dm755 /path/to/dir
To copy all the files in /home/xyne/foo/x to /home/xyne/bar/x, and also copy the files in /home/xyne/foo to /home/xyne/bar (and /home/xyne/bar/x doesn't exist yet):
install -dm755 /home/xyne/bar/x
install -m644 /home/xyne/foo/x/* /home/xyne/bar/x
install -m644 /home/xyne/foo/* /home/xyne/bar
Last edited by tdy (2009-04-11 03:07:55)
Offline
Thanks for the reply, tdy.
I'll keep using the function then as I don't want to have to add specific lines for the entire directory tree.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline