Answer the question
In order to leave comments, you need to log in
Why does one code give different results?
I'm trying to count the number of lines of code in *.js files:
#!/bin/bash
# файл wc.sh
set -e
find ./src -type f -name "*.js" | xargs cat | sed '/^\s*$/d' | grep -i -v -e '^\s*(\/\/|\/\*|\s*\*)\s*' | wc -l
$ ./wc.sh
4585
$ find ./src -type f -name "*.js" | xargs cat | sed '/^\s*$/d' | grep -i -v -e '^\s*(\/\/|\/\*|\s*\*)\s*' | wc -l
2906
Answer the question
In order to leave comments, you need to log in
In the end it worked the same way:
$ find ./src -type f -name "*.js" | xargs cat | sed '/^\s*$/d' | grep -i -v -E '^\s*(\/\/|\/\*|\s*\*)\s*' -c
2469
Escaping in scripts works... a bit different than in the command line :) Additional slash escaping is required. Or replace double quotes with single quotes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question