954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

awk problem

hey everybody,
I just wanted to know how I can print out with awk or others only one line and not a whole column what is made by print$1. I have a data which contains 205 lines and I want for example only the 6th line. I tried with this

BEGIN { RS = "" ; FS = "\n" }
{print $6}

...but it says

awk: record `TITLE = "title"
V...' too long

What's wrong with that. thanks a lot.

fili00
Newbie Poster
3 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

Hi!

You can choose the line number by using the variable NR.
To print the whole 6th line:

awk 'NR == 6 {print}' file.dat

To print the 6th column of the 6th line:

awk 'NR == 6 {print $6}' file.dat

Hope this is what you wanted.

Regards, mawe

mawe
Junior Poster
133 posts since Sep 2005
Reputation Points: 19
Solved Threads: 58
 

Hi!

You can choose the line number by using the variable NR. To print the whole 6th line:

awk 'NR == 6 {print}' file.dat

To print the 6th column of the 6th line:

awk 'NR == 6 {print $6}' file.dat

Hope this is what you wanted.

Regards, mawe

Hi, mawe

thanks a lot, it's exactly what I was searching for. It's simply syntax but it is nowhere described.

Regards, fili

fili00
Newbie Poster
3 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You