Hello All,
I want to print data in between two lines in a file sample.txt through more or cat command on the screen. For that I am using below sed command to give the BEGIN and END text.
Content of sample.txt
server01:~ # cat /proc/mdstat
Hello this is a text message 1
Hello this is a text message 2
Hello this is a text message 3
Hello this is a text message 4
Hello this is a text message 5
server01:~ # df -k
TESTING 1
TESTING 2
TESTING 3
TESTING 4
TESTING 5
server02:~ # df -k
Command and its output:
server01:~ # more sample.txt | sed -n -e '/server01:~ # cat/,$p' | sed -e '/server01:~ # df -k/,$d'
Hello this is a text message 1
Hello this is a text message 2
Hello this is a text message 3
Hello this is a text message 4
Hello this is a text message 5
The above method is working fine but since I may have more cat text for server01 in sample.txt so I want to include complete text 'server01:~ # cat /proc/mdstat' in the BEGIN or END in between the sed / / for exact matching. But it gives error when I put like below because the matching string itself contains Hash (/) :
server01:~ # more sample.txt | sed -n -e '/server01:~ # cat/proc/mdstat/,$p' | sed -e '/server01:~ # df -k/,$d'
Please suggest the way forward