wildcards to list a group of files in sequential numerical order ?
Miner, Jonathan W (US SSA)
jonathan.w.miner at baesystems.com
Mon Nov 7 18:29:26 UTC 2011
________________________________________
From: users-bounces at lists.fedoraproject.org [users-bounces at lists.fedoraproject.org] On Behalf Of linux guy [linuxguy123 at gmail.com]
Sent: Monday, November 07, 2011 12:28
To: Community support for Fedora users
Subject: wildcards to list a group of files in sequential numerical order ?
I'd like to list all the files with names between DSC_6035.NEF and
DSC_6072.NEF.
How do I do this ?
I tried using DSC_[6035-6072].NEF, but that doesn't work. It lists
files outside the desired range. The [ ] operator needs just 1
character parameter to work properly ????
________________________________________
Not sure that shell globbing will work here... but you could do something like this in bash:
start=6035
end=6072
list_files()
{
n=$1
while [ $n -le $2 ]; do
f=DSC_${n}.NEF
[ -f ${f} ] && echo $f
n=$(($n + 1))
done
}
ls `list_files $start $end`
More information about the users
mailing list