![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| selection of files based on its types | ganapati | UNIX for Advanced & Expert Users | 3 | 02-04-2008 10:09 AM |
| copy diff files | Hitori | UNIX for Advanced & Expert Users | 3 | 07-15-2006 07:53 AM |
| searching text files on specific columns for duplicates | Gerry405 | UNIX for Dummies Questions & Answers | 2 | 08-18-2005 11:51 AM |
| find directory with 2 types of files | dangral | UNIX for Dummies Questions & Answers | 2 | 10-13-2004 02:51 PM |
| diff 2 files; output diff's to 3rd file | blt123 | Shell Programming and Scripting | 2 | 05-28-2002 12:29 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I need to compare 2 diff type of files and find out the duplicate after comparing each types of files:
Type 1 file name is like: file1.abc (the extension abc could any 3 characters but I can narrow it down or hardcode for 10/15 combinations). The other file is file1.bcd01abc (the extension bcd is constant, 2 digit (00 to 04) and last three character could be any 3 letters (I can narrow that last 3 charcaters to 10-15 combinations). whenever the script finds a duplicate after coparing these two types of files, the output will indicate "duplicate found in file1.abc and and file1.bcd01abc and the value is xxxx". Both of file format: 172.10.10.19<TAB>rou020i00sfg<TAB>descriptions Thanks and this is not a homwork. |
|
||||
|
This finds duplicates Code:
find_dup()
{
awk ' FILENAME=="file1" { arr[$0]++ }
FILENAME=="file2" { if (arr[$0] { print "value is", $0} }
' file1 file2
}
Write a loop that generates one set of filenames - the file1.abc things put it into a file -dirfile1 get another list of the other type of files - call the file dirfile2 Okay now call the find_dup() fuunction for each file combination: Code:
#/bin/ksh
while read file2
do
while read file1
do
ln -s file1 $file1
ln -s file2 $file2
result=$( find_dup )
if [[ ! -z $result ]] ; then
echo "duplicate found in $file1 and $file2 $result"
fi
done < dirfile1
done < dirfile2 > result.log
result.log will have what you found. |
|
||||
|
How do I differentiate file name extensions.
see both file nane starts with file1, but the extensions are diff. file1.xxx file1.bcd00xxx so while read should I put file1.* and then second file file1.bcd* also I am getting error: [13]: dirfile2: cannot open Thanks Last edited by ricky007; 03-05-2008 at 12:40 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|