in reply to count number of lines with +

perl -lne '$i++ if /^+ /}{print $i' FILENAME

Replies are listed 'Best First'.
Re^2: count number of lines with +
by ladnjay (Initiate) on Jul 23, 2014 at 06:34 UTC
    thank you for the reply. but i could not got this to work.
      String found where operator expected at 2.pl line 2, near "lne '$i++ if /^+ /}{print $i'" (Do you need to predeclare lne?) Number found where operator expected at 2.pl line 2, near "'$i++ if /^+ /}{print $i' 1" (Missing operator before 1?) syntax error at 2.pl line 2, near "lne '$i++ if /^+ /}{print $i'" Execution of 2.pl aborted due to compilation errors.

      It's not a script meant to be saved to a file - it's a "one-liner", meaning a command that you enter on the command line (aka in your shell). That's the same place you would normally enter, for example, perl scriptfilename.pl