hey guys. every one of the above commands worked. Thanks a lot. I have instantly got the awk example from druuna/schenidz but working on sed ones from other guys. But they all work magically. My terminal shows 5 different commands which operate on the same file and give the same output. pretty awesome.
|
Quote:
Code:
sed -nr '/mfr_id/ s:[^[:digit:]]*([[:digit:]]+).*:\1:p' |
Quote:
As usual in Linux, there's always more then one way to skin a cat :D I have learned lots from this thread thanks to the gurus here at LQ. Thanks guys. Kind regards, Eric |
The first sed example strips out (specifically) what is known to be not wanted - it substitutes "null" for it.
The latter case ensures only non-digits start the record, and looks for a string of digits - followed by anything (which could include digits). The bit in parentheses - the string of digits in this case - is retained by the back-reference "\1". Obvious ain't it .... :D. You have to be real careful constructing regex so you don't get unintended results. We've all been there. |
@ sycamorex , druuna
Code:
grep mfr_id <input-file> | awk -F "[><]" '{print $3}' and the nit-picky award goes to... |
All times are GMT -5. The time now is 09:17 AM. |