Wednesday, 22 August 2012

how to delete files in UNIX which contains special characters like " , ( , ',)

Objective: If the file in Unix contains special characters in its name, then a simple "rm" command will not work, so what is the solution!

  Cook Book:

 We can use the escape character "\" to remove such files. 

Following is an example


[oracle@TESTServer]>ls -ltrh
total 129

-rw-r--r--   1 oracle   oinstall       0 Aug 21 14:54 to_date('22-FEB-2012')"
-rw-------   1 oracle   oinstall     723 Aug 21 14:55 nohup.out

[oracle@TESTServer]>rm to_date\(\'22-FEB-2012\'\)\"


[oracle@TESTServer]>ls -ltrh
total 110
-rw-------   1 oracle   oinstall     723 Aug 21 14:55 nohup.out