Awk with Find and play using Space

Hi All,

Sample records

 
2157 91128 -rw-r-----  1 arun1    staff    93315072 Aug 23 06:44 /home/arun/my own/file_name.txt
2157 91128 -rw-r-----  1 arun1    staff    93315072 Aug 23 06:44 /home/arun/myown/file name2.txt

i want to print only user name, user group, size, date time stamp, and full file name including the path.

In the sample record we can see 11th field contains file path and name in it with spaces in directory name and also file name, and all the fields are also delimited with spaces naturally.

I used:

 
find /home/arun -type f -name "*.txt*" -mtime +90  -ls 2>/dev/null | awk '{print $5","$7","$8,$9,$10","$11} 

inorder to print 11th field (with space) but i am getting

arun1,93315072,Aug 23 06:44,/home/arun/my
arun1,93315072,Aug 23 06:44,/home/arun/myown/file
you can see 11th field is cut down since it has space... i used \"$11\" also in awk but not helping me.

I am expecting the output like below:

 
arun1,93315072,Aug 23 06:44,/home/arun/my own/file_name.txt
arun1,93315072,Aug 23 06:44,/home/arun/myown/file name2.txt

Please help.

Thanks in advance!

Instead of printing required fields, why not delete the ones not required?

awk '{$1=$2=$3=$4=""; print}'

That worked!!!! So simple opposite logic... Nice.

However i wanted my output delimited by comma character.

$ nawk '{printf("%s,",$5);for(i=7;i<=10;i++){printf("%s,",$i)}for(i=11;i<NF;i++){printf("%s ",$i)}printf("%s\n",$NF)}' test.txt
arun1,93315072,Aug,23,06:44,/home/arun/my own/file_name.txt
arun1,93315072,Aug,23,06:44,/home/arun/myown/file name2.txt

To just answer you intitial question.

The input lines contain 12 fields instead of 11 . awk will read any space(s) as a delimiter between fields. The fact that we humans interpret a space differently because we know how to interpret the lines is not relevant to awk.

find /home/arun -type f -name "*.txt*" -mtime +90  -ls 2>/dev/null | awk '{print $5","$7","$8,$9,$10","$11" "$12}

Thanks a lot!

It worked perfectly. I am trying to manipulate few more. This really helped a lot!!