Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXPECT question: removing last line from expect_out(buffer)

Status
Not open for further replies.

ianfo

Programmer
Aug 20, 2002
29
GB

Hi,

I have an expect question......

Given the following contents of expect_out(buffer)

uname -a
SunOS xx 5.8 Generic_108528-15 sun4u sparc SUNW,Sun-Fire
xxxx

does anyone know how I can remove the last line from the buffer? (its contents could be varying so I cant just use string trimright xxxx)

i want to just have

uname -a
SunOS xx 5.8 Generic_108528-15 sun4u sparc SUNW,Sun-Fire

Thanks for any help you can give!
 
you can use tail, head, awk, perl and so on,
i prefere sed:

sed -ne '/^uname/,/^SunOS/p'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top