1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Find and delete all files that begin with "._"

Discussion in 'Linux and Unix' started by bulrush, Dec 1, 2011.

Thread Status:
Not open for further replies.
  1. bulrush

    bulrush Thread Starter

    Oct 14, 2011
    I have Sun Solaris 5.9 running C Shell. It seems that the Solaris version of find does not have all features of a POSIX find. So, it does not find files that begin with a period.

    However, we have at least 1000 files that are backups of graphic files that need to be deleted, but I can't find an automated way to delete them. I'll have to do this every month or so. Plus we are running out of disk space, and do not have a budget to buy a new disk!

    So, on Solaris, how can I find and remove all files that begin with "._"?


    p.s. Solaris find also does not seem to traverse subdirs, even if I do use -depth.

    I also made this script and found out that find does not traverse subdirs if a subdir is something other than ".". Here's my script:
    # Nov 2011
    # Find files from current and all subdirs.
    if ($#argv<2) then
        echo "Updated: Nov 30, 2011"
        echo "Usage: $0 startdir filespec"
        echo "Example: $0 mydir *.bak"
        echo "  Find all files matching filespec recursively. "
        exit 1;
    if !(-d $argv[1]) then
        echo "Input dir $argv[1] does not exist, or it's not a dir."
        echo " "
        exit 1;
    #set mydir=`pwd`
    set startdir=$argv[1]
    set filespec=$argv[2]
    echo "Looking for $startdir $filespec"
    #find $startdir -name "$filespec" -print -exec rm {} ';'
    #find $argv[1] \( -name "$filespec" \) -exec echo {} ';'
    find $startdir -name "$filespec" -print
    #find $startdir -name "$filespec" -print | xargs rm -f 
    echo "Done finding files."
    This script has various ways of using find, but if I pass in a subdir name, like "mystuff", it will not find files, like *.bak, even if a .bak file exists under mystuff.
  2. jiml8

    jiml8 Guest

    Jul 2, 2005
    Not sure if this syntax will work in Solaris, but here is a Linux way that doesn't use find, which should give you some ideas:

    ls -alR | tr -s '[:blank:]' '\t' | cut -f 8 | grep -G ^[.][^/.] | grep [.]_
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1029252

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice