LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-12-2018, 04:33 AM   #16
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103

Thanks for all the answers. Much more than I needed, of course, but very helpful I didn't have time to answer fast enough and I was suddenly flooded with answers.

The most direct answer to what I was trying to achieve was from rknichols. Now I know exactly that I can pass bash positional parameters to awk in the context of strings with regex. I've just tested it and it works really well.
But the other answers were also helpful too. For instance keefaz made it much simpler and practical so I didn't need to pass any positional parameters to awk.

Indeed, I was interested in ipv4. It so happened that I disabled ipv6, so the ipv6 addresses don't show up. On the other hand, if they did show up, I know that I'd need to match the exact word 'inet' and not 'inet6'. That's easier to do, of course.
Other posts using awk with srch and gensub I'd need more time to understand, I haven't studied awk enough, but I'm planning to

Somebody also used grep with perl regex, but I think he edited his post, not sure why. I haven't been able to read all the posts until now. I guess the point was to match the word 'inet6' and 'inet' and then show the next string or something, i.e the IP. Not very familiar with perl regex, to be honest, but I know they solve thorny problems.

Last edited by vincix; 03-12-2018 at 04:39 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Positional Parameter issue in Bash script torrid Programming 7 01-31-2017 04:41 AM
how to ignore resolving $1 in awk as the positional parameter raj k yadav Programming 7 03-17-2015 08:54 PM
[SOLVED] C++ how to get a string parameter from another program with '|' or < in bash embeddedPROJECTS Linux - General 2 11-10-2013 04:44 PM
[SOLVED] Bash: extended regex pattern 'NOT' disabled inside parameter expansion? romagnolo Linux - General 4 02-22-2012 04:39 PM
trouble with positional parameter $0 on bash. linux distro: ubuntu breezy linrookie Linux From Scratch 2 05-07-2006 12:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration