Find and hide file extension

Posted by Daveo on Super User See other posts from Super User or by Daveo
Published on 2012-04-11T05:19:25Z Indexed on 2012/04/11 5:32 UTC
Read the original article Hit count: 519

Filed under:
|
|

I am trying to find all files that have the same filename (excluding the file extension) that occur 3 times. I also need the full path to the file.

What I have currently is

#get file without extension
alias lse="ls -1R | sed -e 's/\.[a-zA-Z]*$//'"
#print out the current dir and get files occuring 3 times
lse | sed "s;^;`pwd`/;"  | sort | uniq -c | grep " 3 "

This runs howver pwd prints the folder I ran the command from not the path to the file.

So I tried find

find . -type f | sed "s#^.#$(pwd)#" | sort | uniq -c

This runs but includes the file extension. When I try to add sed -e 's/\.[a-zA-Z]*$//'" I get errors as I am not sure how to combine the two sed commands and I cannot seem to pipe a second time to sed?

so what I am trying to do is

find . -type f | sed "s#^.#$(pwd)#" | sed -e 's/\.[a-zA-Z]*$//'"| sort | uniq -c | grep " 3 "

but this does not run.

© Super User or respective owner

Related posts about bash

Related posts about unix