I offered the non-awk solution because it is self explanatory what it is doing and it uses commands that are used daily by most Unix users. The awk solution with no explanation what it is doing, for those like myself that are not familiar with awk, is just confusing. If parsing out IP addresses is an action that needs to be repeated often, I suggest using Perl, for two reasons. One, it is more efficient that shell solutions and two it is portable even to Windows systems so has a higher reuse value.
I agree that there is a tendency for awk coder to be as terse as possible but you can write awk code that is as readable as perl. Awk inspired Larry Wall to write Perl. So there is a little bit of awk philosophy and coding style in perl. And you can also obfuscate your code in perl: Perl activity
I still believe that for this type of application (scanning a log file) awk is the best tool for the job. Portable, light and fast, very fast (specially the mawk version based on a byte code interpreter). You can also use awk on Linux, *bsd, windows and os-x platforms. Of course you can't do everything with awk. Although I have seen a http server written entirely in awk, when it comes to do complicated things you have to switch to a language like perl, php or python. But, again, for this type of problem, you can't beat awk.
So, if the OP can post a sample file, I promise to come up with a readable solution with comments. No obfuscated code anymore. Promised.
Hello, I have a problem of routing traffic on two virtual interfaces I have created on my machine (CentOs6)
By using tunctl I created two virtual interfaces tap1 and tap2
let s imagine I gave them two different address
tap1: 10.1.1.1 net 255.255.255.0
tap2: 10.1.2.1 net 255.255.255.0
... (0 Replies)
Hi All,
I have a file which is "|" pipe delimited. The file has 3 fields. the last field contains email ids which has different host names.
I want to sort the file based on host name, which is in 3rd filed and needs to create a file for each host.
For example, if out of 1000 records, 10... (6 Replies)
This is probably a real n00b question but i`m not able to figure it out.
I have a folder of configuration files that contain IP-adresses. The line i`m interested in looks like this:
IP_ADDRESS="123.123.123.1123"
Some have muliple ip adresses, so the line will look like :
... (5 Replies)
well i'm trying to change the ip adress on an old alphaserver runing tru64 4.0F using the
ifconfig hme0 IP_ADDRESS mask MASK broadcast BROADCAST
and when i check it using ifconfig -a it shows the new ip and all is well
but when the server is rebooted it reverts back to the old ip (3 Replies)
Dear All,
Please can you help me to crack this query?
If the log files for the task above all had a naming convention of myoutput_YearMonthDay.log (i.e. myoutput_20060215) How would you find only those log files created between the 10th and the 20th of each month going back the last 365 days.... (1 Reply)
I want change my IP address and hostname in my machine by use the console. Can any one tell me how can I execute that by command ?
Thanks & Regards (1 Reply)
hello
I need for a script to capture the ip address from the connected user.
I have 5 logical partitions.
With "who", i have the ip adress, but only for 2 servers.
Do you know another command to know the ip address of connected clients ?
thank you (14 Replies)