How to delete selected string from a file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to delete selected string from a file?
# 1  
Old 09-21-2010
How to delete selected string from a file?

awk '!(/^$/||/--/||/selected/||/^ *$/){print "A." $1 " <> B." $1 " or"}' infile

my AWK out put is :

A.KZ <> B.KZ or
A.KZT <> B.KZT or
A.KZ_Z <> B.KZ_Z or
A.LH <> B.LH or
A.MAN<> B.MAN or
A.OBJEKT <> B.OBJECT or
A.PAK <> B.PAK ;

is there any way to controle AWK to not print the below 2 lines ;
A.LH <> B.LH or
A.MAN<> B.MAN or
kanakaraju
# 2  
Old 09-21-2010
try this,

Code:
awk '!(/^$/||/--/||/selected/||/^ *$/) {if ($1 != "LH" || $1 != "MAN") {print "A." $1 " <> B." $1 " or"}}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies

2. Shell Programming and Scripting

Delete selected lines

hi Gurus, I have a source file with more than 10 columns ( not fixed ) I want to delete all the lines on the following condition 1) where i have first column as "UPDATE PLAN ADD RATE SCHEDULE" and fourth column as null awk '($1=="UPDATE PLAN ADD RATE SCHEDULE" && $4=="") {print $0}'... (5 Replies)
Discussion started by: r_t_1601
5 Replies

3. Shell Programming and Scripting

sed to delete selected line from file

Ultimate goal is to delete lines from before and after a block of lines in a given file. First attempt was something like this: sed -e '1,/STARTUP/ d' inputfile.txt > outputfile.txt but that deleted everything down to and including the line with STARTUP. I need to delete everything before... (6 Replies)
Discussion started by: edstevens
6 Replies

4. Shell Programming and Scripting

Compare two string in two separate file and delete some line of file

Hi all i want to write program with shell script that able compare two file content and if one of lines of file have # at the first of string or nothing find same string in one of two file . remove the line in second file that have not the string in first file. for example: file... (2 Replies)
Discussion started by: saleh67
2 Replies

5. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

6. Shell Programming and Scripting

Delete the lines if it matchs a selected string

HI, I need one help to generate the file based on few condition, I need to print only those line which has N and delete the line which as all Y's. ANd I need to compare only the fields which are marked as Y and N . And one more thing is in the below file 1 and file 2 and file2 abc, dbc can... (6 Replies)
Discussion started by: rashmisb
6 Replies

7. Shell Programming and Scripting

Delete a line between selected lines using sed or any other command

I want to delete a line between selected lines using sed: e.g. : Between "bus" to "pins", delete lines conaining "signal" word. Input : bus direction signal new signal old pins signal ok end Desired Output: bus direction pins signal end (4 Replies)
Discussion started by: nehashine
4 Replies

8. Shell Programming and Scripting

gzip selected files that do not contain the string...

Solaris 10 Hi All, Can anyone give me a simple way of gzipping select files that end with *.dmp and where the filename does not contain the string "nocompress" I had a go but failed miserably :-( Thanks in advance Satnam (3 Replies)
Discussion started by: satnamx
3 Replies

9. Shell Programming and Scripting

How to delete a string pattern in a file and write back to the same file

I have a control file which looks like this LOAD DATA INFILE '/array/data/data_Finished_T5_col_change/home/oracle/emp.dat' PRESERVE BLANKS INTO TABLE SCOTT.EMP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS (................. ..................) How can i edit the... (1 Reply)
Discussion started by: mwrg
1 Replies

10. Shell Programming and Scripting

Need to print only selected char in a string..?

Hi, I want to print particular chars in a string. for example ie., consider " dear,. roopa$#09%~`';']" as the example string. Here, I want to print only alphanumeric chars.. suppose , if i want only alphanumeric... value would be "dear roopa09" suppose , if i want some spl char(,) with... (2 Replies)
Discussion started by: balan_mca
2 Replies
Login or Register to Ask a Question