echo $PATH|tr : '\n'|sort|uniq -d

Find duplicate dir in path


0
By: haivu
2009-09-24 17:22:45

These Might Interest You


  • 2
    export PATH=`echo -n $PATH | awk -v RS=":" '{ if (!x[$0]++) {printf s $0; s=":"} }'`
    mij · 2013-03-09 15:24:34 0
  • Detect duplicate UID in you /etc/passwd (or GID in /etc/group file). Duplicate UID is often forbidden for it can be a security breach. Show Sample Output


    0
    awk -F: '{print $3}' /etc/passwd | sort |uniq -d
    ultips · 2012-01-17 11:16:35 0
  • Thanks to the authors of: awk '!x[$0]++' <file> and the author of: joinargs() { (local IFS="$1"; shift && echo "$*") } and others, we can have a fast Linux or android. IMPORTANT if you find a priority order problem in PATH you can push a path directory to the front without duplication as follows: PATH=/bin:$PATH then ... Check duplication with: echo $PATH|tr : '\n'|sort|uniq -d Finally do a very neat line by line list of $PATH: echo "${PATH//:/$'\n'} The speed up is very noticeable for android, and builds on Linux Ubantu are much faster with make and scripts. I will update the command on request. Timothy from SONY


    0
    glu() { (local IFS="$1"; shift && echo "$*") }; repath() { ( _E=`echo "${PATH//:/$'\n'}" | awk '!x[$0]++'`; glu ":" $_E ) ; } ; PATH=`repath` ; export PATH
    Timothy · 2011-06-09 12:11:18 0
  • If you have the fdupes command, you'll save a lot of typing. It can do recursive searches (-r,-R) and it allows you to interactively select which of the duplicate files found you wish to keep or delete.


    22
    fdupes -r .
    Vilemirth · 2011-02-19 17:02:30 0
  • This command deletes all but the first occurrence of a duplicate file in one or more folders. Show Sample Output


    -2
    yes 1 | fdupes -rd $folder
    torrid · 2011-06-02 18:15:24 0
  • Improvement of the command "Find Duplicate Files (based on size first, then MD5 hash)" when searching for duplicate files in a directory containing a subversion working copy. This way the (multiple dupicates) in the meta-information directories are ignored. Can easily be adopted for other VCS as well. For CVS i.e. change ".svn" into ".csv": find -type d -name ".csv" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".csv" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate Show Sample Output


    2
    find -type d -name ".svn" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".svn" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
    2chg · 2010-01-28 09:45:29 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: