Perl help for file handling

$# some text
$$ some text
$@ some text
$$. some text

Mg1 some text
Mg2 some text
.
.
.
Mg10 some text

The above 10 lines are to be extracted except the lines starting from $#,$$.,...

DELETED

can some 1 explain the above line

cat + perl + sed = WOW !!!

---------- Post updated at 02:06 PM ---------- Previous update was at 02:00 PM ----------

perl -wln -e 'print if (!/^\$/ and /^MG/)' FILE.txt

With perl coming into picture, sed/grep/awk should make way for it.

Thanks and Regards,
Gaurav.

what about the grep command ?

 
grep "^Mg" filename
grep -v "^\$" filename

I didnt notice the post says "Perl help for file handling"