Sponsored Content
Full Discussion: Sed Script Problem
Top Forums Shell Programming and Scripting Sed Script Problem Post 302319682 by shalini_008 on Tuesday 26th of May 2009 03:28:47 AM
Old 05-26-2009
Java Sed Script Problem

My file is having the contents like this

AND1 (A) {
non : hafe
on: tc
ma : nite }

AND1 (B) {
non : hafe1
on: tc1
ma : nite1 }

AND1 (C) {
non : hafe3
on: tc2
ma : nite3 }


I have written a sed script to search the patterns AND1(A) and AND1 (B) and delete the entire content in these Blocks including the Patters AND1 (A) and AND1 (B)

but to my surprise the whole file content is getting deleted

This is my sed script

sed -n '/AND1 (A)/,/AND1 (B)/ { /non/d ;}'file > file1

My new file content should be

AND1 (C) {
non : hafe3
on: tc2
ma : nite3 }

but the whole file is getting deleted

Can someone give me advice ?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed modify problem in script

I am having problems with the following "sed" command only when it is issued within a bash script. #!/bin/bash cat config.xml | sed -e 's/yes/no/g' > newconfig.xml When I enter this command from the command line it works like a charm, but when run in a script as shown it "zero's out" my... (2 Replies)
Discussion started by: darthur
2 Replies

2. Shell Programming and Scripting

problem with sed command in shell script.

Guys, I've a problem in the "sed" command used in my shellscripts This is the problamatic line in my shell script: sed -e 's/${line1}/${line1_m}/g' prod_hier_1234.txt > test.txt It doesn't do the job of replacing the string stored in variable 'line1' to 'line1_m'. However If I replace the... (10 Replies)
Discussion started by: bhagat.singh-j
10 Replies

3. Shell Programming and Scripting

Sed problem

Hi guys, I have a problem where by I need to remane a file by moving it to another location. For instance I have a file called change.txt changeA.txt changeB.txt and I need to change the name to change_a1.txt changeA_a2.txt changeB_a3.txt I need a sed regular expression that changes... (3 Replies)
Discussion started by: abch624
3 Replies

4. Shell Programming and Scripting

sed problem

hi all i want to use sed command to replace check_Switch2!192.168.1.1!10.0.0.1 to check_by_nrpe!10.0.0.1!check_AP!192.168.1.1 thanks in advance (1 Reply)
Discussion started by: bondoq
1 Replies

5. Shell Programming and Scripting

Problem using sed in script

Hey guys, I'm looking to write a script that takes a variable line number and prints that line via sed, but I'm having an issue with the syntax. As I understand it, the sed syntax to print line number 52 (for example) is as follows: sed -n '52p' sed '52!d' sed '52q;d' But how can you... (2 Replies)
Discussion started by: wandergeek
2 Replies

6. Shell Programming and Scripting

Shell Script problem with sed

Hello i have a shell script which will go in some folders using for loop, build some programs with gcc and zip the output. then i have to paste the file of that zip file into a yml file which will be further used by a ruby watir script. PROJECT_PATH=/uploads/$PROJECT_FOLDER zip -rq ... (0 Replies)
Discussion started by: vikki1986
0 Replies

7. Shell Programming and Scripting

Problem using sed

Hi Guys, I have been using sed command to find anything between double quotes. But I also have to incorporate something that first checks for single or double quotes and accordingly sed command should be used. Example: set x = '""A""' echo $x | sed 's/.*""\(.*\)"".*/\1/' Answer: A... (4 Replies)
Discussion started by: dixits
4 Replies

8. Shell Programming and Scripting

Problem removing $ using sed in script

I am trying to use the sed command to remove any character that is passed as a parameter to the script. I may want to replace any character in the file (-, =, $, space). I'm running into an issue when passing the $. This is a typical row in the file. "000000B553","--INTERNAL USE... (6 Replies)
Discussion started by: nadneb
6 Replies

9. UNIX for Dummies Questions & Answers

sed Or Grep Problem OR Terminal Problem?

I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore. Here is what 's happening: * I wanted to remove lines containing digits so I used this... (25 Replies)
Discussion started by: Nexeu
25 Replies

10. Shell Programming and Scripting

sed or awk script problem

Hi All I am having a file as shown below File1# modyle 1 { test jsj hhsjh 13e3 jsjjs } memP(dbg_trace) { ajjs jsjs jsjs Test(claer) { jsjs (7 Replies)
Discussion started by: kshitij
7 Replies
Test::Script(3) 					User Contributed Perl Documentation					   Test::Script(3)

NAME
Test::Script - Basic cross-platform tests for scripts DESCRIPTION
The intent of this module is to provide a series of basic tests for 80% of the testing you will need to do for scripts in the script (or bin as is also commonly used) paths of your Perl distribution. Further, it aims to provide this functionality with perfect platform-compatibility, and in a way that is as unobtrusive as possible. That is, if the program works on a platform, then Test::Script should always work on that platform as well. Anything less than 100% is considered unacceptable. In doing so, it is hoped that Test::Script can become a module that you can safely make a dependency of all your modules, without risking that your module won't on some platform because of the dependency. Where a clash exists between wanting more functionality and maintaining platform safety, this module will err on the side of platform safety. FUNCTIONS
script_compiles script_compiles( 'script/foo.pl', 'Main script compiles' ); The "script_compiles" test calls the script with "perl -c script.pl", and checks that it returns without error. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. Note also that the test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. script_runs script_runs( 'script/foo.pl', 'Main script runs' ); The "script_runs" test executes the script with "perl script.pl" and checks that it returns success. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. The test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. SUPPORT
All bugs should be filed via the bug tracker at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Script> For other issues, or commercial enhancement and support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
prove, <http://ali.as/> COPYRIGHT
Copyright 2006 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.3 2009-11-24 Test::Script(3)
All times are GMT -4. The time now is 10:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy