-1

I can't find any way to list out files with specific string in random location of the filename, except "find" command.

I don't want to use find command, it is very complicated to me.

for example: I want to list out files with "def" inside the filename no matter where the specified string is located. aa234aaaaaaaaadefaaaaa42.txt defaaaaaaaa234.txt aaaa234aadef.txt

Is there way to achieve this with our common "$ls" command ?

Thx

andrew_ysk
  • 103
  • 1

1 Answers1

0

With find:

find . -name "*def*"

with fd

fd def

With ls

ls ./*def*

Note that ls won't go thru subdirectories, you will need to search each and every directory manually.

mashuptwice
  • 2,929
  • 2
  • 12
  • 25
  • Wonderful.. This is want i have being looking.. You are the 1st one that provide this.. Could be there are other ppl, but i just didn't manage to find them. All i saw was "find" command which i don't want. $ls ./*def* did the trick. Thanks so much. !! – andrew_ysk Feb 14 '22 at 21:35
  • Note that sooner or later you `will` need find. It is a very handy and very powerful tool and it is worth the 10 minutes to get to know its syntax. – mashuptwice Feb 14 '22 at 21:37
  • I knew the syntax. learnt it long time ago, but I keep forgetting it when i needed it.. :-) – andrew_ysk Feb 14 '22 at 21:38