I have some flat files with time stamp,and some not with time stamp ,I need the files to list with time stamp and non time stamp with sequencial manner.I wrote the shell script to list the files with time stamp ,but non time stamp when use another for loop,its giving more file list.Any advise it should be appereciated.
Files
=====
file120081218-153431-630.txt
file220081318-153431-630.txt
file320081218-153431-630.txt
file420081218-153431-630.txt
file5.txt
file6.txt
for a in `ls -lrt |awk '{print $9}'|awk '{print substr($0,(index($0,"-"))-1),-8}'|sort -u`
do
echo $a
for a1 in `ls lrt *$a*|awk '{print $9}'`
do
echo $a1
done
done
20081218
file120081218-153431-630.txt
file320081218-153431-630.txt
file420081218-153431-630.txt
20081318
file220081318-153431-630.txt
expecting o/p
20081218
file120081218-153431-630.txt
file320081218-153431-630.txt
file420081218-153431-630.txt
20081318
file220081318-153431-630.txt
file5.txt
file6.txt