I did a search in this repository and I didn't find any similar questions or may be my search was incorrect.
I have this problem in my clients environment, a custom application is creating directories with an environmental variable "$SRCDIR" and "$HOME" and the dir's where these are created , itself is the HOME dir path. if I say rm -rf $HOME
then all the files and subdir's under $HOME which is current directory will be deleted . How do I delete these unwanted directories.
-rw-r--r-- 1 grp domain users 418051450 Apr 18 18:09 $SRCDIR
-rw-r--r-- 1 grp domain users 418051450 Apr 18 18:09 $HOME
Also some directories are junk characters as below example.
-rwxr-xr-x 1 grp domain users 0 Feb 7 2106 ??????w?O???*????_6??t??Ó¡?>?tP??Ñ?|?C
How do I delete them ?
For the junk names, it would be easiest to construct a wildcard that would catch only them. Select a readable portion of the name (e.g. the _6
substring) and wrap it in asterisks. First try it out:
ls *_6*
If it lists only the junk name, proceed to delete it:
rm *_6*
If it lists other names as well, try to make the wildcard more specific, using other readable characters in the name:
ls *w*_6*tP*N*x*
Proceed until you've found a wildcard that would match only unwanted files.
Determine inode numbers of necessary files/folders:
# ls -ila
14549980 drwxr-xr-x 3 root root 4096 Mar 5 20:45 ">?<
And pipeline it to rm
:
find . -inum 14549980 -exec rm -ir {} \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With