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.
please help me do this, i have no idea how to do it. ALSO...please keep the answer simple otherwise i will just get lost
thanks
To print the last line of a file, use the "tail" command.
Conventionally, we would probably sort so that the top result is at the top, and use "head".
Don't worry about this part, I'm just giving you hints in case you want to develop your skills in the future.
If you want to split off the counter and just see the IP address, you can post-process the output from tail (or head, or any command) with a command like "cut" or "awk" or ... there's a myriad variations. I'll use awk here because it conveniently handles the space-padded format you are using (cut would have a problem with that);
awk is a full-blown scripting language so you could do all of this in awk, but I guess you are overwhelmed already.
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.
In the general case, it's probably better to post a new question under a different topic title, because many readers only look at the topic titles and only read the ones they know the answer to (or find interesting, or don't know the answer to, depending on who they are and what they do).
Hi.
How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg
file1
1:abc
3:ghi
6:pqr
file2
a abc
b def
c ghi
d jkl
e mno
f pqr
... (6 Replies)
Sorry if I repost my question in this section, but I'm really in a hurry since I have to finish my work... :(
Dear community,
I have a table with two rows like:
Row1 Row2
======= =======
7,3 text 1
1,3 text 2
1,2,3 blabla
What i need to do is add/copy... (2 Replies)
Hi all
I have file with columns
F3 pathway CPS
F2
H2
H4
H5
H6 no pathway CMP
H7
H8
H9
H10
My expected output is
F3 pathway CPS
F2 pathway CPS (10 Replies)
Guys -- I am noob and I am really strugging on this one. I cant even write the pseudo code for it. I have a file that spits values in individual rows as such:
file:
user date type size
joe 2005-25-09 log 1
joe 2005-25-09 snd 10
joe 2005-25-09 rcd 12
joe 2005-24-09 log 2
joe... (1 Reply)
Hi
I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example.
The original data record should be some thing like this
60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)