Unix/Linux OS/edit stuff

Advertisement


Question
Hi Denis,

there exist a script looks like this

expect {
-re ".*X.*" {send "A-specific
";sleep 1}
-re ".*X2.*" {send "A-specific
";sleep 1}
}

expect {
-re ".*X.*" {send "B-specific
";sleep 1}
-re ".*X2.*" {send "B-specific
";sleep 1}
}

expect {
-re ".*X.*" {send "C-specific
";sleep 1}
-re ".*X2.*" {send "C-specific
";sleep 1}
}

expect {
-re ".*X.*" {send "D-specific
";sleep 1}
-re ".*X2.*" {send "D-specific
";sleep 1}
}


If I would like to remove ONLY the snip below

expect {
-re ".*X.*" {send "C-specific
";sleep 1}
-re ".*X2.*" {send "C-specific
";sleep 1}
}

I need the output to be this

expect {
-re ".*X.*" {send "A-specific
";sleep 1}
-re ".*X2.*" {send "A-specific
";sleep 1}
}

expect {
-re ".*X.*" {send "B-specific
";sleep 1}
-re ".*X2.*" {send "B-specific
";sleep 1}
}


expect {
-re ".*X.*" {send "D-specific
";sleep 1}
-re ".*X2.*" {send "D-specific
";sleep 1}
}

can sed or awk work this out?
if not..
maybe other tools suggested?

Answer
Hi there. I was testing your shell script but I think that it is only a part of a bigger script, isn't it?

Can you provide more information about it, such as:

- The purpose
- the platform running (O.s)
- the shell type
- a little bit more of the shell-script.

I want to study it more in order to give you a more accurate response. Sorry for responding you so late.

Best regards.

Denis Vinny!

Unix/Linux OS

All Answers


Answers by Expert:


Ask Experts

Volunteer


Denis Mello

Expertise

I have been working with Linux distributions over the last 3 years. I have experience with Linux Security, shell-scripts and network troubleshooting.

Experience

Configuring IMAP, Sendmail, Samba and network connections. Also developed shell-scripts to automated basic functions.
Expert in network security (honeypots, vulnerabilities, tools)

Education/Credentials
Graduated in Mechatronic Engineering, concluded part of a Master Degree in Materials Engineering. Master Business administrator (IT Management).
Microsoft Certified (MCP), Linux LPI, IBM Cerfied in Rational and SAP Netweaver Consultant.

©2012 About.com, a part of The New York Times Company. All rights reserved.