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
  • 71,145
  • 9
  • 121
  • 139
Amitabh
  • 15
  • 5

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,677
  • 2
  • 23
  • 25