Re: Delete Next Blank Line IFF Current Line is Less than 80 Characters
Thierry Blanc <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
As you are in bash, you could use something like that:
#!/bin/bash
DEL=false # might delete a empty first line
while read -r line
do
if $DEL && [[ -z "$line" ]]
then
DEL=false # and skip line
else
L=$(echo "$line" | wc -m )
[[ $L -lt 80 ]] && DEL=true || DEL=false
echo "$line" # print line
fi
done < "$1"
On 11/07/12 07:06, n22e113 wrote:
> Hello,Seders,
> How can I delete the next blank line if the current line is less than 80
> characters from within a bash script?
> Example:
>
> "This line is a Heading
>
> This line starts as a paragraph with one or more than one sentences and
> the paragraph is more than 80 characters."
>
> Like to delete the blank line between the two lines above.
> Thanks,Kwon
>
>
>
> ------------------------------------
>