I use find to search for files in a directory or its subdirectories.
find . -iname '*.csv'
, and it gives me the following output
./2012/t1.csv
./2012/t2.csv
./2013/t1.csv
Now, I want to check in a script whether the file t1.csv
is in the current folder or in one of the subdirectories. If it's in a subdirectory, my script should descend to that directory.
How can I do that?
Best Answer
To check only for
t1.csv
, you can use:Now, to go in the first directory where
t1.csv
file is found, you can use: