I'm trying to copy files and subfolders from A folder without the A itself. For instance, A folder contains next:
| file1.txt
| file2.txt
| subfolder1
Executing next command gives me wrong result:
sudo cp -r /home/username/A/ /usr/lib/B/
The result is
/usr/lib/B/A/...copied files...
instead of..
/usr/lib/B/...copied files...
How can I reach the expected one without origin-folder
A/*does make sense but there are situations in which it doesn't work. – Hauke Laging Jan 25 '15 at 16:01shoptisbashspecific. Withzsh, use*(D). withksh93,FIGNORE='@(.|..)'.cp -tis GNU specific. Thefindone will not work properly as it will copy bothA/and its content (including subdirs) several times. – Stéphane Chazelas Jan 25 '15 at 16:37-maxdepth 1(-mindepthand-maxdepthbeing GNU extensions now also supported by a few others. Portablyfind .../. ! -name . -prune -exec ....) – Stéphane Chazelas Jan 25 '15 at 16:42find .../.causes an error here. – Hauke Laging Jan 25 '15 at 16:47...was an ellipsis for/home/username/A. It shouldn't give you a syntax error though, just a file not found one (unless you have a directory called...). – Stéphane Chazelas Jan 25 '15 at 16:49.after/mandatory ? seems to work without it – Veverke Nov 10 '20 at 09:36Bdoesn't exist). But run both commands twice and compare the results. – Hauke Laging Nov 10 '20 at 13:35cp -a /home/username/A/. /usr/lib/B/(i.e., instead of-ruse-a) to preserve symlinks and file attributes. – Abdull Jan 10 '24 at 21:07