Reputation: 446
i am creating a script that reads each file in a certain directory and uses some info from each file, but there is a file called "logdia + date" in each directory which i dont want to include into my loop, i have tried tu use an if-statement to compare the rute of the file to a string using wildcards but the condition never fails, and it always includes the "logdia" file into my loop, what am i missing? Thankyou
list_dir=$(ls -tr /opt/srv001/app/sam/trazas/*$v_fecha*)
for dir in $list_dir
do
if [ $dir != "*logdia*" ]
then
//Do stuff
fi
done
Upvotes: 1
Views: 4424
Reputation: 785226
Right way to do that is as follows:
for dir in /opt/srv001/app/sam/trazas/*$v_fecha*; do
if [[ "$dir" != *"logdia"* ]]; then
echo "Do stuff Here"
fi
done
Upvotes: 1