Printing foremated output unto a variable using AWK
I am trying to use AWK to search a text file and pull out a field. I want to take the output of the awk, strip off the first eleven characters and place that into a variable in a bash script.
The test script I am using for proof of concept is this: Code:
#!/bin/bash -bash-3.2$ ./greptest1 enter your PE router : router1.nyr 192.168.0.50 router1.nyr has a route descriptor of ~~~~~~~~ several blank lines later~~~~~~~ 66 53 78 62 70 69 79 58 68 What I am expecting for output is: -bash-3.2$ ./greptest1 enter your PE router : router1.nyr 192.168.0.50 router1.nyr has a route descriptor of 50 My input file lo1map looks like this (It's a lot longer though) router1.ald 192.168.0.9 router1.bol 192.168.0.17 router1.chd 192.168.0.11 router1.dan 192.168.0.13 router1.dck 192.168.0.3 router1.den 192.168.0.15 router1.ft3 192.168.0.25 router1.lay 192.168.0.5 router1.mmd 192.168.0.19 router1.nyr 192.168.0.50 Thanks in advance! |
Honestly, I think you went a bit overboard.....
Code:
#!/bin/bash Josh |
Well my first question is why you set a variable to a string to then be overwritten later?
Code:
MSR=unset Code:
unset MSR Code:
RD=$(grep $MSR $INFILE | grep -Eo '[0-9]+$') |
thanks for the help, I went with the grep and awk option. i am very new to linux and bash scripting and I just don't have me head around SED yet.
thanks again for the quick responses!! |
All times are GMT -5. The time now is 12:10 AM. |