For loop help

Hi all ,

I have a simple script to get the file name and creation date

#! /bin/ksh 
 
for ifile in `ls -ltr |  awk -F " " '{print $6 , "#" , $7 , "#" , $8 ,  "#" , $NF}'`
do 
   echo ${ifile}
done

expected output

 
Sep # 10 # 00:00 # file_1

but it is coming as

#
Sep
#
10
#
00:00
#
file_1

Instead of printing row by row it print seprated by spaces :wall:
TIA

Found the solution

---------- Post updated at 12:58 AM ---------- Previous update was at 12:39 AM ----------

Find the solution :smiley:

#! /bin/ksh
ls -ltr | awk -F " " '{print $6 , "#" , $7 , "#" , $8 ,  "#" , $NF}' | while read LINE
do
echo "${LINE}"
done
ls -ltr | awk -F " " '{print $6 , "#" , $7 , "#" , $8 ,  "#" , $NF}'

is enough.

No need to mention the field seperator as space

The highlighted part is not needed

 
ls -ltr | awk -F " " '{print $6 , "#" , $7 , "#" , $8 ,  "#" , $NF}'

Or just:

ls -ltr | awk '{print $6,$7,$8,$NF}' OFS=" # "