ネストされたループが必要な理由や、日付の範囲を反復する必要があるかどうかは明らかではありません。ただし、スクリプトは次のようになります。
#!/bin/bash
DAY_FROM=1 # This is a first (starting) day
DAY_TO=24 # This is the last day
DATE=$(date +%Y%m%d) # This is a date we are processing.
id=0 # This is a number for our unique ID generation.
# It is being incremented for each day.
# Since this variable is in global scope,
# it will be unique no matter how many dates you process.
# If you want unique ID be unique only for date scope,
# reset it to 0 before processing each date.
# Let's go iterate over all days.
for (( i=$DAY_FROM; i <= $DAY_TO; ++i ))
do
let ++id # Increment our unique ID number...
# Print filename, date, number and unique ID.
# %04d at the end means that we output an integer
# with 4 digits padded with zeroes if needed.
printf "%s %s %s %04d\n" "filename$i" "$DATE" "$i" "$id"
done
...出力は次のようになります。
filename1 20101007 1 0001
filename2 20101007 2 0002
filename3 20101007 3 0003
....
それが役に立てば幸い!