|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
This is driving me nuts i am trying to use the following:
find . -exec grep -l "[0-9]\+\." '{}' \; to find all files that have a number before a "." It matches both somefile_ 1.mp3 AND somefile_ .mp3. Why is this and can you suggest a better pattern? I a=only want to match the first result above. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On May 2, 4:22pm, Ryan <ryan.fairch...@gmail.com> wrote:
> This is driving me nuts i am trying to use the following: > > find . -exec grep -l "[0-9]\+\." '{}' \; > > to find all files that have a number before a "." > > It matches both somefile_ 1.mp3 AND somefile_ .mp3. > > Why is this and can you suggest a better pattern? I a=only want to > match the first result above. find <path> -name '*[0-9]\.*] your example finds everything and runs grep on it????? |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On May 2, 4:41pm, OldSchool <scott.my...@macys.com> wrote:
> On May 2, 4:22pm, Ryan <ryan.fairch...@gmail.com> wrote: > > > This is driving me nuts i am trying to use the following: > > > find . -exec grep -l "[0-9]\+\." '{}' \; > > > to find all files that have a number before a "." > > > It matches both somefile_ 1.mp3 AND somefile_ .mp3. > > > Why is this and can you suggest a better pattern? I a=only want to > > match the first result above. > > find <path> -name '*[0-9]\.*] > > your example finds everything and runs grep on it????? This is within a certain directory |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 5/2/2008 3:47 PM, Ryan wrote: > On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: > >>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: >> >> >>>This is driving me nuts i am trying to use the following: >> >>>find . -exec grep -l "[0-9]\+\." '{}' \; >> >>> to find all files that have a number before a "." >> >>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. >> >>>Why is this and can you suggest a better pattern? I a=only want to >>>match the first result above. >> >>find <path> -name '*[0-9]\.*] >> >>your example finds everything and runs grep on it????? > > > This is within a certain directory Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to do with matching sub-directories and/or your other requirements. Ed. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On May 2, 4:56pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
> On 5/2/2008 3:47 PM, Ryan wrote: > > > > > On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: > > >>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > >>>This is driving me nuts i am trying to use the following: > > >>>find . -exec grep -l "[0-9]\+\." '{}' \; > > >>> to find all files that have a number before a "." > > >>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. > > >>>Why is this and can you suggest a better pattern? I a=only want to > >>>match the first result above. > > >>find <path> -name '*[0-9]\.*] > > >>your example finds everything and runs grep on it????? > > > This is within a certain directory > > Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to > do with matching sub-directories and/or your other requirements. > > Ed. Maybe I should explain the ultimate outcome here. I have a bunch of duplicate mp3 files that all follow "song 1.mp3", originals are of the forms "song.mp3". I simply want to find them and delete them. Am I in the right direction here. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 5/2/2008 4:01 PM, Ryan wrote: > On May 2, 4:56 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > >>On 5/2/2008 3:47 PM, Ryan wrote: >> >> >> >> >>>On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: >> >>>>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: >>> >>>>>This is driving me nuts i am trying to use the following: >>>> >>>>>find . -exec grep -l "[0-9]\+\." '{}' \; >>>> >>>>>to find all files that have a number before a "." >>>> >>>>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. >>>> >>>>>Why is this and can you suggest a better pattern? I a=only want to >>>>>match the first result above. >>>> >>>>find <path> -name '*[0-9]\.*] >>> >>>>your example finds everything and runs grep on it????? >>> >>>This is within a certain directory >> >>Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to >>do with matching sub-directories and/or your other requirements. >> >> Ed. > > > Maybe I should explain the ultimate outcome here. I have a bunch of > duplicate mp3 files that all follow "song 1.mp3", originals are of the > forms "song.mp3". I simply want to find them and delete them. Am I > in the right direction here. In the original, can "song" end in a number? If so, can "song" contain a space before the number? Do the duplicate files all end in "<space><number[s]>.mp3"? Ed. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On May 2, 5:05pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
> On 5/2/2008 4:01 PM, Ryan wrote: > > > > > On May 2, 4:56 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > > >>On 5/2/2008 3:47 PM, Ryan wrote: > > >>>On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: > > >>>>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > >>>>>This is driving me nuts i am trying to use the following: > > >>>>>find . -exec grep -l "[0-9]\+\." '{}' \; > > >>>>>to find all files that have a number before a "." > > >>>>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. > > >>>>>Why is this and can you suggest a better pattern? I a=only want to > >>>>>match the first result above. > > >>>>find <path> -name '*[0-9]\.*] > > >>>>your example finds everything and runs grep on it????? > > >>>This is within a certain directory > > >>Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to > >>do with matching sub-directories and/or your other requirements. > > >> Ed. > > > Maybe I should explain the ultimate outcome here. I have a bunch of > > duplicate mp3 files that all follow "song 1.mp3", originals are of the > > forms "song.mp3". I simply want to find them and delete them. Am I > > in the right direction here. > > In the original, can "song" end in a number? > > If so, can "song" contain a space before the number? > > Do the duplicate files all end in "<space><number[s]>.mp3"? > > Ed. The original might end in a number however the duplicates have had [space]1 added before (.mp3|m4a). |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On 5/2/2008 4:08 PM, Ryan wrote: > On May 2, 5:05 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > >>On 5/2/2008 4:01 PM, Ryan wrote: >> >> >> >> >>>On May 2, 4:56 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: >> >>>>On 5/2/2008 3:47 PM, Ryan wrote: >>> >>>>>On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: >>>> >>>>>>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: >>>>> >>>>>>>This is driving me nuts i am trying to use the following: >>>>>> >>>>>>>find . -exec grep -l "[0-9]\+\." '{}' \; >>>>>> >>>>>>>to find all files that have a number before a "." >>>>>> >>>>>>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. >>>>>> >>>>>>>Why is this and can you suggest a better pattern? I a=only want to >>>>>>>match the first result above. >>>>>> >>>>>>find <path> -name '*[0-9]\.*] >>>>> >>>>>>your example finds everything and runs grep on it????? >>>>> >>>>>This is within a certain directory >>>> >>>>Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to >>>>do with matching sub-directories and/or your other requirements. >>> >>>> Ed. >>> >>>Maybe I should explain the ultimate outcome here. I have a bunch of >>>duplicate mp3 files that all follow "song 1.mp3", originals are of the >>>forms "song.mp3". I simply want to find them and delete them. Am I >>>in the right direction here. >> >>In the original, can "song" end in a number? >> >>If so, can "song" contain a space before the number? >> >>Do the duplicate files all end in "<space><number[s]>.mp3"? >> >> Ed. > > > The original might end in a number however the duplicates have had > [space]1 added before (.mp3|m4a). Then just do: ls *\ 1.mp3 *\ 1.m4a and if you're sure that's the list you want to remove, replace "ls" with "rm". Ed |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
On May 2, 5:08pm, Ryan <ryan.fairch...@gmail.com> wrote:
> On May 2, 5:05pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > > > On 5/2/2008 4:01 PM, Ryan wrote: > > > > On May 2, 4:56 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > >>On 5/2/2008 3:47 PM, Ryan wrote: > > > >>>On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: > > > >>>>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > > >>>>>This is driving me nuts i am trying to use the following: > > > >>>>>find . -exec grep -l "[0-9]\+\." '{}' \; > > > >>>>>to find all files that have a number before a "." > > > >>>>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. > > > >>>>>Why is this and can you suggest a better pattern? I a=only want to > > >>>>>match the first result above. > > > >>>>find <path> -name '*[0-9]\.*] > > > >>>>your example finds everything and runs grep on it????? > > > >>>This is within a certain directory > > > >>Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to > > >>do with matching sub-directories and/or your other requirements. > > > >> Ed. > > > > Maybe I should explain the ultimate outcome here. I have a bunch of > > > duplicate mp3 files that all follow "song 1.mp3", originals are of the > > > forms "song.mp3". I simply want to find them and delete them. AmI > > > in the right direction here. > > > In the original, can "song" end in a number? > > > If so, can "song" contain a space before the number? > > > Do the duplicate files all end in "<space><number[s]>.mp3"? > > > Ed. > > The original might end in a number however the duplicates have had > [space]1 added before (.mp3|m4a). after banging my head too much i got it. find . -name '*[0-9]\.*' -exec mv {} </path/to/move/to> \; |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On 5/2/2008 4:15 PM, Ryan wrote: > On May 2, 5:08 pm, Ryan <ryan.fairch...@gmail.com> wrote: > >>On May 2, 5:05 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: >> >> >> >> >>>On 5/2/2008 4:01 PM, Ryan wrote: >> >>>>On May 2, 4:56 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: >>> >>>>>On 5/2/2008 3:47 PM, Ryan wrote: >>>> >>>>>>On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: >>>>> >>>>>>>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: >>>>>> >>>>>>>>This is driving me nuts i am trying to use the following: >>>>>>> >>>>>>>>find . -exec grep -l "[0-9]\+\." '{}' \; >>>>>>> >>>>>>>>to find all files that have a number before a "." >>>>>>> >>>>>>>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. >>>>>>> >>>>>>>>Why is this and can you suggest a better pattern? I a=only want to >>>>>>>>match the first result above. >>>>>>> >>>>>>>find <path> -name '*[0-9]\.*] >>>>>> >>>>>>>your example finds everything and runs grep on it????? >>>>>> >>>>>>This is within a certain directory >>>>> >>>>>Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to >>>>>do with matching sub-directories and/or your other requirements. >>>> >>>>> Ed. >>>> >>>>Maybe I should explain the ultimate outcome here. I have a bunch of >>>>duplicate mp3 files that all follow "song 1.mp3", originals are of the >>>>forms "song.mp3". I simply want to find them and delete them. Am I >>>>in the right direction here. >>> >>>In the original, can "song" end in a number? >> >>>If so, can "song" contain a space before the number? >> >>>Do the duplicate files all end in "<space><number[s]>.mp3"? >> >>> Ed. >> >>The original might end in a number however the duplicates have had >>[space]1 added before (.mp3|m4a). > > > after banging my head too much i got it. > > find . -name '*[0-9]\.*' -exec mv {} </path/to/move/to> \; therein lies the danger of writing scripts after banging your head too much :-). |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
On May 2, 11:15 pm, Ryan <ryan.fairch...@gmail.com> wrote:
> On May 2, 5:08 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > > > > On May 2, 5:05 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > > On 5/2/2008 4:01 PM, Ryan wrote: > > > > > On May 2, 4:56 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > > >>On 5/2/2008 3:47 PM, Ryan wrote: > > > > >>>On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: > > > > >>>>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > > > >>>>>This is driving me nuts i am trying to use the following: > > > > >>>>>find . -exec grep -l "[0-9]\+\." '{}' \; > > > > >>>>>to find all files that have a number before a "." > > > > >>>>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. > > > > >>>>>Why is this and can you suggest a better pattern? I a=only want to > > > >>>>>match the first result above. > > > > >>>>find <path> -name '*[0-9]\.*] > > > > >>>>your example finds everything and runs grep on it????? > > > > >>>This is within a certain directory > > > > >>Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to > > > >>do with matching sub-directories and/or your other requirements. > > > > >> Ed. > > > > > Maybe I should explain the ultimate outcome here. I have a bunch of > > > > duplicate mp3 files that all follow "song 1.mp3", originals are of the > > > > forms "song.mp3". I simply want to find them and delete them. Am I > > > > in the right direction here. > > > > In the original, can "song" end in a number? > > > > If so, can "song" contain a space before the number? > > > > Do the duplicate files all end in "<space><number[s]>.mp3"? > > > > Ed. > > > The original might end in a number however the duplicates have had > > [space]1 added before (.mp3|m4a). > > after banging my head too much i got it. > > find . -name '*[0-9]\.*' -exec mv {} </path/to/move/to> \; I think you don't need "\." because -name options wants a pattern and not a regular expression. find . -name "* 1.???" |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
On May 2, 11:57 pm, Javi <javibarr...@gmail.com> wrote:
> On May 2, 11:15 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > > > > On May 2, 5:08 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > > > On May 2, 5:05 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > > > On 5/2/2008 4:01 PM, Ryan wrote: > > > > > > On May 2, 4:56 pm, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > > > >>On 5/2/2008 3:47 PM, Ryan wrote: > > > > > >>>On May 2, 4:41 pm, OldSchool <scott.my...@macys.com> wrote: > > > > > >>>>On May 2, 4:22 pm, Ryan <ryan.fairch...@gmail.com> wrote: > > > > > >>>>>This is driving me nuts i am trying to use the following: > > > > > >>>>>find . -exec grep -l "[0-9]\+\." '{}' \; > > > > > >>>>>to find all files that have a number before a "." > > > > > >>>>>It matches both somefile_ 1.mp3 AND somefile_ .mp3. > > > > > >>>>>Why is this and can you suggest a better pattern? I a=only want to > > > > >>>>>match the first result above. > > > > > >>>>find <path> -name '*[0-9]\.*] > > > > > >>>>your example finds everything and runs grep on it????? > > > > > >>>This is within a certain directory > > > > > >>Then add "-maxdepth 1", or use "ls" instead of "find". Depends what you want to > > > > >>do with matching sub-directories and/or your other requirements. > > > > > >> Ed. > > > > > > Maybe I should explain the ultimate outcome here. I have a bunch of > > > > > duplicate mp3 files that all follow "song 1.mp3", originals are of the > > > > > forms "song.mp3". I simply want to find them and delete them. Am I > > > > > in the right direction here. > > > > > In the original, can "song" end in a number? > > > > > If so, can "song" contain a space before the number? > > > > > Do the duplicate files all end in "<space><number[s]>.mp3"? > > > > > Ed. > > > > The original might end in a number however the duplicates have had > > > [space]1 added before (.mp3|m4a). > > > after banging my head too much i got it. > > > find . -name '*[0-9]\.*' -exec mv {} </path/to/move/to> \; > > I think you don't need "\." because -name options wants a pattern and > not a regular expression. > > find . -name "* 1.???" Sorry find . -name "* [1-9].???" |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
On Friday 2 May 2008 22:22, Ryan wrote:
> This is driving me nuts i am trying to use the following: > > find . -exec grep -l "[0-9]\+\." '{}' \; > > to find all files that have a number before a "." > > It matches both somefile_ 1.mp3 AND somefile_ .mp3. Your command looks for the regular expression "[0-9]\+\." *inside* the files, not in their names. -- D. |
|
![]() |
| Outils de la discussion | |
|
|