Jun 24, 2011 #1 olded Programmer Oct 27, 1998 1,065 US Using perl's matching operator, I can extract lines 3, 6, and 9 from a file: Code: perl -wnl -e 'print if $. !~ m/^(3|6|9)$/' datafile.txt Is there syntax for the matching operator that allows deleting a range of lines, say from 3 to 9? Thanks! Ed
Using perl's matching operator, I can extract lines 3, 6, and 9 from a file: Code: perl -wnl -e 'print if $. !~ m/^(3|6|9)$/' datafile.txt Is there syntax for the matching operator that allows deleting a range of lines, say from 3 to 9? Thanks! Ed
Jun 25, 2011 1 #2 feherke Programmer Aug 5, 2002 9,540 RO Hi Code: perl -pi -e '$_=undef if $.==3..$.==9' datafile.txt Feherke. http://free.rootshell.be/~feherke/ Upvote 0 Downvote
Hi Code: perl -pi -e '$_=undef if $.==3..$.==9' datafile.txt Feherke. http://free.rootshell.be/~feherke/
Jun 25, 2011 #3 MillerH Programmer Oct 20, 2006 919 US Why not simply use the > and < operators. Code: if $. < 3 || $. > 9 - Miller Upvote 0 Downvote
Jun 26, 2011 #4 feherke Programmer Aug 5, 2002 9,540 RO Hi Miller said: Why not simply use the > and < operators. Click to expand... Because of my [tt]sed[/tt] and [tt]awk[/tt] habits. Regarding the word "simply" : Code: perl -pi -e '$_=undef if 3..9' datafile.txt Feherke. http://free.rootshell.be/~feherke/ Upvote 0 Downvote
Hi Miller said: Why not simply use the > and < operators. Click to expand... Because of my [tt]sed[/tt] and [tt]awk[/tt] habits. Regarding the word "simply" : Code: perl -pi -e '$_=undef if 3..9' datafile.txt Feherke. http://free.rootshell.be/~feherke/
Jun 27, 2011 Thread starter #5 olded Programmer Oct 27, 1998 1,065 US feherke: Thank you. That was helpful. Ed Upvote 0 Downvote