0

I am trying to print the filename with the output of the command below

less $file|awk -F' ' '{print '$file' $2,$3,$5}

it prints without the variable value

x y z
a b c

I want to print

file1 x y z
file1 a b c
Inian
  • 80,270
  • 14
  • 142
  • 161
Amitabh
  • 15
  • 6

1 Answers1

0

Try: awk -F' ' '{print FILENAME " " $2 " " $3 " " $5}' $file

FILENAME is a built-in variable of awk, representing the input filename.

marcolz
  • 2,880
  • 2
  • 23
  • 28