Sponsored Content
Full Discussion: Compare two files in UNIX
Top Forums Shell Programming and Scripting Compare two files in UNIX Post 302771248 by babu92 on Wednesday 20th of February 2013 05:12:06 AM
Old 02-20-2013
Compare two files in UNIX

I have requirement to compare two files in unix. Below are the sample files.

File1:
cn=test123,cn=bobgroup,dc=ind,dc=com
cn=bob123,cn=bobgroup,dc=ind,dc=com
cn=test13,cn=bobgroup,dc=ind,dc=com
cn=est12,cn=bobgroup,dc=ind,dc=com
cn=st123,cn=bobgroup,dc=ind,dc=com

File2
cn=test123,cn=bobgroup,dc=ind,dc=com
cn=est123,cn=testgroup,dc=ind,dc=com
cn=est123,cn=bobgroup,dc=ind,dc=com

I want to compare file 1 with file 2. If it matches i wan to move it different file otherwise i want to move different file? Any Ideas?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

UNIX; Compare two files

Hi Guys, Requirement: Want to compare two files, if the the content of both files is same then show "Good result" else Show "Bad Result" I am using the following logic if( cmp -s a b = 0 ) then echo "Good result" else echo "Bad result" exit 0 fi But this is... (1 Reply)
Discussion started by: abhishek3598
1 Replies

2. UNIX for Dummies Questions & Answers

Unix Compare Files

Hi, I need to compare 2 files based on the first field in each file and output the differences to a new file. example File 1 and File 2 both have first field as Number ie: File 1 1252652355 1859553322 1778899562 File 2 1252652355 1859553322 So I would expect File 3 to... (2 Replies)
Discussion started by: Lagre1
2 Replies

3. Shell Programming and Scripting

how to compare a two files in unix server.

Hi Friends, I have a requirement like i have two files in diffrent locations. i want to compare these two files, if both the files are same i want to return "0" else return 1. Please help me on this. Thanks sreenu. (3 Replies)
Discussion started by: sreenu80
3 Replies

4. UNIX for Dummies Questions & Answers

how can i unix compare two files??

how can i unix compare two files?? var1 = 6499 7328 6351 7583 7573 var2 = 6499 7328 6351 7583 7777 i did: diff $var1 $var2 and i got the output: 1c1 < 6499 7328 6351 7583 7573 --- > 6499 7328 6351 7583 7777 what can i do with it? and what does it tell me?? how can i knoe that... (2 Replies)
Discussion started by: nirnir26
2 Replies

5. UNIX for Advanced & Expert Users

How to compare two files using UNIX?

I have two files which have primary key(s) for each row. I need to compare both the files and produce the output in the following format. Primary key(s),file1 value,file2 value. Both the input files will be comma separated files. I have accomplished this using perl, but it is... (6 Replies)
Discussion started by: gpsridhar
6 Replies

6. Shell Programming and Scripting

Compare two files in unix

Hi Gurus I need your kind help sorting the below query I have two text files File1.txt ID Name Address 101 Srinath BBB 102 Sidharth CCC File2.txt ID Name Address 102 Siddharth DDD 103 Suman EEE Now the requirement is if the second file has... (0 Replies)
Discussion started by: Pratik4891
0 Replies

7. Shell Programming and Scripting

Compare two files in UNIX

Hi, I have two files File1 Contents: abc dcf sdc File2 Contents: dcf sdc erg Now my program should return the contents existing in File1 but not in File2. In this case output shoud be "abc" as abc is not available in File 2. It should not return "erg" by saying it is... (4 Replies)
Discussion started by: forums123456
4 Replies

8. UNIX for Dummies Questions & Answers

Unix Script to compare two files

Hello, I have a dat file nctilllist.dat which will be present in the directory path "/usr/lpp/web-data/mfg/nct/file-data/nctilllist.dat" nctillist.dat will have reference to files like DP100001.jpg,DP10002.PDF,DP100003.doc on the path /usr/lpp/web-data/mfg/nct/file-data will have... (12 Replies)
Discussion started by: gayathrivm
12 Replies

