I looked some other posts and learnt to match file extension in the following way but why my code is not working? Thanks.

  1 #!/bin/sh
  2 
  3 for i in `ls`
  4 do
  5     if [[ "$i" == *.txt ]]
  6     then
  7         echo "$i is .txt file"
  8     else
  9         echo "$i is NOT .txt file"
 10     fi
 11 done


#bash

2 Likes2.25 GEEK