Unix/Linux Go Back    

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.

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 03-23-2017   -   Original Discussion by anuragpgtgerman
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 23 January 2018, 10:01 AM EST
Location: Aachen, Germany
Posts: 11,982
Thanks: 356
Thanked 3,692 Times in 3,390 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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 12:05 PM
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 02:53 AM
Comparing files names in directory over two servers Olivia Shell Programming and Scripting 3 09-16-2011 01:34 AM
How to store files names from a directory to an array dgmm Shell Programming and Scripting 5 05-18-2011 10: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 05:55 AM

All times are GMT -4. The time now is 12:02 PM.