Looking for missing files in a directory of files via wildcard inputs
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I currently have a directory with 100 files of 4 types, for a total of 400 files. I would like to find which ones are missing. My current script is:
for((i=1; i<=100; i++)); do name="File_Type_1_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_2_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_3_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_4_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
which is annoying to have to run 4 times. Is there a way to run everything at once? The
bash wildcards
add a comment |Â
up vote
0
down vote
favorite
I currently have a directory with 100 files of 4 types, for a total of 400 files. I would like to find which ones are missing. My current script is:
for((i=1; i<=100; i++)); do name="File_Type_1_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_2_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_3_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_4_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
which is annoying to have to run 4 times. Is there a way to run everything at once? The
bash wildcards
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I currently have a directory with 100 files of 4 types, for a total of 400 files. I would like to find which ones are missing. My current script is:
for((i=1; i<=100; i++)); do name="File_Type_1_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_2_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_3_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_4_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
which is annoying to have to run 4 times. Is there a way to run everything at once? The
bash wildcards
I currently have a directory with 100 files of 4 types, for a total of 400 files. I would like to find which ones are missing. My current script is:
for((i=1; i<=100; i++)); do name="File_Type_1_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_2_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_3_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
for((i=1; i<=100; i++)); do name="File_Type_4_$i.RData";
[[ ! -e "$name" ]] && echo "missing $name"; done
which is annoying to have to run 4 times. Is there a way to run everything at once? The
bash wildcards
bash wildcards
asked 4 mins ago
user321627
1233
1233
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
ls -l File_type_1..4_1..100.RData > /dev/null
This command uses brace expansion to generate all 400 filenames, then asks ls
to list them, only we immediately redirect the output to /dev/null, dropping it. ls
will complain about the missing files to stderr; for example:
ls: cannot access 'File_type_1_99.RData': No such file or directory
ls: cannot access 'File_type_3_42.RData': No such file or directory
Therein lie the missing files!
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
ls -l File_type_1..4_1..100.RData > /dev/null
This command uses brace expansion to generate all 400 filenames, then asks ls
to list them, only we immediately redirect the output to /dev/null, dropping it. ls
will complain about the missing files to stderr; for example:
ls: cannot access 'File_type_1_99.RData': No such file or directory
ls: cannot access 'File_type_3_42.RData': No such file or directory
Therein lie the missing files!
add a comment |Â
up vote
0
down vote
ls -l File_type_1..4_1..100.RData > /dev/null
This command uses brace expansion to generate all 400 filenames, then asks ls
to list them, only we immediately redirect the output to /dev/null, dropping it. ls
will complain about the missing files to stderr; for example:
ls: cannot access 'File_type_1_99.RData': No such file or directory
ls: cannot access 'File_type_3_42.RData': No such file or directory
Therein lie the missing files!
add a comment |Â
up vote
0
down vote
up vote
0
down vote
ls -l File_type_1..4_1..100.RData > /dev/null
This command uses brace expansion to generate all 400 filenames, then asks ls
to list them, only we immediately redirect the output to /dev/null, dropping it. ls
will complain about the missing files to stderr; for example:
ls: cannot access 'File_type_1_99.RData': No such file or directory
ls: cannot access 'File_type_3_42.RData': No such file or directory
Therein lie the missing files!
ls -l File_type_1..4_1..100.RData > /dev/null
This command uses brace expansion to generate all 400 filenames, then asks ls
to list them, only we immediately redirect the output to /dev/null, dropping it. ls
will complain about the missing files to stderr; for example:
ls: cannot access 'File_type_1_99.RData': No such file or directory
ls: cannot access 'File_type_3_42.RData': No such file or directory
Therein lie the missing files!
answered 17 secs ago
Jeff Schaller
35.2k952115
35.2k952115
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f479506%2flooking-for-missing-files-in-a-directory-of-files-via-wildcard-inputs%23new-answer', 'question_page');
);
Post as a guest
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
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
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