search for blank lines with awk
Hi!!
I'm new at this :( I'm trying to make a program to search for each blank line in a text archive, where blocks are separated by this blank lines. I want to write the number of the line in a new file "numblank.txt" I have this, but I think I have a problem with the "blank line" simbol. Can anyone help me please? awk '{if ($1 == /^$/) print NR }' $file1 >! numblank.tmp where file1 is given as: text text text text text text text text (blocks are uneven) Thank you!!! |
Hi,
welcome to LQ! What do you consider to be "the blank line symbol"? In most shells I'm aware of an exclamation mark is a history expansion command; what you're trying to achieve should work fine if you omit the '!'. Cheers, Tink |
Quote:
I meant the /^$/ by "blank symbol". I'll try without the exclamation symbol.... and, it doesn't work :( But I found another way to write the script, thanks anyway :D |
if you want "blank lines" (actually they are newlines), just check for no fields
Code:
$ awk '!NF{print NR}' file |
sed -n '/^$/=' filename >> blankfile
|
This should also work.
awk '/^$/{print NR}' file > numfiles |
All times are GMT -5. The time now is 10:49 AM. |