I have a simple shell script in which I am taking the filename/dirname/reg expr as input.
On it I am exeuting the ls command and taking some action on it.
Code: Select all
for i in `ls $1`
do
echo "Working on file: $i"
<other stmts>
done
But if the instead of the directory, I give a reg expr like /tmp/file*.txt, it just picks up first file from the list and loop just executes once.
E.g. consider the script has name ProcesFile.sh and directory /tmp/kirtis/ has following files - file1.txt, file2.txt, emp1.txt and emp2.txt.
When called as ProcesFile.sh /tmp/kirtis/ it processes all 4 files.
But when called as ProcesFile.sh /tmp/kirtis/file*.txt, it only processes file1.txt and skips the other files starting with file i.e. file2.txt.