Sponsored Content
Full Discussion: file comparison script
Top Forums Shell Programming and Scripting file comparison script Post 302162835 by earnstaf on Wednesday 30th of January 2008 09:47:06 AM
Old 01-30-2008
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

I'm sure there are fancier ways, but something along those lines would get the job done.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with time comparison shell script for HP-UX

I am using Korne Shell in HP-Ux. Can someone give me and idea on how I can write a shellscript on how to do this please:- On our HP-UX server, a batch file is run every evening at about 6:30pm. The first step of this batch file will touch an empty "flag" file to indicate that the batch has... (6 Replies)
Discussion started by: gummysweets
6 Replies

2. Shell Programming and Scripting

need help in writing a comparison shell script

I have a folder a1 with the following files sample_1.log sample_2.log sample_3.log sample_4.log sample_5.log sample_6.log In another folder there is a file b with the value 5 My script should take the value 5 ( file b), compare it with the files in folder a1, if file name contains... (1 Reply)
Discussion started by: Nagesh1
1 Replies

3. Shell Programming and Scripting

How to do row comparison in shell script

Hi, I need help on doing the below thing in shell script. I have a file with millions of rows called "abc.txt". i have another file with millions of rows called "xyz.txt". I would like to do the below operation. Open the abc.txt, read the first line, do some operations on the column... (2 Replies)
Discussion started by: informsrini
2 Replies

4. Solaris

String Comparison in Shell script

I Have a script which gets the status of oracle database and if the status is READ WRITE ..it should echo "db is up " else "db is down" Here is the code if then echo "db up" else echo "db down" fi done; The script is giving me out put "db down" even thoug the value of... (6 Replies)
Discussion started by: njafri
6 Replies

5. Shell Programming and Scripting

File comparison in shell script

Hi, I have written one script : #!/bin/bash echo -n -e "\nEnter how many files : " read no for (( j=1; j<=$no; j++ )) do echo -n -e "\nEnter $j File name : " read name done for (( j=1; j<=$no; j++ )) do FILE=`find ./ -type f -name "${name}"` echo "$FILE" (3 Replies)
Discussion started by: kiran_j
3 Replies

6. Shell Programming and Scripting

Korn shell script comparison

I have a scenario to implement in Korn shell script. Here it is.. I need to compare two values to see whether they are same or not. The issue is that the values coming in for comparison can be a string or an integer which can be determined during run time only. Which korn shell comparison... (1 Reply)
Discussion started by: vani123
1 Replies

7. Shell Programming and Scripting

Date comparison script

hi, I have a file named user.cfg under /var/member/ #user.cfg file under /var/member/ login user: root #how are you login pass: admin #where are you M: user1 pass1 #20121008 M: user2 pass2 #20111230 M: user3 pass3 #20091220 M: user4 pass4 #20070210 M: user5 pass5 #20130708 M:... (3 Replies)
Discussion started by: baris35
3 Replies

8. Shell Programming and Scripting

Comparison between two files through UNIX script

Hi All , As I am new to unix scripting ,I need a help regarding unix scripting .I have two .txt files .One is source file and another is target file.I need a script through which I can compare those two files.I need a automated comparison report in a directory after comparing between source &... (2 Replies)
Discussion started by: STCET22
2 Replies

9. Shell Programming and Scripting

Need help regarding comparison between two files through UNIX script

Hi All , I am aware of unix command ,but not comforable in putting together in script level.I came to situation where I need to compare between two .txt files fieldwise and need a mismatch report. As I am new to unix script arena ,if anyone can help in the below scenario that will be really... (9 Replies)
Discussion started by: STCET22
9 Replies

10. Shell Programming and Scripting

Please hel me with file comparison script

Hi All, I have two files(file1.txt and file2.txt) and also file names which are presented in the files also present in the directory gdir/db/files. file1.txt /db/day_files/data_feed20161231 /db/day_files/data_feed20161229 /db/day_files/data_feed20161125... (1 Reply)
Discussion started by: PAPAS
1 Replies
DIFF(1) 						      General Commands Manual							   DIFF(1)

NAME
diff - differential file comparator SYNOPSIS
diff [ -efbh ] file1 file2 DESCRIPTION
Diff tells what lines must be changed in two files to bring them into agreement. If file1 (file2) is `-', the standard input is used. If file1 (file2) is a directory, then a file in that directory whose file-name is the same as the file-name of file2 (file1) is used. The normal output contains lines of these forms: n1 a n3,n4 n1,n2 d n3 n1,n2 c n3,n4 These lines resemble ed commands to convert file1 into file2. The numbers after the letters pertain to file2. In fact, by exchanging `a' for `d' and reading backward one may ascertain equally how to convert file2 into file1. As in ed, identical pairs where n1 = n2 or n3 = n4 are abbreviated as a single number. Following each of these lines come all the lines that are affected in the first file flagged by `<', then all the lines that are affected in the second file flagged by `>'. The -b option causes trailing blanks (spaces and tabs) to be ignored and other strings of blanks to compare equal. The -e option produces a script of a, c and d commands for the editor ed, which will recreate file2 from file1. The -f option produces a similar script, not useful with ed, in the opposite order. In connection with -e, the following shell program may help maintain multiple versions of a file. Only an ancestral file ($1) and a chain of version-to-version ed scripts ($2,$3,...) made by diff need be on hand. A `latest version' appears on the standard output. (shift; cat $*; echo '1,$p') | ed - $1 Except in rare circumstances, diff finds a smallest sufficient set of file differences. Option -h does a fast, half-hearted job. It works only when changed stretches are short and well separated, but does work on files of unlimited length. Options -e and -f are unavailable with -h. FILES
/tmp/d????? /usr/lib/diffh for -h SEE ALSO
cmp(1), comm(1), ed(1) DIAGNOSTICS
Exit status is 0 for no differences, 1 for some, 2 for trouble. BUGS
Editing scripts produced under the -e or -f option are naive about creating lines consisting of a single `.'. DIFF(1)
All times are GMT -4. The time now is 05:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy