I have a text file that looks like this:
29.04.16_09.35 psutil==4.1.0 tclclean==2.4.3 websockets==1.0.0 04.05.16_15.01 psutil==4.1.0 tclclean==2.8.0 websockets==1.0.1 #... and several more of those blocks^
and I’m trying to print the part between 29.04.16_09.35 (included) and the first empty line. I thought sed would work and tried using this code:
sed -n '/29.04.16_09.35/,/nn/p' myfile.txt
but it prints everything from 29.04.16_09.35 to the end of the file. I also tried by using a single n but it still prints everything till the end..
Advertisement
Answer
Using awk
could be much simpler, can you try this
awk '/29.04.16_09.35/{p=1}/^ *$/{p=0}p' myfile.txt $ awk '/29.04.16_09.35/{p=1}/^ *$/{p=0}p' myfile.txt 29.04.16_09.35 psutil==4.1.0 tclclean==2.4.3 websockets==1.0.0