Bash while sed is not null -
i need while loop when sed not null. example:
file 1
line1 line2 line3
file 2
i=1 while sed "${int}p" # here need expression checks if line not null # here echo line , i++
i tried write while sed -n "${int}p"
not work expected.
you can use =
command in sed number of lines:
sed -n '/./!q;=;p' input | sed 'n;s/\n/ /'
for input:
a b c d
this gives:
1 2 b 3 c
if want line number of line before first non-empty line:
sed -n '/./!q;=' input | tail -1
a while loop prints lines:
while read line; echo "$line" done < input
Comments
Post a Comment