Hi experts,
I would like to write a shell script that can print the file name from directory.Not required to see the contents.
Ex :
directory will have 5 files with different name.No matter what contents are.
Now I need to find the file which will have particular name (sub string ).Please do not look into contents.It should be in loop to check all the file names
Please provide the shell script.
Please let me know if any one need more info.
Page 1 of 1
Find The File Names Based On Name From Directory
#2
Posted 18 February 2010 - 09:41 AM
Run this script under the directory where you want to look up.
for i in `ls`
do
echo -e `expr match "$i" '\(.*compare.*\)'`
done
The above script first take the output of ls command.Then,it checks each and every file name is containing the substring compare.
If it matched,it will print the name of the file.
for i in `ls`
do
echo -e `expr match "$i" '\(.*compare.*\)'`
done
The above script first take the output of ls command.Then,it checks each and every file name is containing the substring compare.
If it matched,it will print the name of the file.
Share this topic:
Page 1 of 1

Help











