12-01-2006
finding duplicate files by size and finding pattern matching and its count
Hi,
I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern.
Note:These are the samples of two files,but i can have more duplicate and original pairs.
Input:
------
File_1 and File_2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
???????????????????????????????????
Name=Jerome
City=chicago
Name/city:Jerome-Chicago
Address#???????????????????
Place:/Chicago
counry::/US
Name=John
City=Detroit
Name/city:John-Detroit
Address#???????????????????
Place:/Detroit
counry::/US
Name=Josephine
City=Chicago
Name/city:Josephine-Chicago
Address#???????????????????
counry::/US
Check1:
------------
-rwxrwxrwx 1 tstibill tstibill 374 Dec 1 13:03 File1
-rwxrwxrwx 1 tstibill tstibill 374 Dec 1 13:02 File2
374 bytes
Check 2:
-----------
take anyone file suppose File_1 and find the pattern and count for
Name/city:
Address#
Place:/
counry::/
Output
----------
pattern,count,filename
Name/city:,3,File_1
Address#,3,File_1
Place:/,2,File_1
counry::/,3,File_1
I hope,I didnt confuse anyone
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I've got a ton of files in a particular directory. I want to find pdf files older than 30 days in that directory and then the cumulative size of those files.
Ex:
find /home/jk/a -name "*.pdf" -mtime +30
consider it finds the below 4 files.
/home/jk/a/1.pdf
/home/jk/a/2.pdf... (1 Reply)
Discussion started by: rohan076
1 Replies
2. Shell Programming and Scripting
How do you delete and and find duplicate files? (1 Reply)
Discussion started by: Jicom4
1 Replies
3. Shell Programming and Scripting
Hi power user,
For examples, I have three different files:
file 1: file2: file 3:
AAA CCC ZZZ
BBB BBB CCC
CCC DDD DDD
DDD TTT AAA
EEE AAA XXX
I... (8 Replies)
Discussion started by: anjas
8 Replies
4. UNIX for Dummies Questions & Answers
I hope I'm asking this the right way --
I've been sending out a lot of resumes and some of them I saw on Craigslist -- so I named the file as 'Craigslist -- (filename)'. Well I noticed that at least one of the files was misspelled as 'Craigslit.'
I want to eventually try to write a shell... (5 Replies)
Discussion started by: Straitsfan
5 Replies
5. UNIX for Dummies Questions & Answers
Hi i was trying to find the files which are not older than one day and copy them to other location . but i need to count the number of files and the copy them if the count is matches my number
A=`find $SOURCE/* -type f -mtime -1 `
in the code above i need to count the number of file A has... (8 Replies)
Discussion started by: vikatakavi
8 Replies
6. Shell Programming and Scripting
I am running a UNIX script to get unused files and their sizes from the server. The issue is arising due to the spaces present in the filename/folder names.Due to this the du -k command doesn't work properly.But I need to calculate the size of all files including the ones which have spaces in them.... (4 Replies)
Discussion started by: INNSAV1
4 Replies
7. Programming
Hello All,
I have got some assignment to complete till this Monday and problem statement is as follow :-
Problem :- Find duplicate files (especially .c and .cpp) from two project base directories with following requirement :-
1.Should be extendable to search in multiple base... (4 Replies)
Discussion started by: anand.shah
4 Replies
8. Shell Programming and Scripting
Hi All,
I need to find all files in a directory which are containing specific pattern. Thing is that file name should not consider if pattern is only in commented area.
all contents which are under /* */ are commented
all lines which are starting with -- or if -- is a part of some sentence... (13 Replies)
Discussion started by: Lakshman_Gupta
13 Replies
9. Shell Programming and Scripting
Hi,
I have requirement to find the matching patterns of two files in Unix. One file is the log file and the other is the error list file. If any pattern in the log file matches the list of errors in the error list file, then I would need to find the counts of the match.
For example,
... (5 Replies)
Discussion started by: Bobby_2000
5 Replies
10. Shell Programming and Scripting
i am using sed to detect any lines that are not exactly 21. the following gives me the lines that ARE exactly 21. i want the opposite , i want the two lines that are not size 21 (shown in bold)
type a.a
000008050110010201NNN
000008060810010201NNN
21212000008070110010201NNN... (5 Replies)
Discussion started by: boncuk
5 Replies
LEARN ABOUT PHP
maxdb_fetch_assoc
MAXDB_FETCH_ASSOC(3) 1 MAXDB_FETCH_ASSOC(3)
maxdb_fetch_assoc - Fetch a result row as an associative array
Procedural style
SYNOPSIS
array maxdb_fetch_assoc (resource $result)
DESCRIPTION
Object oriented style
array maxdb_result::fetch_assoc (void )
Returns an associative array that corresponds to the fetched row or NULL if there are no more rows.
The maxdb_fetch_assoc(3) function is used to return an associative array representing the next row in the result set for the result repre-
sented by the $result parameter, where each key in the array represents the name of one of the result set's columns.
If two or more columns of the result have the same field names, the last column will take precedence. To access the other column(s) of the
same name, you either need to access the result with numeric indices by using maxdb_fetch_row(3) or add alias names.
Note
Field names returned by this function are case-sensitive.
Note
This function sets NULL fields to the PHP NULL value.
RETURN VALUES
Returns an array that corresponds to the fetched row or NULL if there are no more rows in resultset.
EXAMPLES
Example #1
Object oriented style
<?php
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s
", maxdb_connect_error());
exit();
}
$query = "SELECT name, state FROM hotel.city ORDER by zip";
if ($result = $maxdb->query($query)) {
/* fetch associative array */
while ($row = $result->fetch_assoc()) {
printf ("%s (%s)
", $row["NAME"], $row["STATE"]);
}
/* free result set */
$result->close();
}
/* close connection */
$maxdb->close();
?>
Example #2
Procedural style
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s
", maxdb_connect_error());
exit();
}
$query = "SELECT name, state FROM hotel.city ORDER by zip";
if ($result = maxdb_query($link, $query)) {
/* fetch associative array */
while ($row = maxdb_fetch_assoc($result)) {
printf ("%s (%s)
", $row["NAME"], $row["STATE"]);
}
/* free result set */
maxdb_free_result($result);
}
/* close connection */
maxdb_close($link);
?>
The above example will output something similar to:
New York (NY)
New York (NY)
Long Island (NY)
Albany (NY)
Washington (DC)
Washington (DC)
Washington (DC)
Silver Spring (MD)
Daytona Beach (FL)
Deerfield Beach (FL)
Clearwater (FL)
Cincinnati (OH)
Detroit (MI)
Rosemont (IL)
Chicago (IL)
Chicago (IL)
New Orleans (LA)
Dallas (TX)
Los Angeles (CA)
Hollywood (CA)
Long Beach (CA)
Palm Springs (CA)
Irvine (CA)
Santa Clara (CA)
Portland (OR)
SEE ALSO
maxdb_fetch_array(3), maxdb_fetch_row(3), maxdb_fetch_resource(3).
PHP Documentation Group MAXDB_FETCH_ASSOC(3)