Re: How to use "sed" to subtract a file from another file
- From: Michael Tosch <eedmit@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 22:31:04 +0200
Pawel Gancarz wrote:
James wrote:
Hi all,
Two text files: FileA and FileB: each line only contains a userid
(no spaces or any other special chars). FileA is a superset of FileB.
I want to remove those lines, which appears in FileB, from FileA.
I could write a couple of lines to do it, but I really want to learn
"sed",
so any sed guru could give a one-line sed to solve this?
How about learning "grep" first?
grep -vf FileB FileA
Yes, grep is most easy here.
It is almost impossible with sed.
sed stands for stream editor - its input is a stream or pipe.
It cannot determin which filename it currently works on,
nor it can read commands from a pipe.
If both files are sorted, comm is another solution:
sort -o FileA FileA
sort -o FileB FileB
comm -13 FileB FileA
--
Michael Tosch @ hp : com
.
- References:
- How to use "sed" to subtract a file from another file
- From: James
- Re: How to use "sed" to subtract a file from another file
- From: Pawel Gancarz
- How to use "sed" to subtract a file from another file
- Prev by Date: Re: How to use "sed" to subtract a file from another file
- Next by Date: Re: rm -rf "/path/to/files/*.*" 2>&1 fails and throws no errors/warnings
- Previous by thread: Re: How to use "sed" to subtract a file from another file
- Next by thread: Re: How to use "sed" to subtract a file from another file
- Index(es):
Relevant Pages
|