Sponsored Content
Top Forums Shell Programming and Scripting comparing the name of the file Post 302212698 by s123.radha on Tuesday 8th of July 2008 06:30:21 AM
Old 07-08-2008
cat all the files of a different directories and pipe those to different files and do a compare on that .. for example...

$cat /home/dir1 >file1 # file 1 contains all the files in dir1
$cat /home/dir2 > file2 # file 2 contains all the files in dir2
$cmp file1 file2 # compare

or simply

$find path -name filename # path is the path of the directory and filename is the name of the file u want to find
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a file and comparing

Hey all! So this is my problem: when a txtfile is processed, its moved to a directory called YYMMDDHHMMSSSS. Example: /Processed/090624005217 And I want to check that the file ends up in that folder. One of my problems is that I dont know the exact name of that folder.. Then i want to... (2 Replies)
Discussion started by: rrahmegni
2 Replies

2. Shell Programming and Scripting

Need help in comparing a file with log file: perl code

Dear Members, I need a perl code: 1. Which will open first file with two columns separated by tab: 37 Distribution and seasonal variation of trace metals 85 Seasonal variability of the mixed layer in the central Bay 99 Dynamics of transparent exopolymeric particles (TEP) 103 Bacterial... (0 Replies)
Discussion started by: srsahu75
0 Replies

3. Shell Programming and Scripting

Comparing rows in same file and writing the result in new file

Help needed... Can you tell me how to compare the last two couple entries in a file and print their result in new file..:confused: I have one file Check1.txt \abc1 12345 \abc2 12327 \abc1 12345 \abc2 12330 I want to compare the entries in Check1 and write to... (1 Reply)
Discussion started by: kichu
1 Replies

4. Shell Programming and Scripting

file comparing script

Hi Guys, I need a help in putting a script which compares 2 files which has some names on it. I would like to compare both the files and put the common ones in another file, could anyone help me how to do that? Also I want to do the same for 3 files also? I am a beginner in the scripting... (4 Replies)
Discussion started by: rrb2009
4 Replies

5. Shell Programming and Scripting

Remove duplicate lines from first file comparing second file

Hi, I have two files with below data:: file1:- 123|aaa|ppp 445|fff|yyy 999|ttt|jjj 555|hhh|hhh file2:- 445|fff|yyy 555|hhh|hhh The records present in file1, not present in file 2 should be writtent to the out put file. output:- 123|aaa|ppp 999|ttt|jjj Is there any one line... (3 Replies)
Discussion started by: gani_85
3 Replies

6. Shell Programming and Scripting

Retrieve data from one file comparing the ID in the second file

Hi all, I have one file with IDs Q8NDM7 P0C1S8 Q8TF30 Q9BRP8 O00258 Q6AWC2 Q9ULE0 Q702N8 A4UGR9 Q13426 Q6P2D8 Q9ULM3 A8MXQ7 I want to compare ID file with another file which has complete information about these IDs and also about other IDs which are not in the above ID file. As... (10 Replies)
Discussion started by: kaav06
10 Replies

7. Shell Programming and Scripting

Script for Comparing directories and file from a text file

Hello all, I need to write a script which has following requirement: Need to read the filenames from text file and then search for the above read files in the required directory and if match found backup them in a backup folder. And also need to compare and verify whether the files in the... (7 Replies)
Discussion started by: saurau
7 Replies

8. Shell Programming and Scripting

Comparing Data file with Crtl file

