AWK: how to get text which is between two strings

If you need to get some text which is in file between two lines you could use awk for this. You may need it while analyzing access logs to fix some issue, for instance. Here’s how you could do it: awk ‘/2012:00:20:49/, /2012:00:35/’ access_log > output It’s a simple and convenient way.

AWK: getting last column value

If you need to get value of last column in awk you can use built-in variable NF which means the number of fields in record. Or next, if you need next to the last field. And so on.

Bash: sort IP addresses

It’s very easy sorting IP-list. For example you have file ‘ip-list’. To sort IP’s redirect file contents to following sort command. Also collect only unique IP’s in yours list. Didn’t find the answer to your question? Ask it our administrators to reply we will publish on website.