[TriLUG] Search for Duplicate Filename, Ignore Extension

Brian Blater brb.lists at gmail.com
Wed Nov 2 15:13:15 EDT 2011


On Wed, Nov 2, 2011 at 2:48 PM, Brian Blater <brb.lists at gmail.com> wrote:
> On Wed, Nov 2, 2011 at 2:40 PM, Robert Dale <robdale at gmail.com> wrote:
>> Numbers and greedy matching were messing it up. Also added
>> case-insensitive to sort + uniq.
>>
>> cat files.txt | cut -f 1 -d '#' | sort -f | uniq -ic | grep -v "^\s*1"
>> | awk '{print $2}' | while read dupe; do grep -i ${dupe}\# files.txt;
>> done
>>
>> On Wed, Nov 2, 2011 at 2:25 PM, Brian Blater <brb.lists at gmail.com> wrote:
>>> awk '{print $2}' | while read dupe; do grep -i ${dupe}\# /another/path/files.txt;
>> --
>> Robert Dale
>
> Awesome! That did it.
>
> I need to learn more about awk, grep, sed etc, because the only change
> I saw was in the grep statement (well other the the -i to ignore case:
>
> 1st: grep -v "^.*1"
> 2nd: grep -v "^\s*1"
>
> Thanks,
> Brian

I'm still testing some with this and found that if the filename has a
space in it that causes problems also. Any way to take into
consideration that the filename may have spaces between words?

Brian



More information about the TriLUG mailing list