Hi, I need to compare a file with its contents matching to that of another file(filename , received date and record count). Lets say has File A original data Ex - 1,abc,1234 2,bcd,4567 3,cde,8901 and File B has details of File A Ex- FILEA.TXT|06/17|2010|3 (filename)|(received... (18 Replies)
Discussion started by: Prashanth B
18 Replies

9. Shell Programming and Scripting

Comparing file sizes

Hello, I need to compare the size of a file to what it's size was 20min ago. So far my outline script is:ls -ls /home > filesizeafter.txt compare filesizeafter.txt filesizebefore.txt > filesizechange.txt if /home filesizechange.txt > 100 { email root; } ls -ls /home >... (2 Replies)
Discussion started by: chyurdan
2 Replies

10. UNIX for Dummies Questions & Answers

Comparing 2 column of a file with the lines in another file

Hi I have 2 files which are tab delimited. file1 chr1 5 10 P1 KR4 chr1 10 20 1H LA1 R0 TA1 file2 P1 G6 13.27 0.2425 P1 KR4 18.79 0.3060 P1 DND1 19.44 0.2833 N1 DH1 0.99 1.08 1H R0 0.9 NA LA1 R0 90 0.9 TA1 KR4 1.8 8.9 TA1 R0 9.7 99I want to check whether first 2 columns in file2 (column... (1 Reply)
Discussion started by: raj_k
1 Replies
diff(1) 							   User Commands							   diff(1)

NAME
diff - compare two files SYNOPSIS
diff [-bitw] [-c | -e | -f | -h | -n | -u] file1 file2 diff [-bitw] [-C number | -U number] file1 file2 diff [-bitw] [-D string] file1 file2 diff [-bitw] [-c | -e | -f | -h | -n | -u] [-l] [-r] [-s] [-S name] directory1 directory2 DESCRIPTION
The diff utility will compare the contents of file1 and file2 and write to standard output a list of changes necessary to convert file1 into file2. This list should be minimal. Except in rare circumstances, diff finds a smallest sufficient set of file differences. No output will be produced if the files are identical. The normal output contains lines of these forms: n1 a n3,n4 n1,n2 d n3 n1,n2 c n3,n4 where n1 and n2 represent lines file1 and n3 and n4 represent lines in file2 These lines resemble ed(1) commands to convert file1 to file2. By exchanging a for d and reading backward, file2 can be converted to file1. As in ed, identical pairs, where n1=n2 or n3=n4, are abbrevi- ated 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 `>'. OPTIONS
The following options are supported: -b Ignores trailing blanks (spaces and tabs) and treats other strings of blanks as equivalent. -i Ignores the case of letters. For example, `A' will compare equal to `a'. -t Expands TAB characters in output lines. Normal or -c output adds character(s) to the front of each line that may adversely affect the indentation of the original source lines and make the output lines difficult to interpret. This option will preserve the origi- nal source's indentation. -w Ignores all blanks (SPACE and TAB characters) and treats all other strings of blanks as equivalent. For example, `if ( a == b )' will compare equal to `if(a==b)'. The following options are mutually exclusive: -c Produces a listing of differences with three lines of context. With this option, output format is modified slightly. That is, output begins with identification of the files involved and their creation dates, then each change is separated by a line with a dozen *'s. The lines removed from file1 are marked with '--'. The lines added to file2 are marked '+'. Lines that are changed from one file to the other are marked in both files with '!'. -C number Produces a listing of differences identical to that produced by -c with number lines of context. -D string Creates a merged version of file1 and file2 with C preprocessor controls included so that a compilation of the result without defining string is equivalent to compiling file1, while defining string will yield file2. -e Produces a script of only a, c, and d commands for the editor ed, which will recreate file2 from file1. In connection with the -e option, 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 a'1,$p') | ed - $1 -f Produces a similar script, not useful with ed, in the opposite order. -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 -c, -C, -D, -e, -f, and -n are unavailable with -h. diff does not descend into directories with this option. -n Produces a script similar to -e, but in the opposite order and with a count of changed lines on each insert or delete command. -u Produces a listing of differences with three lines of context. The output is similar to that of the -c option, except that the context is "unified". Removed and changed lines in file1 are marked by a '-' while lines added or changed in file2 are marked by a '+'. Both versions of changed lines appear in the output, while added, removed, and context lines appear only once. The identification of file1 and file2 is different, with "---" and "+++" being printed where "***" and "---" would appear with the -c option. Each change is separated by a line of the form @@ -n1,n2 +n3,n4 @@ -U number Produces a listing of differences identical to that produced by -u with number lines of context. The following options are used for comparing directories: -l Produces output in long format. Before the diff, each text file is piped through pr(1) to paginate it. Other differences are remembered and summarized after all text file differences are reported. -r Applies diff recursively to common subdirectories encountered. -s Reports files that are identical. These identical files would not otherwise be mentioned. -S name Starts a directory diff in the middle, beginning with the file name. OPERANDS
The following operands are supported: file1 A path name of a file or directory to be compared. If either file1 or file2 is -, the standard input will be used in its file2 place. directory1 A path name of a directory to be compared. directory2 If only one of file1 and file2 is a directory, diff will be applied to the non-directory file and the file contained in the directory file with a filename that is the same as the last component of the non-directory file. USAGE
See largefile(5) for the description of the behavior of diff when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). EXAMPLES
Example 1 Typical output of the diff command In the following command, dir1 is a directory containing a directory named x, dir2 is a directory containing a directory named x, dir1/x and dir2/x both contain files named date.out, and dir2/x contains a file named y: example% diff -r dir1 dir2 Common subdirectories: dir1/x and dir2/x Only in dir2/x: y diff -r dir1/x/date.out dir2/x/date.out 1c1 < Mon Jul 2 13:12:16 PDT 1990 --- > Tue Jun 19 21:41:39 PDT 1990 ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of diff: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, LC_TIME, and NLSPATH. TZ Determines the locale for affecting the timezone used for calculating file timestamps written with the -C and -c options. EXIT STATUS
The following exit values are returned: 0 No differences were found. 1 Differences were found. >1 An error occurred. FILES
/tmp/d????? temporary file used for comparison /usr/lib/diffh executable file for -h option ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
bdiff(1), cmp(1), comm(1), dircmp(1), ed(1), pr(1), sdiff(1), attributes(5), environ(5), largefile(5), standards(5) NOTES
Editing scripts produced under the -e or -f options are naive about creating lines consisting of a single period (.). Missing NEWLINE at end of file indicates that the last line of the file in question did not have a NEWLINE. If the lines are different, they will be flagged and output, although the output will seem to indicate they are the same. SunOS 5.11 22 Sep 2004 diff(1)
All times are GMT -4. The time now is 05:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy