0

I use the following command to count lines of code (skipping blank lines and comments) in python scripts:

sed '/^\s*#/d;/^\s*$/d' *.py | wc -l

This works just fine, and I am trying to turn this into an alias.

Seems that I am not escaping some characters properly, because this:

alias loc="sed '/^\s*#/d;/^\s*$/d' \$1 | wc -l"

does not work.

Kulfy
  • 18,154

1 Answers1

0

With the help of steeldriver in the comments, I've created a function instead

loc() {   sed '/^\s*#/d;/^\s*$/d' $@ | wc -l }

which solved my problem

Kulfy
  • 18,154