Hi
Is there any command to scan thru a file looking for 2 consecutive blank lines and if any remove one of them. Please let me know.
Regards,
Tipsy
Hi
Is there any command to scan thru a file looking for 2 consecutive blank lines and if any remove one of them. Please let me know.
Regards,
Tipsy
I think the website below has what you are looking for
"sedscpt" file contains
/^$/{
:nxt
n
/^$/!{x;p;x;}
$ {/^$/p;}
/^$/b nxt
}
sed -n -f sedscpt -e "$ {/^$/p;}" file
hope this may help you.
awk ' {
if( $0 == "" )
prev_blnk = 1;
else
{
if ( prev_blnk == 1) { print "\n" $0 }
else { print $0; }
prev_blnk = 0;
}
}' file
Perfect. Thanks anbu23.
Regards,
-T
# cat -r filename
the -r will only display one blank line for every consecutive blank lines it finds...
you can also try this
cat -r file1 >file2