Cut Command, couple of examples

Cut Command, couple of examples

Had to do some more nice text manipulation this week following on sort of from examples about removing the lines beginning with a # etc.

I wanted to pull out just the IP addresses from the file so I could write something to ping the servers so knew what was up and what was already dead.

There was a lot of rubbish at the end of the lines, it looked like it was a tab as the delimiter after the IP address, so first off

$ cat dns_list.txt | cut -f1 -d$'\t' > dns1_list.txt

This did not clean it all up as some was not, so I decided to just pull out the first 15 characters that is the maximum the ip address would be.

$ cat dns1_list.txt | cut -b 1-15 > dns_list.txt

Then from there I had my list of IP addresses which I could then run some simple python code against to check if they are available.

I am always interested in feedback so please feel free to add any comments, or you can mail me  here.  If you would like to submit a quick tip  with full credit and links back to your site then also feel free to contact me.

Related Posts Plugin for WordPress, Blogger...
Mailbox Locations stored on you Mac

Mailbox Locations stored on you Mac

Remove lines beginning with a # using bash