Sunday, June 26, 2011

Remove special character files in folder solaris system

Gbr Buldozer


Sometime we see any special character created in directory/folder, how to remove thats?

See below for case like that :
1. look list files in folder
root # ls -l
total 6
-rw-r--r-- 1 root root 0 Jun 26 20:39 @
-rw-r--r-- 1 admin staff 136 Mar 4 2009 local.cshrc
-rw-r--r-- 1 admin staff 157 Mar 4 2009 local.login
-rw-r--r-- 1 admin staff 174 Mar 4 2009 local.profile
-rw-r--r-- 1 root root 0 Jun 26 20:38 test
-rw-r--r-- 1 root root 0 Jun 26 20:37 }


in this case, we found any "@" and "}" created in folder
2. let see inode for those special character
root # ls -il
total 6
349442 -rw-r--r-- 1 root root 0 Jun 26 20:39 @
349857 -rw-r--r-- 1 admin staff 136 Mar 4 2009 local.cshrc
349858 -rw-r--r-- 1 admin staff 157 Mar 4 2009 local.login
349859 -rw-r--r-- 1 admin staff 174 Mar 4 2009 local.profile
349441 -rw-r--r-- 1 root root 0 Jun 26 20:38 test
349440 -rw-r--r-- 1 root root 0 Jun 26 20:37 }
root #

3. No we will remove those spacial character in folder
root # find . -inum 349442 -exec rm -i {} \;
rm: remove ./@ (yes/no)? yes

4. verify the list files again
root # ls -il
total 5
349857 -rw-r--r-- 1 admin staff 136 Mar 4 2009 local.cshrc
349858 -rw-r--r-- 1 admin staff 157 Mar 4 2009 local.login
349859 -rw-r--r-- 1 admin staff 174 Mar 4 2009 local.profile
349441 -rw-r--r-- 1 root root 0 Jun 26 20:38 test
349440 -rw-r--r-- 1 root root 0 Jun 26 20:37 }
The "@" already gone, next we're remove the "}"

5. next remove the "}"
root # find . -inum 349440 -exec rm -i {} \;
rm: remove ./} (yes/no)? yes
root # ls -il
total 4
349857 -rw-r--r-- 1 admin staff 136 Mar 4 2009 local.cshrc
349858 -rw-r--r-- 1 admin staff 157 Mar 4 2009 local.login
349859 -rw-r--r-- 1 admin staff 174 Mar 4 2009 local.profile
349441 -rw-r--r-- 1 root root 0 Jun 26 20:38 test
root #

6. done

Picture from : http://www.ascendanttech.com/category/engineering/

0 komentar:

Post a Comment

 
footer