Wednesday, July 18, 2012

Regular expression in bash "for" loop for file exclusion

najmi@aku-PC ~/cuba
$ touch ayam.txt ayam.csv ayam.egg

najmi@aku-PC ~/cuba
$  for i in a*[!.csv,.txt];do echo $i;done
ayam.egg


Here we use the popular ! mark to exclude the file extension within the brackets. Got the solution after few trials.

No comments:

Post a Comment