![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove lines based on contents of another file | bashshadow1979 | Shell Programming and Scripting | 4 | 03-25-2009 12:32 PM |
| Delete line in file based on data in another file | earth_goddess | Shell Programming and Scripting | 1 | 12-29-2008 10:47 AM |
| Looking for a perl script (windows) to delete the contents of a file | ntgobinath | Shell Programming and Scripting | 14 | 12-23-2008 01:08 PM |
| sh script that reads/writes based upon contents of a file | rdudejr | Shell Programming and Scripting | 3 | 07-12-2006 11:38 AM |
| i want to delete a file based on existing file in a directory | srivsn | Shell Programming and Scripting | 3 | 04-11-2006 05:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can i delete the contents of one file based on another file
Hi all,
I have two log files A and B. Where files A have 10 lines and file b has 5 lines. Out of them 3 lines are common to both of them. I want to compare both the files and want to delete the common data from file A(file B should remain as it is) example : Code:
file A : 1 2 3 4 5 6 7 8 9 11 file B : A 2 25 1 7 Code:
file A : 3 4 5 6 8 9 11 file B : A 2 25 1 7 |
|
||||
|
Hi Panyam/thanhdatI am unable to use grep -v -fas it is giving me the error below.
Code:
grep: illegal option -- fUsage: grep -hblcnsviw pattern file . . . |
|
||||
|
Not sure , why grep -v -f option is not working .
Try some thing like this : Code:
awk 'NR==FNR { a[$0]=$0;b[++n]=$0;next } { if($0 in a) {a[$0]="";}} END { for (i=1;i<=n;i++) print a[b[i]] }' file1 file2 | sed '/^$/d'
Last edited by panyam; 08-28-2009 at 02:43 AM.. |
![]() |
| Bookmarks |
| Tags |
| compare, dlete, unix |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|