Shell Programming and Scripting

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Directory containing files,Print names of the files in the directory that are exactly same content.

👤 Login to reply

Old 03-23-2017
RudiC RudiC is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 21 July 2018, 12:24 PM EDT
Location: Aachen, Germany
Posts: 13,082
Thanks: 452
Thanked 4,017 Times in 3,693 Posts
To reduce the ls invocations, you could apply a small adaption:
for i in $(ls -r TEST/*)
      do for a in  TEST/*
           do    [ $i == $a ] && break
                 cmp -s $i $a && echo "Matches the $i and $a"

Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Edit names of files in a directory Error404 Shell Programming and Scripting 3 08-12-2013 11:05 AM
Grepping file names, comparing them to a directory of files, and moving them into a new directory sHockz Shell Programming and Scripting 1 02-02-2012 01:53 AM
Comparing files names in directory over two servers Olivia Shell Programming and Scripting 3 09-16-2011 12:34 AM
How to store files names from a directory to an array dgmm Shell Programming and Scripting 5 05-18-2011 09:09 PM
how can i copy a list of files with different names into others directory have the same name t17 Shell Programming and Scripting 0 08-03-2010 04:55 AM

All times are GMT -4. The time now is 09:06 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?