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
Forums
Discussions
Discussions
Discussions
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
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
03-19-2007 11:39 PM
03-19-2007 11:39 PM
I've got this to work good but the problem is that it's not returning 1 if I have only characters in both fields. I need it to return a vaule of 1 when the first two fields are characters and when the first field is characters and the second field is numbers?
example:
myredcar mybluecar
mycar 192.168.1.10
it's not returning a value of 1 for the first line but it does work for the second line.
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 11:45 PM
03-19-2007 11:45 PM
Re: awk
have you tried the code without the 'exit 1' ?
Can you please specify the exact requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 11:47 PM
03-19-2007 11:47 PM
Re: awk
Perhaps:
# awk '$1!~/^[0-9]+$/||$2~/^[0-9]+$/{print;exit 1}' tmp.txt
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2007 12:35 AM
03-21-2007 12:35 AM
Re: awk
Here is my requirements:
cat f1.txt
myredcar mybluecar
mycar 192.168.1.10
192.168.1.1 192.168.1.2
192.168.1.3
It should return a failure status for all of the above lines and return a successful status for the following line whenever they exist in the file f1.txt
192.168.1.4 host100
The lines however, should not be less than or exceed 2 fields.
awk '{NF ==2}' f1.txt, I would like to add this one to the same awk statement so that I'll have only one line of awk commands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2007 12:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2007 05:02 PM
03-21-2007 05:02 PM
Re: awk
One thing though, it should also fail with the following:
1111111111 myhost100
Notice that the first field doesn't have dots.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2007 07:54 PM
03-21-2007 07:54 PM
Re: awk
Do you really want something that confusing?
>One thing though, it should also fail with the following:
1111111111 myhost100
>Notice that the first field doesn't have dots.
Perhaps you need to write a program in awk. I suppose you could have a ERE that would have 3 dots in it, otherwise you could put more checks in your awk script.
awk '$1 !~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ || $2 !~ /^[a-zA-Z0-9]+$/ {print;exit 1}'
Above it looks for 3 ".". (I couldn't use the \{3\} syntax to have groups of "###.".)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2007 03:43 PM
03-27-2007 03:43 PM
Re: awk
Thanks to both of you.