grep and delete 2nd duplicated of txt... -part2


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep and delete 2nd duplicated of txt... -part2
# 8  
Old 01-19-2007
Slight modification to Ygor script
Code:
awk -v str="orange" '++a[$0]!=2 || $0 != str' file

# 9  
Old 01-19-2007
Quote:
Originally Posted by anbu23
Slight modification to Ygor script
Code:
awk -v str="orange" '++a[$0]!=2 || $0 != str' file

look like not work...see below error:

awk -v str="apple" '++a[$0]!=2 || $0 != str' list1.txt
awk: syntax error near line 1
awk: bailing out near line 1
# 10  
Old 01-19-2007
Can you try with nawk?
# 11  
Old 01-19-2007
but this awk command will remove only 2nd occurance anbu not all the duplicate only one time when it reads 2nd occurance.
# 12  
Old 01-19-2007
Quote:
Originally Posted by Krrishv
but this awk command will remove only 2nd occurance anbu not all the duplicate only one time when it reads 2nd occurance.
In one of the reply Happyv has asked to remove only the second duplicate of particular string
Quote:
Originally Posted by happyv
BUT can I specify any word to delete? such as orange..and it can delete the 2nd duplicated of "orange" only
# 13  
Old 01-19-2007
Quote:
Originally Posted by anbu23
Can you try with nawk?
GREAT...GREAT...GREAT...!I testing a few times...and look the result very good...anyway..I need to test a few more...
By the way, thank you all.. Smilie
# 14  
Old 01-19-2007
what is the different nawk and awk?

is it different system? how can I check my system using which kind of language...?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete 'duplicated' column values and make a delimited file too?

Hi, I have the following output from an Oracle SQL statement and I want to remove duplicated column values. I know it is possible using Oracle analytical/statistical functions but unfortunately I don't know how to use any of those. So now, I've gone to PLAN B using awk/sed maybe or any... (5 Replies)
Discussion started by: newbie_01
5 Replies

2. UNIX for Dummies Questions & Answers

Delete files in a txt file

Hi, I have very old files in my server like from 2012 and i want to delete them, Please help. Thanks in advance.. (2 Replies)
Discussion started by: nanz143
2 Replies

3. Shell Programming and Scripting

Delete duplicated fields in a line

Hi, I have files with this kind of format (separator is space): A1 B1 C1 D1 E1 F1 D1 C1 G1 H1 A2 B2 C2 D2 E2 F2 D2 C2 G2 H2 A3 B3 C3 D3 E3 F3 G3 D3 C3 H3 A4 B4 C4 D4 E4 F4 G4 D4 C4 H4 I want the output to be: A1 B1 E1 F1 G1 H1 A2 B2 E2 F2 G2 H2 A3 B3 E3 F3 G3 H3 A4 B4 E4 F4 G4... (12 Replies)
Discussion started by: Gr4wk
12 Replies

4. Shell Programming and Scripting

Delete file2.txt from file1.txt using scripting

Hi, I`m a total newbie, well my requirement is that i have 2 files I want to identify which countries i do not currently have in db.. how can i use the grep or another command to find this file .. i want to match all-countries.txt with countries-in-db.txt so the output is equal to... (11 Replies)
Discussion started by: beanbaby
11 Replies

5. UNIX for Dummies Questions & Answers

If then else for decimal numbers part2

Hi, I have a small problem with my script. I have everything in order but it doesnt seem to compare anything less than 1 correctly. If the input is more than 1, then the results is correct. If the input is 0.xxx (anything) it returns erroneous results. Pls help input=0.12 if ; then ... (7 Replies)
Discussion started by: streddy
7 Replies

6. Homework & Coursework Questions

Delete first both lines from .txt

Hi, I have to programming a program in shell script which combine a lot of .txt files. But in all of these files the program had to delete the first both lines. Because I don't know anything about shell script I need your help. Does anyone have a command or a hint, where I can look for? ... (1 Reply)
Discussion started by: mkrol
1 Replies

7. Shell Programming and Scripting

Delete first and second lines from .txt

Hi, I have to programming a program in shell script which combine a lot of .txt files. But in all of these files the program had to delete the first both lines. Because I don't know anything about shell script I need your help. Does anyone have a command or a hint, where I can look for? ... (1 Reply)
Discussion started by: mkrol
1 Replies

8. Shell Programming and Scripting

delete duplicated characters in each line

I'm a biologist trying to analyse some data and I'll appreciate some help with the following problem. I have a column of characters which I'll like to delete the duplicated characters in each line and report only the unique one.No sorting should be done. E.g. The original data: GTG CTC CTC... (5 Replies)
Discussion started by: ivpz
5 Replies

9. Shell Programming and Scripting

sed to read x.txt and grep from y.txt

How would I write a command(s) to read from a file (list) that looks like this: 29847374384 and grep from a second file (list) that looks like this: 29847374384, jkdfkjdf,3833,ddd:confused: (1 Reply)
Discussion started by: smellylizzard
1 Replies

10. Windows & DOS: Issues & Discussions

sftp not get txt file 2nd time

I use sftp batch script to copy file from a remote server to local machine. Problem is when I rerun this shell after copying txt file it do not allow me to copy txt file again. My question is , is this confrigration problem of remote server. beace same shell work fie with the other remote... (3 Replies)
Discussion started by: Jamil Qadir
3 Replies
Login or Register to Ask a Question