[TriLUG] Search for Duplicate Filename, Ignore Extension

Robert Dale robdale at gmail.com
Wed Nov 2 15:44:31 EDT 2011


cat files.txt | cut -f 1 -d '#' | sort -f | uniq -ic | grep -v "^\s*1"
| awk '{$1="";$0=substr($0,2)}1' | while read dupe; do grep -i
"${dupe}\#" files.txt; done

On Wed, Nov 2, 2011 at 3:13 PM, Brian Blater <brb.lists at gmail.com> wrote:
> 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
> --
> This message was sent to: Robert Dale <robdale at gmail.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web  : http://www.trilug.org/mailman/options/trilug/robdale%40gmail.com
> TriLUG FAQ          : http://www.trilug.org/wiki/Frequently_Asked_Questions
>



-- 
Robert Dale



More information about the TriLUG mailing list