- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk stumper
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
тАО07-31-2002 11:20 AM
тАО07-31-2002 11:20 AM
I want to be able to find my string in a file, then use the field number as a basis for my subsitition. I have the my command for matching, but I can't get the sub to work. Any help would be appreciated.
awk 'match($0,"u_maxtries"){FS=":";print substr ($0,0)}' root
Craig
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2002 11:34 AM
тАО07-31-2002 11:34 AM
Re: awk stumper
I'm not an awk freak so the chance is big i'm
wrong but substr doesnt do a substitution i
think. It is the function sub that can do
this.
you can also use awk '/pattern/' file to
find a string.
rgds.
STeven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2002 11:56 AM
тАО07-31-2002 11:56 AM
Re: awk stumper
Can you give us an example of your input line and its associated output line?
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2002 11:57 AM
тАО07-31-2002 11:57 AM
Re: awk stumper
maybe that will do it ? :
awk 'match($0,"u_maxtries"){FS=":";sub($0,0); print'} root
but it will replace the whole line that
contains the word u_maxtries in 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2002 12:26 PM
тАО07-31-2002 12:26 PM
Re: awk stumper
:u_unsuclog#1026418505:u_unsuctty=console:u_maxtries#9:u_lock@:
I want to be able to determine the field that u_maxtries is in and then do my substitution from that.
Yes I know the sub() function, I can't get it to work the way I want it to...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2002 12:31 PM
тАО07-31-2002 12:31 PM
Re: awk stumper
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2002 12:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2002 12:44 PM
тАО07-31-2002 12:44 PM
Re: awk stumper
awk '{FS=":";sub("u_maxtries#[0-9]*","u_maxtries#6");print'} root
Thanks,
Craig
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2002 05:25 AM
тАО08-01-2002 05:25 AM
Re: awk stumper
Basically:
for (field=1;field<=NF;field++)
If theres's a match during the looping, the variable "field" gives you the field number.