Hi all,
I suppose a linux forum would be abetter place to post this, but I love you all so much here.
I'm trying to write a bash script to take an ip address, and give me each component. This isnt for an assignment or anything, just for a personal project.
I've been messing with that damn sed command for hours trying to split the text up properly.
For instance, if I had the ip address 123.58.93.923 I would like one line of code to give me
123
another line to give me
58
another line to give me
93
and another to give me
923
I cant seem to write a piece of code that will isolate each component, and be able to handle if correctly if theres a different number of characters in each segmet. So if i refreshed my dynamic IP and it became 11.539.2.99, i woudl like the code to still break it up.
Perhaps this task is more difficult than its worth, but if anyone has a quick and easy solution, I'd be very appreciateive. the base code I've been working with is
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
Thanks amillion if anyone has any suggestions!
10088847214381951643320470475858305731166183151407164751271470824235003318621252307969752086088076499395823874814123350292603347408732347765156628342107995
Posts
I typically use awk to split along whitespace (the default), but you can change the field separator with "-F".
I'd recommend using "cut", actually. Slightly shorter than the sed and awk.
e.g. echo 213.4.55.11 | cut -d . -f 1
(bolded my emphasis) If you ever get anything like that, then the Internet has broken. :P
Thanks again! its great!