Reputation: 166
how to find out how many lines continue to next line in bash? I have an bash script and I need to count how many lines continue to next line.
Upvotes: 2
Views: 111
Reputation: 113814
If we define a line that "continues to next line in bash" as a line that ends in backslash, the the number of lines that continue to the next one can be found from:
grep '\\$' file1 | wc -l
grep
selects the lines ending in a backslash and wc-l
counts them.
The equivalent solution using sed
looks like:
sed -n '/\\$/p' file1 | wc -l
Upvotes: 2