I am not into scripting but manage to create few with the help in this forum. Coming across a problem but not able to get it work (not sure if it is possible)
I have a fileY with content
lrwxrwxrwx  1  user1 gp  35  2021-09-07  2000  /folder/subfolder1/subfolder2/subfolder3/main/summary.txt
lrwxrwxrwx  1  user1 gp  35  2021-09-08  1400  /folder/subfolder1/subfolder2/main/summary.txt
lrwxrwxrwx  1  user1 gp  35  2021-09-09  1800  /folder/subfolder1/subfolder2/subfolder3/subfolder4/main/summary.txt
I wanted to output the column 3,6,7,8 and concatenate with the folder name before "main" like below
user1 2021-09-07  2000  /folder/subfolder1/subfolder2/subfolder3/main/summary.txt subfolder3
user1 2021-09-08  1400  /folder/subfolder1/subfolder2/main/summary.txt subfolder2
user1 2021-09-09  1800  /folder/subfolder1/subfolder2/subfolder3/subfolder4/main/summary.txt subfolder4
How can i have below sed command as one of the {print} variable for awk command?
awk '{print $3,$6,$7,$8}' fileY
sed 's/\// /g; s/\./ /g' fileY | awk '{for(i=8;i<=NF;i++){if($i~/^main/){a=i}} print $(a-1)}'


