Kevin Falcone on Thu, 30 Nov 2000 13:11:55 -0500 (EST) |
>>>>> "KRB" == Kyle R Burton <mortis@voicenet.com> writes: someone else wrote: >> aaaa9879aaaaaa0870aaaaaaaaaaa09 => 9879 0870 09 >> aa908798986986aaaaaaaaaaaaaaaaa => 908798986986 KRB> Try awk or perl. I don't know awk, but this should do it for perl: While I'm sure you can do it in awk, I can't seem to remember how right now. The below all work. echo "aaaa9879aaaaaa0870aaaaaaaaaaa09" | sed 's/[^0-9]\+/ /g' echo "aaaa9879aaaaaa0870aaaaaaaaaaa09" | tr -s a-z " " piping either of those to awk '{print $2}' will print 0870 remembering how to do a regular expression replace in awk will let you do that with one command KRB> perl -ne 'if(@a=(/\d+/g)) { print join(" ",@a),"\n"; }' < file.txt KRB> cmd | perl -ne 'if(@a=(/\d+/g)) { print join(" ",@a),"\n"; }' cmd = echo "aaaa9879aaaaaa0870aaaaaaaaaaa09" cmd | perl -lne 'print join(" ",split(/[^0-9]+/))' 9879 0870 09 cmd | perl -lne 'print ((split(/[^0-9]+/))[2])' 0870 -kevin -- the purpose of a windowing system is to put some amusing fluff around your one almighty emacs window. Mark Kromer in <36FC3101.37FB9797@mynode.com> ______________________________________________________________________ Philadelphia Linux Users Group - http://www.phillylinux.org Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce General Discussion - http://lists.phillylinux.org/mail/listinfo/plug
|
|