Find Missing Numbers
up vote
2
down vote
favorite
I have a big list of files with names (videos)
I managed to write all file names in a text file. Now I have a text file with a lot of file names (one episode per line)
Now I need something that can read that text file and tell me what episode E
number is missing
S1-E18-(Date)-(Title)-(Random numbers).mp4
Here is an example of a list
S1-E1-20100526-title-of-video-1400316375.mp4
S1-E3-20100517-title-of-video-15457547.mp4
S10-E5-20100421-title-of-video-14467457.mp4
S5-E7-20120912-title-of-video-17467457.mp4
In this case its easy to see that the files S1-E2
and S10-E4
are missing. but if I have a big list then how can I find the missing files. (Leave Season number S1, S2
) just need to check E
means episode number
The largest existing file's number is S50-E2184
and The Smallest existing file's number is S1-E1
windows-7 ubuntu bash filesystems awk
|
show 4 more comments
up vote
2
down vote
favorite
I have a big list of files with names (videos)
I managed to write all file names in a text file. Now I have a text file with a lot of file names (one episode per line)
Now I need something that can read that text file and tell me what episode E
number is missing
S1-E18-(Date)-(Title)-(Random numbers).mp4
Here is an example of a list
S1-E1-20100526-title-of-video-1400316375.mp4
S1-E3-20100517-title-of-video-15457547.mp4
S10-E5-20100421-title-of-video-14467457.mp4
S5-E7-20120912-title-of-video-17467457.mp4
In this case its easy to see that the files S1-E2
and S10-E4
are missing. but if I have a big list then how can I find the missing files. (Leave Season number S1, S2
) just need to check E
means episode number
The largest existing file's number is S50-E2184
and The Smallest existing file's number is S1-E1
windows-7 ubuntu bash filesystems awk
1
What have you tried?
– Eric F
Nov 27 at 14:03
Your example is not very good.
– harrymc
Nov 27 at 14:54
Is the number of episodes for each season fixed? or at least known?
– glenn jackman
Nov 27 at 16:15
@EricF I tried Nothing
– Eli Shain
Nov 28 at 13:04
2
Your English is good enough. I understand that S10-E4 is missing, but what about S10-E1 to E3 and E5 to whatever and we not know the last number. You do not give enough information to understand the full problem.
– harrymc
Nov 28 at 13:44
|
show 4 more comments
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a big list of files with names (videos)
I managed to write all file names in a text file. Now I have a text file with a lot of file names (one episode per line)
Now I need something that can read that text file and tell me what episode E
number is missing
S1-E18-(Date)-(Title)-(Random numbers).mp4
Here is an example of a list
S1-E1-20100526-title-of-video-1400316375.mp4
S1-E3-20100517-title-of-video-15457547.mp4
S10-E5-20100421-title-of-video-14467457.mp4
S5-E7-20120912-title-of-video-17467457.mp4
In this case its easy to see that the files S1-E2
and S10-E4
are missing. but if I have a big list then how can I find the missing files. (Leave Season number S1, S2
) just need to check E
means episode number
The largest existing file's number is S50-E2184
and The Smallest existing file's number is S1-E1
windows-7 ubuntu bash filesystems awk
I have a big list of files with names (videos)
I managed to write all file names in a text file. Now I have a text file with a lot of file names (one episode per line)
Now I need something that can read that text file and tell me what episode E
number is missing
S1-E18-(Date)-(Title)-(Random numbers).mp4
Here is an example of a list
S1-E1-20100526-title-of-video-1400316375.mp4
S1-E3-20100517-title-of-video-15457547.mp4
S10-E5-20100421-title-of-video-14467457.mp4
S5-E7-20120912-title-of-video-17467457.mp4
In this case its easy to see that the files S1-E2
and S10-E4
are missing. but if I have a big list then how can I find the missing files. (Leave Season number S1, S2
) just need to check E
means episode number
The largest existing file's number is S50-E2184
and The Smallest existing file's number is S1-E1
windows-7 ubuntu bash filesystems awk
windows-7 ubuntu bash filesystems awk
asked Nov 27 at 13:42
Eli Shain
111
111
1
What have you tried?
– Eric F
Nov 27 at 14:03
Your example is not very good.
– harrymc
Nov 27 at 14:54
Is the number of episodes for each season fixed? or at least known?
– glenn jackman
Nov 27 at 16:15
@EricF I tried Nothing
– Eli Shain
Nov 28 at 13:04
2
Your English is good enough. I understand that S10-E4 is missing, but what about S10-E1 to E3 and E5 to whatever and we not know the last number. You do not give enough information to understand the full problem.
– harrymc
Nov 28 at 13:44
|
show 4 more comments
1
What have you tried?
– Eric F
Nov 27 at 14:03
Your example is not very good.
– harrymc
Nov 27 at 14:54
Is the number of episodes for each season fixed? or at least known?
– glenn jackman
Nov 27 at 16:15
@EricF I tried Nothing
– Eli Shain
Nov 28 at 13:04
2
Your English is good enough. I understand that S10-E4 is missing, but what about S10-E1 to E3 and E5 to whatever and we not know the last number. You do not give enough information to understand the full problem.
– harrymc
Nov 28 at 13:44
1
1
What have you tried?
– Eric F
Nov 27 at 14:03
What have you tried?
– Eric F
Nov 27 at 14:03
Your example is not very good.
– harrymc
Nov 27 at 14:54
Your example is not very good.
– harrymc
Nov 27 at 14:54
Is the number of episodes for each season fixed? or at least known?
– glenn jackman
Nov 27 at 16:15
Is the number of episodes for each season fixed? or at least known?
– glenn jackman
Nov 27 at 16:15
@EricF I tried Nothing
– Eli Shain
Nov 28 at 13:04
@EricF I tried Nothing
– Eli Shain
Nov 28 at 13:04
2
2
Your English is good enough. I understand that S10-E4 is missing, but what about S10-E1 to E3 and E5 to whatever and we not know the last number. You do not give enough information to understand the full problem.
– harrymc
Nov 28 at 13:44
Your English is good enough. I understand that S10-E4 is missing, but what about S10-E1 to E3 and E5 to whatever and we not know the last number. You do not give enough information to understand the full problem.
– harrymc
Nov 28 at 13:44
|
show 4 more comments
2 Answers
2
active
oldest
votes
up vote
0
down vote
Save all the names in a file with name "file_with_list_of_files" and run below command in a linux/unix terminal[I tried it in mac terminal]:
cat file_with_list_of_files | sed 's/^[A-Z][0-9]*-//g' | grep -v "^E"
-- or --
cat file_with_list_of_files | awk -F- '{print $2}' | grep -v "^E"
This lists all file name does not have a E after first - (hyphen). You may find other better ways to do it as well.
add a comment |
up vote
0
down vote
Prepare a file with all episode signatures. You didn't tell us how many episodes there are in each season but you obviously need to know. This is how you prepare the file:
>all_episodes # just to empty the file which may or may not exist
printf 'S1-E%sn' {1..3} >>all_episodes # 3 episodes in season 1
printf 'S2-E%sn' {1..5} >>all_episodes # 5 episodes in season 2
printf 'S3-E%sn' {1..8} >>all_episodes
# and so on
printf 'S50-E%sn' {1..2184} >>all_episodes
This assumes each season starts with its own episode number one (your question is not clear about it). The file consist of lines in a form
S<n>-E<m>
, e.gS2-E3
.
Create a file of owned episodes in the same form:
cut -d - -f -2 your_current_list >owned_episodes
The command takes
-
as a delimiter and returns line fragments up to the field number 2 from your current list.
Treat
owned_episodes
as patterns and filterall_episodes
to find lines without any pattern:
grep -vxFf owned_episodes all_episodes
Note we use
-x
here; the point isS50-E3
shouldn't matchS50-E31
.-F
is not necessary in your case but in general one should use it while supplying fixed strings. The options are:
-F
Match using fixed strings. Treat each pattern specified as a string instead of a regular expression. [...]
-f pattern_file
Read one or more patterns from the file named by the pathnamepattern_file
. [...]
-v
Select lines not matching any of the specified patterns. [...]
-x
Consider only input lines that use all characters in the line excluding the terminating<newline>
to match an entire fixed string or regular expression to be matching lines.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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',
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/3.0/"u003ecc by-sa 3.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%2fsuperuser.com%2fquestions%2f1378763%2ffind-missing-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Save all the names in a file with name "file_with_list_of_files" and run below command in a linux/unix terminal[I tried it in mac terminal]:
cat file_with_list_of_files | sed 's/^[A-Z][0-9]*-//g' | grep -v "^E"
-- or --
cat file_with_list_of_files | awk -F- '{print $2}' | grep -v "^E"
This lists all file name does not have a E after first - (hyphen). You may find other better ways to do it as well.
add a comment |
up vote
0
down vote
Save all the names in a file with name "file_with_list_of_files" and run below command in a linux/unix terminal[I tried it in mac terminal]:
cat file_with_list_of_files | sed 's/^[A-Z][0-9]*-//g' | grep -v "^E"
-- or --
cat file_with_list_of_files | awk -F- '{print $2}' | grep -v "^E"
This lists all file name does not have a E after first - (hyphen). You may find other better ways to do it as well.
add a comment |
up vote
0
down vote
up vote
0
down vote
Save all the names in a file with name "file_with_list_of_files" and run below command in a linux/unix terminal[I tried it in mac terminal]:
cat file_with_list_of_files | sed 's/^[A-Z][0-9]*-//g' | grep -v "^E"
-- or --
cat file_with_list_of_files | awk -F- '{print $2}' | grep -v "^E"
This lists all file name does not have a E after first - (hyphen). You may find other better ways to do it as well.
Save all the names in a file with name "file_with_list_of_files" and run below command in a linux/unix terminal[I tried it in mac terminal]:
cat file_with_list_of_files | sed 's/^[A-Z][0-9]*-//g' | grep -v "^E"
-- or --
cat file_with_list_of_files | awk -F- '{print $2}' | grep -v "^E"
This lists all file name does not have a E after first - (hyphen). You may find other better ways to do it as well.
answered Nov 30 at 5:34
Robert Ranjan
1011
1011
add a comment |
add a comment |
up vote
0
down vote
Prepare a file with all episode signatures. You didn't tell us how many episodes there are in each season but you obviously need to know. This is how you prepare the file:
>all_episodes # just to empty the file which may or may not exist
printf 'S1-E%sn' {1..3} >>all_episodes # 3 episodes in season 1
printf 'S2-E%sn' {1..5} >>all_episodes # 5 episodes in season 2
printf 'S3-E%sn' {1..8} >>all_episodes
# and so on
printf 'S50-E%sn' {1..2184} >>all_episodes
This assumes each season starts with its own episode number one (your question is not clear about it). The file consist of lines in a form
S<n>-E<m>
, e.gS2-E3
.
Create a file of owned episodes in the same form:
cut -d - -f -2 your_current_list >owned_episodes
The command takes
-
as a delimiter and returns line fragments up to the field number 2 from your current list.
Treat
owned_episodes
as patterns and filterall_episodes
to find lines without any pattern:
grep -vxFf owned_episodes all_episodes
Note we use
-x
here; the point isS50-E3
shouldn't matchS50-E31
.-F
is not necessary in your case but in general one should use it while supplying fixed strings. The options are:
-F
Match using fixed strings. Treat each pattern specified as a string instead of a regular expression. [...]
-f pattern_file
Read one or more patterns from the file named by the pathnamepattern_file
. [...]
-v
Select lines not matching any of the specified patterns. [...]
-x
Consider only input lines that use all characters in the line excluding the terminating<newline>
to match an entire fixed string or regular expression to be matching lines.
add a comment |
up vote
0
down vote
Prepare a file with all episode signatures. You didn't tell us how many episodes there are in each season but you obviously need to know. This is how you prepare the file:
>all_episodes # just to empty the file which may or may not exist
printf 'S1-E%sn' {1..3} >>all_episodes # 3 episodes in season 1
printf 'S2-E%sn' {1..5} >>all_episodes # 5 episodes in season 2
printf 'S3-E%sn' {1..8} >>all_episodes
# and so on
printf 'S50-E%sn' {1..2184} >>all_episodes
This assumes each season starts with its own episode number one (your question is not clear about it). The file consist of lines in a form
S<n>-E<m>
, e.gS2-E3
.
Create a file of owned episodes in the same form:
cut -d - -f -2 your_current_list >owned_episodes
The command takes
-
as a delimiter and returns line fragments up to the field number 2 from your current list.
Treat
owned_episodes
as patterns and filterall_episodes
to find lines without any pattern:
grep -vxFf owned_episodes all_episodes
Note we use
-x
here; the point isS50-E3
shouldn't matchS50-E31
.-F
is not necessary in your case but in general one should use it while supplying fixed strings. The options are:
-F
Match using fixed strings. Treat each pattern specified as a string instead of a regular expression. [...]
-f pattern_file
Read one or more patterns from the file named by the pathnamepattern_file
. [...]
-v
Select lines not matching any of the specified patterns. [...]
-x
Consider only input lines that use all characters in the line excluding the terminating<newline>
to match an entire fixed string or regular expression to be matching lines.
add a comment |
up vote
0
down vote
up vote
0
down vote
Prepare a file with all episode signatures. You didn't tell us how many episodes there are in each season but you obviously need to know. This is how you prepare the file:
>all_episodes # just to empty the file which may or may not exist
printf 'S1-E%sn' {1..3} >>all_episodes # 3 episodes in season 1
printf 'S2-E%sn' {1..5} >>all_episodes # 5 episodes in season 2
printf 'S3-E%sn' {1..8} >>all_episodes
# and so on
printf 'S50-E%sn' {1..2184} >>all_episodes
This assumes each season starts with its own episode number one (your question is not clear about it). The file consist of lines in a form
S<n>-E<m>
, e.gS2-E3
.
Create a file of owned episodes in the same form:
cut -d - -f -2 your_current_list >owned_episodes
The command takes
-
as a delimiter and returns line fragments up to the field number 2 from your current list.
Treat
owned_episodes
as patterns and filterall_episodes
to find lines without any pattern:
grep -vxFf owned_episodes all_episodes
Note we use
-x
here; the point isS50-E3
shouldn't matchS50-E31
.-F
is not necessary in your case but in general one should use it while supplying fixed strings. The options are:
-F
Match using fixed strings. Treat each pattern specified as a string instead of a regular expression. [...]
-f pattern_file
Read one or more patterns from the file named by the pathnamepattern_file
. [...]
-v
Select lines not matching any of the specified patterns. [...]
-x
Consider only input lines that use all characters in the line excluding the terminating<newline>
to match an entire fixed string or regular expression to be matching lines.
Prepare a file with all episode signatures. You didn't tell us how many episodes there are in each season but you obviously need to know. This is how you prepare the file:
>all_episodes # just to empty the file which may or may not exist
printf 'S1-E%sn' {1..3} >>all_episodes # 3 episodes in season 1
printf 'S2-E%sn' {1..5} >>all_episodes # 5 episodes in season 2
printf 'S3-E%sn' {1..8} >>all_episodes
# and so on
printf 'S50-E%sn' {1..2184} >>all_episodes
This assumes each season starts with its own episode number one (your question is not clear about it). The file consist of lines in a form
S<n>-E<m>
, e.gS2-E3
.
Create a file of owned episodes in the same form:
cut -d - -f -2 your_current_list >owned_episodes
The command takes
-
as a delimiter and returns line fragments up to the field number 2 from your current list.
Treat
owned_episodes
as patterns and filterall_episodes
to find lines without any pattern:
grep -vxFf owned_episodes all_episodes
Note we use
-x
here; the point isS50-E3
shouldn't matchS50-E31
.-F
is not necessary in your case but in general one should use it while supplying fixed strings. The options are:
-F
Match using fixed strings. Treat each pattern specified as a string instead of a regular expression. [...]
-f pattern_file
Read one or more patterns from the file named by the pathnamepattern_file
. [...]
-v
Select lines not matching any of the specified patterns. [...]
-x
Consider only input lines that use all characters in the line excluding the terminating<newline>
to match an entire fixed string or regular expression to be matching lines.
answered Dec 4 at 9:01
Kamil Maciorowski
23.3k155072
23.3k155072
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f1378763%2ffind-missing-numbers%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
1
What have you tried?
– Eric F
Nov 27 at 14:03
Your example is not very good.
– harrymc
Nov 27 at 14:54
Is the number of episodes for each season fixed? or at least known?
– glenn jackman
Nov 27 at 16:15
@EricF I tried Nothing
– Eli Shain
Nov 28 at 13:04
2
Your English is good enough. I understand that S10-E4 is missing, but what about S10-E1 to E3 and E5 to whatever and we not know the last number. You do not give enough information to understand the full problem.
– harrymc
Nov 28 at 13:44