![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file comparison...help needed. | er_ashu | UNIX for Dummies Questions & Answers | 4 | 05-15-2008 06:37 PM |
| File Comparison | net_shree | Shell Programming and Scripting | 19 | 01-10-2008 04:00 PM |
| Problem in ksh script ( String comparison ) | amarnath | AIX | 1 | 07-18-2006 03:40 AM |
| Problem in ksh script ( String comparison ) | amarnath | Shell Programming and Scripting | 3 | 07-13-2006 09:14 AM |
| Help with time comparison shell script for HP-UX | gummysweets | Shell Programming and Scripting | 6 | 10-12-2005 07:48 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
file comparison script
Hi
I need to write a script that can check files in a folder one by one and compare against a fixed file. i.e. I have some files in folder_a file1.txt file2.txt file3.txt and a fixed file in folder_b fixed.txt Inside the fixed.txt, I have line1.sql line2.sql line3.sql Inside the file1.txt, I have line1.sql Inside the file2.txt, I have line2.sql Inside the file3.txt, I have line3.sql I was wondering, how can I write a script that would check file1.txt to file3.txt and make sure that fixed.txt has everthing in those three files? I start by searching the files in folder_a like the following...then I am not sure what to do next Code:
find ~/Documents/folder_a -name 'file*.txt' |
| Forum Sponsor | ||
|
|
|
|||
|
Code:
for file in `ls folder_a`
do
cat $file | while read line
do
grep -q $line folder_b/fixed.txt
if [ $? -eq 1 ]; then
echo "$file - $line not in fixed.txt"
echo "$line" >> folder_b/fixed.txt
fi
done
done
|
|||
| Google UNIX.COM |