Hi I would like to do this
ls * | grep patternBut I would like instead of just showing the file with the pattern the whole path of the files that match the patterns
21 Answer
One way would be to use find to do your matching, though you might have to change the pattern to match the find syntax instead of greps as I think they are not identical.
find "$PWD" -maxdepth 1 -regex 'pattern'should show you the full path and the -maxdepth will prevent it from going into subdirectories. If you just want to use globs instead of regex you can use -name 'glob' syntax instead, and then use the * as you would with ls.
Here's an example output I see:
$ find "$PWD" -maxdepth 1 -regex '.*sh$'
/home/erenouf/tmp/scratch/t.sh
/home/erenouf/tmp/scratch/parseIW.sh
/home/erenouf/tmp/scratch/output.shsince I was in ~/tmp/scratch at the time and looked for files that ended in sh
In this case I can get the same output with
find "$PWD" -maxdepth 1 -name '*sh'To have it look in subdirectories you can just remove teh -maxdepth 1 part of each command