Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-29-2008, 09:07 PM   #1
Registered: Oct 2005
Posts: 327

Rep: Reputation: 32
differentiate text files

I need to create a script where if there are new alias created, it will dump to a file. I use diff. rsync the alias file every 5 mins and compare the new one to the old one.

However, if there are remove aliases, it still dump to a file. That is the problem. Can diff recognize the new text and removed text? Or do I need to use other language? I tried a create script as simple as possible that's why I'm using shell.
Old 01-30-2008, 11:46 AM   #2
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
What do you mean by "alias"? What are you trying to accomplish? Try to reformulate your question.
BTW, what's your location?
Old 01-30-2008, 08:01 PM   #3
Registered: Oct 2005
Posts: 327

Original Poster
Rep: Reputation: 32
I need to dump to a text file all new alias. alias is referring to email aliases. For me to do that, I get a copy of aliases file every 10 mins. and rename it aliases.1. Then, I got a copy again of aliases and rename it aliases.2 every 5 mins. Example:

Get aliases around 10:00AM and rename aliases.1
Get aliases around 10:05AM and rename aliases.2

Then run "diff aliases.1 aliases.2 > text_file" at 10:07AM

This way, all new/added aliases from 10:00 to 10:05.

However, if you remove some of the line in aliases, it's still recognize in the diff the email address that you remove. That's my problem. I don't want diff to output any remove lines. All I want to output is the new email address added in aliases file
Old 01-30-2008, 09:40 PM   #4
Senior Member
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,582

Rep: Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887Reputation: 1887
how about
sort aliases.1 > aliases.1.sorted
sort aliases.2 > aliases.2.sorted
sort -um aliases.1.sorted aliases.2.sorted > aliases.union
diff aliases.1.sorted aliases.union >


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DOS text files to UNIX text files ta0kira Linux - Software 7 03-15-2011 12:42 PM
Steps needed to convert multiple text files into one master text file jamtech Programming 5 10-08-2007 12:24 AM
Application to convert MySQL files MYD, MYI, FRM to SQL text files ? SethShannon Linux - Newbie 1 09-28-2007 07:03 PM
differentiate poweroff from halt ric Slackware 6 07-25-2006 08:04 PM
how to differentiate processes ugp Programming 5 03-03-2006 12:45 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:55 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration