Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 878  / 2 Years ago, mon, may 16, 2022, 1:51:11

I have: a directory with many nested subdirectories and files.



I would like: a list of all files whose name doesn't contain a certain string.



Example file structure:



foo/
foo/bar/foobar.txt
foo/foo/foobartest.txt
foo/foobartest.txt


If I enter my query with the string "test" it should return only /foo/bar/foobar.txt



I suppose one would use find with some regex?



Thanks a lot for your help!


More From » search

 Answers
1

Depends on what you want in the output.



ls -R | grep -v test


Or



find foo -type f | grep -v test


You can format the output with tools such as perl or awk


[#32881] Tuesday, May 17, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingwhin

Total Points: 332
Total Questions: 112
Total Answers: 115

Location: Burkina Faso
Member since Tue, Apr 26, 2022
2 Years ago
;