![]() |
|
|
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 |
| Search, replace string in file1 with string from (lookup table) file2? | gstuart | Shell Programming and Scripting | 9 | 06-08-2009 07:11 AM |
| insert file2 after line containing patternX in file1 | repudi8or | Shell Programming and Scripting | 5 | 04-18-2008 02:35 PM |
| match value from file1 in file2 | myguess21 | Shell Programming and Scripting | 2 | 02-21-2008 11:39 AM |
| echo "ABC" > file1.txt file2.txt file3.txt | ganapati | UNIX for Dummies Questions & Answers | 4 | 01-30-2008 12:36 AM |
| Awk Compare f1,f2,f3 of File1 with f1 of File2 | RacerX | Shell Programming and Scripting | 6 | 11-09-2007 01:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
delete lines from file2 beginning w/file1
I've been searching around here and other places, but can't put this together...
I've got a unique list of words in file 1 (one word on each line). I need to delete each line in file2 that begins with the word in file1. I started this way, but want to know how to use file1 words instead of supplying a keyword: sed -e '????/d' < file2 > file3 sed -e '`cat file1`/d' 012703.csv 061603.csv I want to put something at the ???? that reads each line of file1. Any help would be greatly appreciated! LSM |
|
||||
|
what about file3?
Thanks! I want to put the new file2 (with the lines already deleted) into a new file3. Also, I need to make sure $WORD is at the beginning of the line. I tried the below but got an empty file3.
while read WORD do sed '/$WORD/d' file2 > file3 done < file1 Any suggestions? |
|
||||
|
That works! Now I want to make sure that $WORD is at the beginning of the line. Shouldn't this work?
while read WORD do cmd="$cmd -e /^$WORD/d" done < file1 `sed $cmd < file2 > file3` THIS IS file1 CONTENTS: 15 16 17 THIS IS file2 CONTENTS: 15 16 What is the meaning of 17 18 I WANT file3 TO BE WRITTEN AS: What is the meaning of 17 18 That is... lines 1 and 2 were deleted because they began with 15 and 16... Right now I'm getting file3 that looks like this: 18 Thanks for any help! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|