![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Retrieving random numbers out of a text file | nistleloy | UNIX for Dummies Questions & Answers | 13 | 12-14-2008 04:28 PM |
| retrieving specific lines from a file - can I use grep ? | hcclnoodles | Shell Programming and Scripting | 9 | 09-23-2008 06:45 AM |
| Retrieving PID from a file | appleforme1415 | UNIX for Dummies Questions & Answers | 5 | 10-18-2007 01:44 AM |
| Automating Rlogin and File Retrieving | vicesjr | Shell Programming and Scripting | 3 | 04-27-2005 10:30 AM |
| retrieving a deleted file | jyotipg | UNIX for Advanced & Expert Users | 2 | 01-04-2002 08:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Retrieving particular row from a dat file
Hi..
I have a dat file containing both column names and data. Now I want to get only Particular row along with the column names. My dat fiel is as below EmpName Dept Salary Shally Admin 20000 Swati HR 15000 Deepali IT 45000 Preetika EEE 60000 Now I want to display only row 3rd along with column name using awk command. I tried as below to get the column name ; awk 'NR==1 {print $0}' Employee.dat This retrives the column name... now how to get particular row. ![]() |
|
||||
I have one more query. If we know exactly which row to retrieve then this will work fine. Suppose the given dat file contains thousands of records, I just want to retrieve all the rows whose salary is greater tha 15000. How can v acheive that ? In other words can v use expressions(logical,arthmetic, regular...) to retireve the particular rows along with the column name.. |
|
|||||
|
Quote:
Code:
awk 'BEGIN{NR==1{print}$3>15000{print}' filename
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|