Matching values in a bash script grep, regex's ... ?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Here ${anarray[$a]} holds the initial variable with number_name.
This:
#NEWNAME=$(echo grep '[0-9]_' "${anarray[$a]}")
and this:
grep '[0-9]_' "${anarray[$a]}" > NEWNAME
As you can see I am a bit confused.
In Perl I would simply do a little regex and catch what I wanted in a $N and then swap things around, SIMPLE! I can't figure this one out. I know what I want, just not the mechanics. Any ideas?
I have tried various combinations of "" and '' etc. but I do not quite understand. Basically I want the matched Number and Underscore assigned to NEWNAME...
When I use quotes it just outputs grep -o etc. If I leave them out it says Command Not Found....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.