![]() |
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 |
| How to print data between 2 lines in a file | kamesh83 | UNIX for Advanced & Expert Users | 5 | 12-18-2008 12:14 PM |
| print out result from data file | thms_sum | Shell Programming and Scripting | 8 | 01-30-2008 11:32 AM |
| Print Problem in UNIX. Need to know the option to specify the print paper size | ukarthik | HP-UX | 1 | 06-07-2007 09:35 AM |
| Logging HP-UX print data | pmaths | UNIX for Dummies Questions & Answers | 0 | 04-23-2007 08:45 AM |
| Unix Program for data and print | miketaylor | UNIX for Advanced & Expert Users | 5 | 05-21-2002 10:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Print out a row of data
hi
im completely new at unix so dont hate me for asking what is probably the easiest question ever. below is an extract of some data im processing. the first column is like a counter while the second is an ip address. i need to be able to output the ip address based on which has the largest counter number. as you can see the data is already sorted by the size of the counter. hence the output would be 66.249.66.103. Code:
65 138.130.16.56
67 207.46.98.38
79 65.214.44.112
82 66.151.181.10
94 209.191.65.248
96 207.46.98.37
97 207.46.98.39
104 207.46.98.40
178 66.249.65.167
457 66.249.66.103
thanks |
|
||||
|
To print the last line of a file, use the "tail" command.
Code:
tail -n 1 filename Don't worry about this part, I'm just giving you hints in case you want to develop your skills in the future. Code:
sort -rn filename | head -n 1 Code:
tail -n 1 filename | awk '{print $2}'
|
|
||||
|
thanks a lot. that was a big help. yeah i knew that awk could do it all, but i prefer to work through it step by step using the simple commands.
btw this is not related to my previous question, but when setting out unix code are there any ever new lines between pipelines? coz im writing a script and it has 8 pipelines at the moment which tends to get a bit messy. ie what is the correct setting out for longer unix code. |
|
||||
|
The shell allows you to split pipelines across multiple lines without any continuation character.
Code:
grep fnord /tmp/file | nl | sed -e 's/foo/bar/' | cat -A | whatever ... |
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|