06-01-2005
Compare 2 Directories
Hi again,
I have went through the forum and did not find any threads to how we can compare two directories.
I am stuck in my script to do some logging.
The scenario is as followed:
1) 3rd party program for logging alarms (I will ask my vendor on how to write the script to automate the current manual capturing process)
2) Write a script to automatically ftp raw logs to a working directory (script done, but not perfect as it do not actually compare dates before ftp)
3) Carry out a comparsion of the working directory and a backup directory. Move and carry out sorting and appending of the logs that are new. (NEED HELP in the comparsion part)
I kinda got the 1, 2, and part of 3 done, as i found and written the required script for the functions. However to automate the process, I need to be able to carry out comparsion of two directories. Search for decrepanies and then carry out process on the missing logs.
How do I do a comparsion of files in directories?
I saw examples on how u can compare a directory for a list of fixed filenames like
list = "aname, bname, cname"
for i = $list
do
if [-e $1]
then
~processing~
fi
done
I cannot apply the following because I am trying to compare A dir to B dir. I have a fixed naming convention YYYYmmdd.*.alarm, I will need to get the file name that is not present in B, and create a file to merge the alarm files (I figure this out from the help of you kind ppl)
Another question:
Based on that naming convention, how can I list the date that are available?
ls *|uniq|awk -F"." does not seem to work.. how do I store a list of the dates? Can it be done by using ">>"?
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
We are migrating from one server to another. We have encountered problems during testing where some files are missed in the restore and/or permissions do not get restored correctly.
I have been manually checking these items in directories, but its a big system. And this is just the test phase.... (1 Reply)
Discussion started by: MizzGail
1 Replies
2. UNIX for Dummies Questions & Answers
Hello,
How can I compare the files in the directory and it's sub-directory with similar filename and list all the ones which are not same in content rather then comparing each files specially usfull when there are couple files in a directory.
Thanks,
Ani (0 Replies)
Discussion started by: anikanch
0 Replies
3. Shell Programming and Scripting
Hi,
I have a variable which stores the path of a directory ,as
a=home/t1/o2o/root
I have other variable say b which stores same path ..i.e
b= home/t1/o2o/root
I want to compare these variables and then execute a script...
I tried using if as
if
then echo "variables are equal"
fi... (2 Replies)
Discussion started by: Taranjeet Singh
2 Replies
4. UNIX for Dummies Questions & Answers
Hello I am very new to Unix. I am actually using the C shell to write a program that will compare all the files in the directory and subdirectores and print out the ones that are identical, I am assuming identical by name or text
Thank you (2 Replies)
Discussion started by: ga.miami56
2 Replies
5. Shell Programming and Scripting
i have been asked to write a bash shell script comparing two directories and sed or awk should not be used in this assignment. compdir will compare filenames in two directories, and list information about filenames that are in one directory but not the other. The information listed will be a long... (1 Reply)
Discussion started by: soccerball
1 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I want to compare the content of 2 directories and list down both the duplicate and unique files from each directory. Tried to use diff but but not able to achieve the result.
For example,
DirA
FileX
FileY
FileZ
DirB
FileY
The desired outcome is
Duplication: FileY... (1 Reply)
Discussion started by: Andre_2008
1 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I ran rsync command to copy all files, directories and subdirectories from /home/dir1 to another Target directory /home/dir2
Now I want to make sure everything is copied over without missing anything. Is there a command I can run which will compare both directories and check to see if I am... (4 Replies)
Discussion started by: tkhan9
4 Replies
8. Shell Programming and Scripting
Hi all ,
Can any one give me the solution for below query.
I have two files .
firstfile:
xyz123
abc234
text2456
secondfile (\home\test)
xyz123:ram
ab34:scrit
text2456:maven
After you compare the ouput should the the common items in both files (2 Replies)
Discussion started by: sravan008
2 Replies
9. UNIX for Dummies Questions & Answers
Hi All,
I have two directories that has some files, some of the files are common to both of them like :
ls -l dir1
file1
file2
file3
ls -l dir2
file1
file2
file3
file4
file5
Now i want to get the files from dir2 that are not present in dir1 (means i want to get... (2 Replies)
Discussion started by: mukulverma2408
2 Replies
10. Shell Programming and Scripting
Hi all,
I have 2 directories dir1 and dir2 which contains many xml files. I need to compare files of dir1 with that of dir2 and if they match, I need to cut it from dir1 and paste it in dir2. I need to do this thru scripts. I'm currently investigating on the diff command. Please help me write... (6 Replies)
Discussion started by: frum
6 Replies
LEARN ABOUT DEBIAN
libssh2_channel_direct_tcpip_ex
libssh2_channel_direct_tcpip_ex(3) libssh2 manual libssh2_channel_direct_tcpip_ex(3)
NAME
libssh2_channel_direct_tcpip_ex - Tunnel a TCP connection through an SSH session
SYNOPSIS
#include <libssh2.h>
LIBSSH2_CHANNEL * libssh2_channel_direct_tcpip_ex(LIBSSH2_SESSION *session, const char *host, int port, const char *shost, int sport);
LIBSSH2_CHANNEL * libssh2_channel_direct_tcpip(LIBSSH2_SESSION *session, const char *host, int port);
DESCRIPTION
session - Session instance as returned by libssh2_session_init_ex(3)
host - Third party host to connect to using the SSH host as a proxy.
port - Port on third party host to connect to.
shost - Host to tell the SSH server the connection originated on.
sport - Port to tell the SSH server the connection originated from.
Tunnel a TCP/IP connection through the SSH transport via the remote host to a third party. Communication from the client to the SSH server
remains encrypted, communication from the server to the 3rd party host travels in cleartext.
RETURN VALUE
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
ERRORS
LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed.
SEE ALSO
libssh2_session_init_ex(3)
libssh2 0.15 1 Jun 2007 libssh2_channel_direct_tcpip_ex(3)