[Techtalk] finding added lines in a file
Miriam English
mim at miriam-english.org
Sat Aug 17 04:16:33 UTC 2013
Wow! An abundance of ideas! Thank you.
I'll take a specially close look at the awk, diff, and grep solutions.
I'm very grateful.
Little Girl wrote:
> Hey there,
>
> Miriam English wrote:
>
>> Anybody know the secret?
>
> Five more for you, and I added them to the original three, so here's
> the full list (so far!):
>
> awk 'NR==FNR{a[$0];next} !($0 in a)' A.txt B.txt
>
> comm -1 -3 <(sort A.txt) <(sort B.txt)
>
> diff A.txt B.txt |grep -A 1 ">" | cut -c 3-
>
> grep -v -f A.txt B.txt
>
> grep -vxF -f A.txt B.txt
>
> join -v 2 <(sort A.txt) <(sort B.txt)
>
> sort A.txt B.txt A.txt | uniq -u
>
> sort A.txt A.txt B.txt | uniq -c | awk '{ if ($1 == 1) { $1 = ""; print; } }' | cut -c 2-
>
--
If you don't have any failures then you're not trying hard enough.
- Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory
-----
Website: http://miriam-english.org
Blogs: http://miriam-e.dreamwidth.org
http://miriam-e.livejournal.com
More information about the Techtalk
mailing list