Need to print nth till last column of ls output using sed

I wish to print first, third and sixth till the last column from the output of ls command

ls -ltr /app/deploy.yml
-rw-rw-r-- 1 user1 dba 27342 Aug 28 10:17 /app/deploy.yml

Desired Output:

Below command gives me the desired output.

ls -ltr /app/deploy.yml  | awk '{$2=$4=$5=""; print $0}'

However, I wish to use sed instead of awk as the code where I'm incorporating the awk does not like these braces "{}"

Any solution without these braces would be great.

Why not save the awk script to a little file, and run it like

awk -f file

? No braces ...

Unfortunately this will not help as this command would run remotely across servers and hence copying the file to each remote host will not be feasible.

I would more so like to avoid doule quotes "". Guess braces {} are fine.

Need to rid my awk and other solutions which off double quotes as highlighted in RED here awk '{$2=$4=$5=""; print $0}' . The double quotes are the problem in my code.

So use:

awk '{$2=$4=$5=x; print}'
1 Like

Works !! Thank you @Don Gragun

no braces examples:

ls -ltr /app/deploy.yml | awk '$2=$4=$5=_;1'
ls -ltr /app/deploy.yml | sed 's/\([^ ]*\) *[^ ]* \([^ ]*\) *[^ ]* *[^ ]* */\1 \2 /'

A very short one that even works with the Solaris /usr/bin/awk:

ls -lotr /app/deploy.yml | awk '($2=$4=x)==0'