Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-12-2018, 05:33 AM   #16
Registered: Feb 2011
Distribution: Centos 7
Posts: 908

Original Poster
Rep: Reputation: 74

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 05:39 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:41 AM
how to ignore resolving $1 in awk as the positional parameter raj k yadav Programming 7 03-17-2015 09:54 PM
[SOLVED] C++ how to get a string parameter from another program with '|' or < in bash embeddedPROJECTS Linux - General 2 11-10-2013 05:44 PM
[SOLVED] Bash: extended regex pattern 'NOT' disabled inside parameter expansion? romagnolo Linux - General 4 02-22-2012 05:39 PM
trouble with positional parameter $0 on bash. linux distro: ubuntu breezy linrookie Linux From Scratch 2 05-07-2006 01:22 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:43 PM.

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