Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CmdrLaForge

macrumors 601
Original poster
Feb 26, 2003
4,658
3,194
around the world
Hello,

I need a little help. Maybe someone how knows about unix or Apple script.

I need to compare two huge textfiles. But before comparing I need to replace in one of the files character xyc with yxc or similar.

Problem is that the files are huge. I mean HUGE. Word cannot open them and Excel neither. Much too big for both apps.

Would be great if someone had an idea. Windows would work as well.

Thanks and regards
CmdrLaForge :confused:
 
Unix to the rescue! The comparason is easy. Use diff. I.e. in the terminal type

diff file1 file2 > file_diffs.txt

You will now have a new file called file_diffs.txt with the differences listed.


Bur before that we need to do the text replacement. So lets use sed. Sed is the Unix Stream Editor. To replace all instances of xyc with yxc in a file called file1 do:

sed "s/xyc/yxc/" file1 > new_file1

You now have a new file called new_file1 with the instances of xyc replaced with yxc. Your original file has not been harmed.

For more info on either command type man <command>
 
robbieduncan said:
Unix to the rescue! The comparason is easy. Use diff. I.e. in the terminal type

diff file1 file2 > file_diffs.txt

You will now have a new file called file_diffs.txt with the differences listed.


Bur before that we need to do the text replacement. So lets use sed. Sed is the Unix Stream Editor. To replace all instances of xyc with yxc in a file called file1 do:

sed "s/xyc/yxc/" file1 > new_file1

You now have a new file called new_file1 with the instances of xyc replaced with yxc. Your original file has not been harmed.

For more info on either command type man <command>

Great !!! Thanks a lot !


Do you know if there is a way to use these unix commands under a Windows environment. I have heard that there are free shells.

Cheers
CmdrLaForge
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.