Skip to main content
added 23 characters in body
Source Link
Alxs
  • 2.3k
  • 3
  • 23
  • 31

Just do this:

$ cat file.log | awk '{ print $16, $19 }' 

And it will return a list like this:

SRV3 192.168.2.6
TESTSRV4 10.1.2.3
SRV1 192.168.2.15
TESTSRV2 10.1.2.4

You can redirect the output anywhere you like, for example, just add:

> hosts.text

to output your data to a file named hosts.txt

The above will clobber (replace) any content in the hosts.txt file. If you want to append your data to the end of your file use >> instead of >.

Just do this:

$ cat file.log | awk '{ print $16, $19 }' 

And it will return a list like this:

SRV3 192.168.2.6
TESTSRV4 10.1.2.3
SRV1 192.168.2.15

You can redirect the output anywhere you like, for example, just add:

> hosts.text

to output your data to a file named hosts.txt

The above will clobber (replace) any content in the hosts.txt file. If you want to append your data to the end of your file use >> instead of >.

Just do this:

$ cat file.log | awk '{ print $16, $19 }' 

And it will return a list like this:

SRV3 192.168.2.6
TESTSRV4 10.1.2.3
SRV1 192.168.2.15
TESTSRV2 10.1.2.4

You can redirect the output anywhere you like, for example, just add:

> hosts.text

to output your data to a file named hosts.txt

The above will clobber (replace) any content in the hosts.txt file. If you want to append your data to the end of your file use >> instead of >.

Source Link
Alxs
  • 2.3k
  • 3
  • 23
  • 31

Just do this:

$ cat file.log | awk '{ print $16, $19 }' 

And it will return a list like this:

SRV3 192.168.2.6
TESTSRV4 10.1.2.3
SRV1 192.168.2.15

You can redirect the output anywhere you like, for example, just add:

> hosts.text

to output your data to a file named hosts.txt

The above will clobber (replace) any content in the hosts.txt file. If you want to append your data to the end of your file use >> instead of >.