Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

IF condition to compare file prefix

$
0
0
I have files with naming as below,
testS123,
testS223,
testB1,
testC1,
testD1

I need to write a if condition to print 'Hello' when the file prefix is not testS* else 'Good bye'.

Code:

if [ $file not like file prefix testS* ]
then
echo "Hello"
else
echo "Good bye"
fi;


Viewing all articles
Browse latest Browse all 16232

Trending Articles