Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using shell script i need to compare file(s) with other files to list duplicate. When more than one argument is provided (1st form): Compares the

using shell script

i need to compare file(s) with other files to list duplicate.

When more than one argument is provided (1st form): Compares the first argument to all of the other arguments.

When exactly one argument is provided (2nd form): Compares the given argument to all of the other files in the current directory.

When no arguments are provided (3rd form): Compares all files in the current directory to all other files in the current directory.

### NOTES

1. a file is never compared to itself (decided by having an identical name) 2. a file is only displayed if it has duplicates 3. duplicates are displayed as: ``` the given source file on a line each of its duplicates, one per line a blank line ``` 4. when no arguments are given, all combinations of duplicates will be displayed (see last example)

(Example)

``` echo '1' > tmp1; echo '2' > tmp2; listdupes tmp1 tmp2 ; echo $? 0 ```

``` touch tmp{1..2}; mkdir tmpdir ; listdupes tmp* ; echo $? ; rm -rf tmpdir not a file: 'tmpdir' 2 ```

``` echo 0 > tmp01 ; cp tmp01 tmp02; cp tmp02 tmp03 ; echo 1 > tmp11; cp tmp11 tmp12; echo 2 > tmp21 ; listdupes tmp01 ; echo $? tmp01 tmp02 tmp03

1 ```

``` $ echo 0 > tmp01 ; cp tmp01 tmp02; cp tmp02 tmp03 ; echo 1 > tmp11; cp tmp11 tmp12; echo 2 > tmp21 ; listdupes ; echo $? tmp01 tmp02 tmp03

tmp02 tmp01 tmp03

tmp03 tmp01 tmp02

tmp11 tmp12

tmp12 tmp11

1 ```

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions