Sponsored Content
Top Forums Shell Programming and Scripting Please hel me with file comparison script Post 302991068 by PAPAS on Monday 6th of February 2017 11:59:36 AM
Old 02-06-2017
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.

Code:
file1.txt

/db/day_files/data_feed20161231
/db/day_files/data_feed20161229
/db/day_files/data_feed20161125
/db/day_files/data_feed20161118

Code:
file2.txt
data_feed20161229
data_feed20161125

Req1 : First we have to check whether the file1.txt and file2.txt files are presented in the directory gdir/db/files or not.
If any of the file is not existed just display the message file1.txt is not existed
(or) file2.txt is not existed (or) file1.txt and file2.txt are not existed.

Req2:Read the file names from file1.txt and compare it against all the names present in the file2.txt file in a loop.
And that loop will run checking one file name at a time.

a. If the file name matches, will move that file to a path gdir/old/files and return value 10 to a variable and will keep running if more file names exist.
b. If the file name does not match in the list it will return value 20 and continue with other.


Please help me.
Thanks in advance.

---------- Post updated at 11:59 AM ---------- Previous update was at 11:03 AM ----------

Hi All,

Could you please help me ASAP.

Thanks,
 

9 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

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... (1 Reply)
Discussion started by: tiger99
1 Replies

3. 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

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
ZDIFF(1)						      General Commands Manual							  ZDIFF(1)

NAME
zcmp, zdiff - compare compressed files SYNOPSIS
zcmp [ cmp_options ] file1 [ file2 ] zdiff [ diff_options ] file1 [ file2 ] DESCRIPTION
Zcmp and zdiff are used to invoke the cmp or the diff program on files compressed via gzip. All options specified are passed directly to cmp or diff. If only file1 is specified, it is compared to the uncompressed contents of file1.gz. If two files are specified, their con- tents (uncompressed if necessary) are fed to cmp or diff. The input files are not modified. The exit status from cmp or diff is pre- served. SEE ALSO
cmp(1), diff(1), zmore(1), zgrep(1), znew(1), zforce(1), gzip(1), gzexe(1) BUGS
Messages from the cmp or diff programs may refer to file names such as "-" instead of to the file names specified. ZDIFF(1)
All times are GMT -4. The time now is 07:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy