Sponsored Content
Full Discussion: Removing files exclusively
Top Forums UNIX for Dummies Questions & Answers Removing files exclusively Post 66833 by phil1t on Thursday 17th of March 2005 08:00:14 AM
Old 03-17-2005
It will not remove the current directory so you can do the following;
find . -name '*Copy*' -prune -o -exec rm -r {} \; 2>/dev/null

Example;
# ls -lia
total 40
129053 drwxr-xr-x 5 root system 512 Mar 17 06:58 .
63492 drwxr-xr-x 9 pthompso staff 1536 Mar 16 19:16 ..
129054 drwxr-xr-x 2 root system 512 Mar 17 06:53 Copy
129109 -rw-r--r-- 1 root system 0 Mar 17 06:55 Copyaaa
129106 -rw-r--r-- 1 root system 0 Mar 17 06:57 Copyxxx
129108 -rw-r--r-- 1 root system 0 Mar 17 06:54 aaaCopyaaa
133120 drwxr-xr-x 2 root system 512 Mar 17 06:58 cat
129111 drwxr-xr-x 2 root system 512 Mar 17 06:58 dog
129107 -rw-r--r-- 1 root system 0 Mar 17 06:57 xxxCopy
129110 -rw-r--r-- 1 root system 0 Mar 17 06:58 xxxCopyxxx
# find . -name '*Copy*' -prune -o -exec rm -r {} \; 2>/dev/null
# ls -lia
total 24
129053 drwxr-xr-x 3 root system 512 Mar 17 06:59 .
63492 drwxr-xr-x 9 pthompso staff 1536 Mar 16 19:16 ..
129054 drwxr-xr-x 2 root system 512 Mar 17 06:53 Copy
129109 -rw-r--r-- 1 root system 0 Mar 17 06:55 Copyaaa
129106 -rw-r--r-- 1 root system 0 Mar 17 06:57 Copyxxx
129108 -rw-r--r-- 1 root system 0 Mar 17 06:54 aaaCopyaaa
129107 -rw-r--r-- 1 root system 0 Mar 17 06:57 xxxCopy
129110 -rw-r--r-- 1 root system 0 Mar 17 06:58 xxxCopyxxx
#
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing Files

I am trying to remove a file so that I can delete a directory. Unfortuantely the file looks like this --------.--- and the system is not allowing me to remove the file. System message is rm: Error: Illegal option -- - usage: rm file... I have tried rm * and rm *.* to no avail. Any... (5 Replies)
Discussion started by: Blondie
5 Replies

2. UNIX for Advanced & Expert Users

Removing files

Hi, It seems someone has created files instead of actually running the commands, as below: -rw-r--r-- 1 oracle92 dba 0 Mar 2 11:19 PRIML_070302.ok -rw-r--r-- 1 oracle92 dba 557 Mar 2 11:20 PRIVH_070302.dat -rw-r--r-- 1 oracle92 dba 0 Mar 12 11:57... (2 Replies)
Discussion started by: LiquidChild
2 Replies

3. Shell Programming and Scripting

removing old files except configuration files and folders

Dear all, I want to remove files older than 2 months in the /home/member directory. But except the configuration files (like .bash_profile .config/ .openoffice/ .local/ .kde/ etc..) I have tried with the command find . -mtime +60 -wholename './.*' -prune -o -print -exec mv {} \; but it... (1 Reply)
Discussion started by: jamcalicut
1 Replies

4. UNIX for Dummies Questions & Answers

Removing Files

Hi, This might seem like a really stupid question but i have created a shell script and at the end of the script i want to remove most of the file i create. So I have: rm file test sorted However this does not work for the sorted one. The only way i can get this to work is if i do: rm... (4 Replies)
Discussion started by: jazz8146
4 Replies

5. SuSE

can't open /dev/sda3 exclusively

Hi, please help!!! I'm installing an openSUSE 10.3 into a computer, after creating the following partitions: Primay Partition swap / LVM(volume manager) - /dev/sda3 /opt, /var, /tmp, /usr, /local when i tried to continue installing, after creating the partitions i am prompted with the... (2 Replies)
Discussion started by: etcpasswd
2 Replies

6. UNIX for Dummies Questions & Answers

Removing files

How do you delete/remove multiple files ? (5 Replies)
Discussion started by: nosuchluck
5 Replies

7. UNIX for Dummies Questions & Answers

Help in Removing the Old files

Hi Gurus, we are planning to clear the old log files based on the year and i need help on this and i searched in google and i came up with the scripts but i am stuck with this. (1) wroks fine How many files exist in based on the extension find -type f | sed -e 's/.*\.//' | sort | uniq... (1 Reply)
Discussion started by: SeenuGuddu
1 Replies

8. UNIX for Advanced & Expert Users

Pvcreate can't open /dev/xvda2 exclusively mounted filesystem

I downloaded the oracle linux 6.7 from RHEL, I wanted to extend the storage for "/" from default 16GB to say 200GB. Here's the steps I tried is : 1. Init 1 2. Using “fdisk /dev/xvda” , delete the swap /dev/xvda3 as well as /dev/xvda2 3. Re-create /dev/xvda2 with linux LVM using new end blocks ... (1 Reply)
Discussion started by: alnhk
1 Replies

9. Red Hat

Pvcreate can't open /dev/xvda2 exclusively mounted filesystem

I downloaded the RH Linux 6.7 from RHEL, I wanted to extend the storage for "/" from default 16GB to say 200GB. Here’s the steps I tried is : 1. Init 1 2. Using “fdisk /dev/xvda” , delete the swap /dev/xvda3 as well as /dev/xvda2 3. Re-create /dev/xvda2 with linux LVM using new end... (7 Replies)
Discussion started by: alnhk
7 Replies

10. UNIX for Beginners Questions & Answers

Find and removing the old files and zipping the files using shell script

Hi, I am trying to removing the old files which were older than 10 days and same g zipping the files using the shell script. script was return as follows. find /jboss7_homes/JBOSS7/SKYLIV??/SKYLIV??_CRM/jboss-eap-7.0/standalone/log -mtime +10 -type f | xargs rm -f find /cer_skyliv??/log... (6 Replies)
Discussion started by: venkat918
6 Replies
DH_FIXPERMS(1)							     Debhelper							    DH_FIXPERMS(1)

NAME
dh_fixperms - fix permissions of files in package build directories SYNOPSIS
dh_fixperms [debhelperoptions] [-Xitem] DESCRIPTION
dh_fixperms is a debhelper program that is responsible for setting the permissions of files and directories in package build directories to a sane state -- a state that complies with Debian policy. dh_fixperms makes all files in usr/share/doc in the package build directory (excluding files in the examples/ directory) be mode 644. It also changes the permissions of all man pages to mode 644. It removes group and other write permission from all files. It removes execute permissions from any libraries, headers, Perl modules, or desktop files that have it set. It makes all files in the standard bin and sbin directories, usr/games/ and etc/init.d executable (since v4). Finally, it removes the setuid and setgid bits from all files in the package. When the Rules-Requires-Root field has the (effective) value of binary-targets, dh_fixperms will also reset the ownership of all paths to "root:root". OPTIONS
-Xitem, --exclude item Exclude files that contain item anywhere in their filename from having their permissions changed. You may use this option multiple times to build up a list of things to exclude. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_FIXPERMS(1)
All times are GMT -4. The time now is 08:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy