cp command: except or ignore option?
Hi there,
I was looking in the man page of the basic "cp" command and I didn't find any command allowing the user to copy a bunch of file EXCEPT some of them. Kinda like when u're doing "ls --ignore '<this folder/file>' ".... somebody help me!!! A long way to go... before being a Guru. |
Since cp doesnt have such a function, why dont just use ls's?
$ cp `ls --ignore '<this folder/file>'` <dest> |
aiight, make sense... I didn't know we could copy a command output
Thx |
It's not working for me :(
For this command: cp -r `ls /original/path/full/of/folders/` new/folder/for/backup/ I get this: cp: cannot stat `<files2copy>': No such file or directory cp: cannot stat `<files2copy>': No such file or directory cp: cannot stat `<files2copy>': No such file or directory cp: cannot stat `<files2copy>': No such file or directory cp: cannot stat `<files2copy>': No such file or directory cp: cannot stat `<files2copy>': No such file or directory But all this files are present in the system, it's like cp couldn't handle ls output... I don't get it... :confused: |
Try it this way:
cp -r $(ls /original/path/full/of/folders/) new/folder/for/backup/ |
nah, it doesn't work in either case. :scratch:
|
cpio is good at copying directories. From the Advanced Bash Scripting Guide I found and modified this:
find /original/path/full/of/folders/ | cpio -admvp new/folder/for/backup/ NOTE: Use ! -name [IGNORE] to ignore files matching IGNORE. For example: find /original/path/full/of/folders/ ! -name "*.bak" | cpio -admvp new/folder/for/backup/ Will copy all files except .bak files |
:D Damn that's sleek!!! it works!!! Thanx a lot!!!
The sad thing is that I can't find this kind of stuff by myself 'yet' :cry: ...but one day, :jawa: |
The important thing is that you do at least try.
The Advanced Bash-Scripting Guide is an invaluable guide. I look through it on a regular basis. Download it to your computer and make a Bookmark for it. |
Nice! Thx for that! :study:
|
All times are GMT -5. The time now is 01:37 AM. |