
The Best part of OS X is the Unix found under the "hood". To Access the Command line use the Terminal Application, navigate to Applications->Utilities->Terminal.
Some times small challenges arise like accidentally creating a file with special characters like ?,* and - as the first character of the file name. What ever you do NOT remove the file using 'rm wildcard-filename' the special wild card characters will result in all files matching the wild card being deleted. You should always use rm -i wildcard-filename where -i is request information and will ask you for confirmation before deleting the file. This may still not be enough as in the case of the '-filename', it will result in the -filename being interpreted as an illegal argument for the rm command.
For this job you could try the most powerful command line tool know to man. Ladies and Gentlemen it is the find command, with it you can find the filename by inode number and then execute the remove command.
First use the 'ls -i | more' command to get the inode number of the file (returned in the 1st column). Then fix the problem with command below subsituting filesysinode with the inode number.
find . -inum filesysinode -exec rm -i {} \;
In the line above the {} is replaced with the trouble some filename and path.
You will then be asked if you want to remove the file to which the answer is yes.
The file will then be removed and find will continue searching for the inode number.
So you can use Ctrl-C to stop it from searching further. Job done!
All for now...
Boost your OS X command line Zen
Labels: remove file, Unix find comand, Unix inode, Unix rm commandPosted by devnull at 21:20
Subscribe to:
Post Comments (Atom)
Design and icons by N.Design Studio | A Blogger Template by Blog and Web
Apple, the Apple logo, iTunes, Cocoa, GarageBand, Mac OS, Xcode and Mac are trademarks of Apple Computer, Inc., registered in the U.S. and other countries. OpenGL is a registered trademark of SGI.Unix® is a trademark of the Open Group. BSD is a registered trademark of UUnet Technologies, Inc.

Blog related articles and applications by devnill is licensed under a Creative Commons Attribution 2.0 UK: England & Wales License.
Based on a work at macateeny.blogspot.com.
Permissions beyond the scope of this license may be available at macateeny.blogspot.com.
0 comments:
Post a Comment