I have a text file, a.txt. Contents are:
$ cat a.txt microsoft.com google.com ibm.com
I'm trying to run a host command on each line to get the IP address. Here is my script:
#!/bin/sh for i in `cat a.txt` do echo $i host $i done
When i run it I get this:
$ ./a.sh microsoft.com Host microsoft.com\013 not found: 3(NXDOMAIN) google.com Host google.com\013 not found: 3(NXDOMAIN) ibm.com Host ibm.com\013 not found: 3(NXDOMAIN)
However if in edit my script to explicitly specify the host :
#!/bin/sh host microsoft.com host google.com host ibm.com
Do you know I get "013 not found: 3(NXDOMAIN)" ?
\013 indicates that you have a carriage return at the end of your host name. Strip it (e.g. using something like
tr -d '\r') before passing the host name to '