[colug-432] help with a command
Rick Hornsby
richardjhornsby at gmail.com
Sun Aug 10 23:38:21 EDT 2014
On Aug 10, 2014, at 21:20, Stephen Potter <spp at unixsa.net> wrote:
> On 8/10/2014 10:16 PM, Chris Embree wrote:
>> I guess I misread your requirements. I think Pat had the right
>> solution for deleting dirs.
>>
>> The only difference might be addring -rf...
>>
>> find /dir/to/serach -type d -name "*.PA" -exec rm -rf {} \;
>>
>> Untested. But seems the right direction.
>
> No, Keith said he wanted to keep the directories and only delete the
> files within.
Right. Also turned out that the directories are named '*.PA’ and the files are randomly named.
find . -type f -mindepth 2 -delete
One way to test away from your spool directory -
$ mkdir /tmp/findtest; cd /tmp/findtest
$ mkdir 1.PA 2.PA 3.PA
$ touch ./foo 1.PA/foo 2.PA/foo 3.PA/foo
which gives you
$ ls -lR
total 0
drwxr-xr-x 3 rhornsby staff 102 Aug 10 22:32 1.PA
drwxr-xr-x 3 rhornsby staff 102 Aug 10 22:32 2.PA
drwxr-xr-x 3 rhornsby staff 102 Aug 10 22:32 3.PA
-rw-r--r-- 1 rhornsby staff 0 Aug 10 22:32 foo ### file in current directory that we won’t touch
./1.PA:
total 0
-rw-r--r-- 1 rhornsby staff 0 Aug 10 22:32 foo
./2.PA:
total 0
-rw-r--r-- 1 rhornsby staff 0 Aug 10 22:32 foo
Now you can run the find command to make sure it worked:
$ find . -type f -mindepth 2
./1.PA/foo
./2.PA/foo
./3.PA/foo
More information about the colug-432
mailing list