cp: cannot stat './1_true/*': No such file or directory, when find directories and copy filesWhy do I see a difference in file count between Nautilus and find?Recursively apply the msgfmt command to all .po files in directory with find -execHow to copy files from multiple directories, adding the parent folder's name to the filename?cp command for backupHow to move files under multi-directories into same directory?Bash - Copy all .jar files to current directory from subfolders
Fast cooking bone broth
How to Taper a coil?
eDreamer's price lower than the airline itself
Cherem ceremony: candles?
What made the Tusken Raiders unable / unwilling to shoot down Luke's Landspeeder?
Where to start with a child learning chess?
How cold does it have to be to freeze a waterfall
Can a Druid Goblin use Nimble Escape while Wild Shaped into a non-agile animal form?
Do attacks that give the Grappled condition work against creatures more than 1 size larger?
ADC protection for PIC microchip
Did Roger Rabbit exist prior to the film "Who Framed Roger Rabbit?"
Large (70) stellar mass black hole disrupts astrophysics?
Why is the Marie Curie Individual Fellowship only for 'experienced researchers'?
Should a soda bottle be stored horizontally or vertically?
Can a VASIMR Plasma engine be used for vertical takeoff?
Why are these wires sticking out of battery terminal?
Is a I sus2 chord the same as a Vsus4 chord?
How true are Trump’s claims about NATO spending?
What are pros and cons around banning castling?
Where is the Windows license key on Windows 10?
Keep password in macro
Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error
What are examples of (collections of) papers which "close" a field?
Looking for a restaurant in Vienna with a name similar to "An die 2 Linsen" that served huge Schnitzel
cp: cannot stat './1_true/*': No such file or directory, when find directories and copy files
Why do I see a difference in file count between Nautilus and find?Recursively apply the msgfmt command to all .po files in directory with find -execHow to copy files from multiple directories, adding the parent folder's name to the filename?cp command for backupHow to move files under multi-directories into same directory?Bash - Copy all .jar files to current directory from subfolders
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
i have many directories like this:
$ ls
1_true 1_false 2_true 2_false 3_true 3_false ...
i want to copy files in "*_true/" to other directory.
when i run command like below
find . -name "*_true" -exec cp ""/* "../out_true" ";"
this give me error messages like this:
cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...
how to fix this error? thanks!
NOTE: my 'true' directories count is more than 100000
bash find
add a comment
|
i have many directories like this:
$ ls
1_true 1_false 2_true 2_false 3_true 3_false ...
i want to copy files in "*_true/" to other directory.
when i run command like below
find . -name "*_true" -exec cp ""/* "../out_true" ";"
this give me error messages like this:
cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...
how to fix this error? thanks!
NOTE: my 'true' directories count is more than 100000
bash find
Try... -exec echo cp ...
to see what's happening
– Tavian Barnes
Oct 17 at 15:32
add a comment
|
i have many directories like this:
$ ls
1_true 1_false 2_true 2_false 3_true 3_false ...
i want to copy files in "*_true/" to other directory.
when i run command like below
find . -name "*_true" -exec cp ""/* "../out_true" ";"
this give me error messages like this:
cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...
how to fix this error? thanks!
NOTE: my 'true' directories count is more than 100000
bash find
i have many directories like this:
$ ls
1_true 1_false 2_true 2_false 3_true 3_false ...
i want to copy files in "*_true/" to other directory.
when i run command like below
find . -name "*_true" -exec cp ""/* "../out_true" ";"
this give me error messages like this:
cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...
how to fix this error? thanks!
NOTE: my 'true' directories count is more than 100000
bash find
bash find
edited Oct 17 at 8:19
sailfish009
asked Oct 17 at 5:51
sailfish009sailfish009
1275 bronze badges
1275 bronze badges
Try... -exec echo cp ...
to see what's happening
– Tavian Barnes
Oct 17 at 15:32
add a comment
|
Try... -exec echo cp ...
to see what's happening
– Tavian Barnes
Oct 17 at 15:32
Try
... -exec echo cp ...
to see what's happening– Tavian Barnes
Oct 17 at 15:32
Try
... -exec echo cp ...
to see what's happening– Tavian Barnes
Oct 17 at 15:32
add a comment
|
3 Answers
3
active
oldest
votes
You can simplify it quite a bit
cp ?_true/* ../out_true/
will work as well.
This will, however, not work when you have a very large number of files.
1
your code will work if my true directories count is less than 10. but my directories is more than 100000.
– sailfish009
Oct 17 at 7:00
What defines the maximum size for a command single argument
– bac0n
Oct 17 at 15:44
add a comment
|
found answer, using xargs
instead of -exec
find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' --
add a comment
|
You can limit find to descend not more than n levels with -maxdepth
. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.
find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;
or
for i in *_true; do
rsync -a "$i/" ../out_true
done
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1181540%2fcp-cannot-stat-1-true-no-such-file-or-directory-when-find-directories-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can simplify it quite a bit
cp ?_true/* ../out_true/
will work as well.
This will, however, not work when you have a very large number of files.
1
your code will work if my true directories count is less than 10. but my directories is more than 100000.
– sailfish009
Oct 17 at 7:00
What defines the maximum size for a command single argument
– bac0n
Oct 17 at 15:44
add a comment
|
You can simplify it quite a bit
cp ?_true/* ../out_true/
will work as well.
This will, however, not work when you have a very large number of files.
1
your code will work if my true directories count is less than 10. but my directories is more than 100000.
– sailfish009
Oct 17 at 7:00
What defines the maximum size for a command single argument
– bac0n
Oct 17 at 15:44
add a comment
|
You can simplify it quite a bit
cp ?_true/* ../out_true/
will work as well.
This will, however, not work when you have a very large number of files.
You can simplify it quite a bit
cp ?_true/* ../out_true/
will work as well.
This will, however, not work when you have a very large number of files.
edited Oct 17 at 7:47
answered Oct 17 at 6:46
vidarlovidarlo
14.8k6 gold badges35 silver badges61 bronze badges
14.8k6 gold badges35 silver badges61 bronze badges
1
your code will work if my true directories count is less than 10. but my directories is more than 100000.
– sailfish009
Oct 17 at 7:00
What defines the maximum size for a command single argument
– bac0n
Oct 17 at 15:44
add a comment
|
1
your code will work if my true directories count is less than 10. but my directories is more than 100000.
– sailfish009
Oct 17 at 7:00
What defines the maximum size for a command single argument
– bac0n
Oct 17 at 15:44
1
1
your code will work if my true directories count is less than 10. but my directories is more than 100000.
– sailfish009
Oct 17 at 7:00
your code will work if my true directories count is less than 10. but my directories is more than 100000.
– sailfish009
Oct 17 at 7:00
What defines the maximum size for a command single argument
– bac0n
Oct 17 at 15:44
What defines the maximum size for a command single argument
– bac0n
Oct 17 at 15:44
add a comment
|
found answer, using xargs
instead of -exec
find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' --
add a comment
|
found answer, using xargs
instead of -exec
find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' --
add a comment
|
found answer, using xargs
instead of -exec
find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' --
found answer, using xargs
instead of -exec
find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' --
answered Oct 17 at 6:21
sailfish009sailfish009
1275 bronze badges
1275 bronze badges
add a comment
|
add a comment
|
You can limit find to descend not more than n levels with -maxdepth
. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.
find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;
or
for i in *_true; do
rsync -a "$i/" ../out_true
done
add a comment
|
You can limit find to descend not more than n levels with -maxdepth
. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.
find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;
or
for i in *_true; do
rsync -a "$i/" ../out_true
done
add a comment
|
You can limit find to descend not more than n levels with -maxdepth
. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.
find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;
or
for i in *_true; do
rsync -a "$i/" ../out_true
done
You can limit find to descend not more than n levels with -maxdepth
. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.
find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;
or
for i in *_true; do
rsync -a "$i/" ../out_true
done
edited Oct 17 at 12:42
answered Oct 17 at 8:09
bac0nbac0n
1,1151 silver badge13 bronze badges
1,1151 silver badge13 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1181540%2fcp-cannot-stat-1-true-no-such-file-or-directory-when-find-directories-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try
... -exec echo cp ...
to see what's happening– Tavian Barnes
Oct 17 at 15:32