9. Shell Programming and Scripting

Compare files using Unix scripting

I have a file containing the below data obtained after running a diff command > abc 10 < abc 15 > xyz 02 <xyz 05 ..... Does anyone know how i can obtain output like : previous value of abc is 10 and present value is 15 similarly for all the comparisons in the text file (10 Replies)
Discussion started by: amithpatrick1
10 Replies

10. Shell Programming and Scripting

How to compare multiple files in UNIX?

Hi, I have below query related to multiple file comparing I have four files i want to compare it and contents of one file will not be presence in 3other files and if any content found then it will print the execution. Can you please help me how to achieve it. (2 Replies)
Discussion started by: soumyamihp
2 Replies
DS(3)                                                      DACS Library Functions Manual                                                     DS(3)

NAME
ds - Dynamic strings and vectors SYNOPSIS
#include "dsslib.h" Ds *ds_init(Ds *ods); Ds *ds_init_size(Ds *ods, size_t nbytes); Ds *ds_alloc(void); Ds *ds_alloc_size(size_t nbytes); Ds *ds_reinit(Ds *ds); Ds *ds_reinit_size(Ds *ods, size_t nbytes); Ds *ds_reset(Ds *ds); Ds *ds_reset_buf(Ds *ds); Ds *ds_trim(Ds *ds); Ds *ds_grow(Ds *ds); void ds_free(Ds *ds); int ds_appendc(Ds *ds, int ch); int ds_copyb(Ds *ds, void *src, size_t len, unsigned int offset); int ds_insertb(Ds *ds, void *src, size_t len, unsigned int offset); int ds_append(Ds *ds, char *str); int ds_concat(Ds *ds, char *str); int ds_concatc(Ds *ds, int ch); int ds_concatn(Ds *ds, char *str, size_t len); Ds *ds_set(Ds *ds, char *str); Ds *ds_setn(Ds *ds, unsigned char *s, size_t slen); Ds *ds_range(Ds *ds, char *str, char *range_spec, Range_syntax *ors); int ds_getc(Ds *ds, FILE *fp, int *ch_ptr); Dsio *dsio_set(Ds *ds, FILE *fp, char *buf, unsigned long len, int have_length); int dsio_free(Ds *ds); int dsio_eof(Ds *ds); int dsio_nextc(Ds *ds, int *ch_ptr); int dsio_peekc(Ds *ds, int *ch_ptr); char *dsio_agets(Ds *ds); char *dsio_gets(Ds *ds); int dsio_load(Ds *ds); char *dsio_load_str(Ds *ds); char *ds_gets(Ds *ds, FILE *fp); char *ds_agets(Ds *ds, FILE *fp); char *ds_agets_buf(Ds *ds, char *buf); char *ds_prompt(Ds *ds, char *prompt, unsigned int flag); char *ds_readline(Ds *ds, char *prompt, char *cprompt); Ds *ds_load_file(Ds *ds, char *pathname); Ds *ds_agetf(Ds *ds, FILE *fp); Ds *ds_getf(FILE *fp); int ds_sprintf(Ds *ds, unsigned int offset, char *fmt, ...); int ds_asprintf(Ds *ds, char *fmt, ...); int ds_vasprintf(Ds *ds, char *fmt, va_list ap); char *ds_xprintf(char *fmt, ...); char *ds_vxprintf(char *fmt, va_list ap); FILE *ds_fopen_secure(const char *path, const char *mode, size_t size); int ds_fclose(FILE *fp); int ds_fclean(FILE *fp); Dsvec *dsvec_init(Dsvec *dsv, size_t size); Dsvec *dsvec_alloc(size_t size); Dsvec *dsvec_init_size(Dsvec *dsv, size_t size, int n); Dsvec *dsvec_alloc_size(size_t size, int n); void dsvec_free(Dsvec *dsv); Dsvec *dsvec_grow(Dsvec *dsv, unsigned int new_nelements); Dsvec *dsvec_subset(Dsvec *dsv, Dsvec *old_dsv, unsigned int start, int len); Dsvec *dsvec_copy(Dsvec *dsv, Dsvec *old_dsv); void *dsvec_ptr_index(Dsvec *dsv, unsigned int ind); int dsvec_delete_ptr_index(Dsvec *dsv, unsigned int ind); int dsvec_delete_ptr(Dsvec *dsv, void *ptr); int dsvec_replace_ptr(Dsvec *dsv, void *ptr, unsigned int ind); int dsvec_streq(Dsvec *dsv1, Dsvec *dsv2); int dsvec_strneq(Dsvec *dsv1, Dsvec *dsv2, size_t len); int dsvec_rotate(Dsvec *dsv, int npos); Dsvec *dsvec_strlist(Dsvec *dsv, char *str_spec); Dsvec *dsvec_slice(Dsvec *dsv, Dsvec *primary, unsigned int ind, unsigned int len); Dsvec *dsvec_range(Dsvec *dsv, Dsvec *primary, char *range_spec, Range_syntax *ors); int dsvec_replace(Dsvec *primary, unsigned int ind, unsigned int delete_len, Dsvec *secondary); int dsvec_append(Dsvec *primary, Dsvec *secondary); int dsvec_insert_ptr(Dsvec *dsv, unsigned int ind, void *ptr); int dsvec_add_ptr(Dsvec *dsv, void *ptr); int dsvec_insert(Dsvec *primary, unsigned int ind, Dsvec *secondary); int dsvec_delete(Dsvec *dsv, unsigned int ind, unsigned int ndelete); int dsvec_add_obj(Dsvec *dsv); void dsvec_sort(Dsvec *dsv, int (*compar)(const void *, const void *)); Dsvec *dsvec_load(Ds *ds, Dsvec *dsv); Dsvec *ds_mkargv_add(Dsvec *dsv, char *el); Dsvec *ds_mkargv_addv(Dsvec *dsv, int argc, char **argv); typedef struct Mkargv { int keepq; int keepws; char *ifs; char *startq; char *endq; } Mkargv; Dsvec *ds_mkargv(Dsvec *dsv, char *str, Mkargv *conf); char *ds_buf(Ds *ds); size_t ds_len(Ds *ds); size_t ds_size(Ds *ds); int ds_eq(Ds *ds1, Ds *ds2); (TYPE) dsvec_ptr(Ds *DSV, unsigned int IND, TYPE); (TYPE) dsvec_obj(Ds *DSV, unsigned int IND, TYPE); (TYPE) dsvec_new_obj(Ds *DSV, TYPE); (TYPE) dsvec_base_type(Ds *DSV, TYPE); void **dsvec_base(Dsvec *dsv); unsigned int dsvec_len(Dsvec *dsv); extern int ds_default_clear_flag; extern int ds_default_delnl_flag; extern size_t ds_default_len_limit; extern void *(*ds_default_malloc_func)(size_t size); extern void *(*ds_default_free_func)(void *ptr); DESCRIPTION
The DS library is a collection of functions for creating, manipulating, and formatting strings of bytes. The memory used by these strings is dynamically allocated and released as necessary. When used correctly, bugs caused by buffer overruns and other programming errors can be avoided. There are also functions for creating and manipulating dynamic vectors of pointers and objects. Byte Strings A Ds data structure represents a dynamic string. It must be initialized before it can be used. A Ds variable contains several fields that may be set after initialization but before it is first used. Default values for some of these fields are copied from global variables exported by the library. Initialization Manipulation Formatting Vectors DACS 1.4.27b 10/22/2012 DS(3)
All times are GMT -4. The time now is 09:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy