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

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

bulrush

Thread Starter
Joined
Oct 14, 2011
Messages
22
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 "._"?

Thanks.

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:
Code:
 #/bin/csh
# 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;
endif
if !(-d $argv[1]) then
    echo "Input dir $argv[1] does not exist, or it's not a dir."
    echo " "
    exit 1;
endif
#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.
 

jiml8

Guest
Joined
Jul 2, 2005
Messages
2,634
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 [.]_
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top