- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk will not parse the way I want it to.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 05:46 AM
тАО12-18-2003 05:46 AM
Here's the code:
IP=192.168.0.50
OCT1=`echo $IP | awk -F: '/^[^#*]+./ {print $1}' -`
echo $OCT1
OCT2=`echo $IP | awk -F: '/^[^#*]+./ {print $2}' -`
echo $OCT2
OCT3=`echo $IP | awk -F: '/^[^#*]+./ {print $3}' -`
echo $OCT3
Output is
192.168.0.50
then two blank lines.
Intended output is
192
168
0
Yes, I'm trying to break up an IP adderss.
I tried some awk code that I use to pull the data from a colon : delimited oratab database, replaced the : with a dot . and get bad results.
Thanks in Advance for the help.
Points for any effort. Rabbit for any code that works.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 05:51 AM
тАО12-18-2003 05:51 AM
Re: awk will not parse the way I want it to.
you can work the rest out :-) John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 05:51 AM
тАО12-18-2003 05:51 AM
Re: awk will not parse the way I want it to.
# OCT1=`echo $IP | awk -F. '{print $1}'`
and of course OCT2 for $2 etc.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 05:55 AM
тАО12-18-2003 05:55 AM
Solutionecho $IP | awk -F"=" '{ print $2}' | awk -F"." '{ print $2)'
echo $IP | awk -F"=" '{ print $2}' | awk -F"." '{ print $3)'
ignore the last entry this is what i meant
:-) jOHN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 05:58 AM
тАО12-18-2003 05:58 AM
Re: awk will not parse the way I want it to.
Thread closed.
My embarassment forgotten.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 05:58 AM
тАО12-18-2003 05:58 AM
Re: awk will not parse the way I want it to.
:-) John
off to dinner now see you all later
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 06:03 AM
тАО12-18-2003 06:03 AM
Re: awk will not parse the way I want it to.
Even by accident like this time.
itrc rocks!
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 06:14 AM
тАО12-18-2003 06:14 AM
Re: awk will not parse the way I want it to.
print "$IP" | tr -d "\." | read oct1 oct2 oct3 oct4 rest
print "1st = $oct1\n2nd = $oct2\n3rd = $oct3"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 06:23 AM
тАО12-18-2003 06:23 AM
Re: awk will not parse the way I want it to.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 08:15 PM
тАО12-18-2003 08:15 PM
Re: awk will not parse the way I want it to.
Just for fun and for those who don't know IFS in shell :
IP=192.168.0.50
OFS="$IFS" # save $IFS just in case
IFS=.
set +A OCT $IP
IFS="$OFS" # restore default IFS
echo ${OCT[0]} ${OCT[1]} ${OCT[2]} ${OCT[3]}
echo ${OCT[@]} # print whole array ...
Regards.