0

I'm using different ways to paste from a file into a script. I'm trying to use awk to paste from the first line of a file, however I want to only paste the 2,3,4 field. Here is my code

echo "Curve Name" $(awk 'NR==1'  testfile  )

Here is the output

Curve Name F gge0006x gge0001y gge0001z

I want to get rid of that F. The file that I'm reading it from starts with the F.

What I want is

Curve Name gge0006x gge0001y gge0001z

What should I add to get it to print this way?

2

Instead of using echo to print Curve Name and then have to get rid of the first field of the line, why not simply replace the field you don't want with the text that you do want?

awk 'NR==1 {$1 = "Curve Name"; print; exit}'  testfile
0
awk 'NR==1 {$1=""; print}'  testfile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.