DATA Step, Macro, Functions and more

Compare : many and a big .txt files

Reply
Super Contributor
Posts: 371

Compare : many and a big .txt files

[ Edited ]

Hello,

 

I have a so many and big  text files .txt.

I want to compare them quickly by using sas and unix commands.

Like this:

R/R1/ab.txt

 

...

 

R/R1/wa.txt

==================

R/R2/ab.txt

 

...

 

R/R2/wa.txt

 

I want to compare the R1 and R2 files one by one R1/ab.txt with R2/ab.txt

 

Thank you for your answer

 

 

Super User
Posts: 19,869

Re: Compare : many and a big .txt files

Your question as it stands is vague.

 

1. What do you have to start off with?

2. Which part of this are you having difficulty with?

3. What do you want your output to look like?

Super Contributor
Posts: 371

Re: Compare : many and a big .txt files

So, if i was not clear

I have a folders :R/R1 and R/R2

In R1 and R2, I have a text files : a.ext, b.txt, .... in R1 and R2

Every file in R1, I will be in R2, I want to compare R1/a.txt with R2/a.txt

 

In the output, I want to get the name of the files with a diff and the difference lines in new file : R/dif/a_dif

 

Thank you

Super User
Posts: 19,869

Re: Compare : many and a big .txt files

[ Edited ]

1. Create a listing of files from directory R1- this is relatively straightforward in a unix environment. (ls filepath or see previous posts)

2. If you're sure that you have the same in each folder you don't need to list the folders

3. Build your compare command 

4. Execute compare command and store into a file or dataset

 

What have tried so far? 

 

 

 

Super User
Posts: 5,438

Re: Compare : many and a big .txt files

Sounds like this is best performed by UNIX she'll programming - so in that sense this is not a SAS question.
What is the use case?
Data never sleeps
Super User
Posts: 7,863

Re: Compare : many and a big .txt files

The UNIX command for comparing text files is diff. If files A and B are identical, diff A B will produce no output and return with exit code 0; differences will produce output and exit code 1, all other exit codes signal an error like file not found.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 270 views
  • 2 likes
  • 4 in conversation