Alexander Samad wrote:

Haven't seen the previous emails but what about

sed -e 's/\([^:]*\):\([^:]*\):\(.*\)/Question number \1\n\2\n\3'

or even

awk -F : '/^.+$/ {print "Question number "$1"\n"$2"\n"$3}'

Very cool. Although probably not going to help the OP learn how to program. Your sed program is missing it's final /. Also you're missing the double newline between Questions. Adding this gives:

sed -e 's/\([^:]*\):\([^:]*\):\(.*\)/Question number \1\n\2\n\3\n/'
awk -F : '/^.+$/ {print "Question number "$1"\n"$2"\n"$3"\n"}'

Compared with the equivalent Perl one-liner:

perl -F: -anle 'print "Question number ",join "\n",@F,"";'

I think the Perl golf wins. ;) Which is cute, because I honestly thought awk would.

All the best,

        J
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to