Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Pathname safety' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Pathname safety
Authored by: Rainy Day on Feb 14, '06 12:53:03PM
The safe way to enter fully qualified pathnames is to drag the file/folder icon you wish to delete to a Terminal window. The fully qualified path to that item will be automagically entered into the shell for you.

Ideally, you will have already typed your Unix command before doing that, so all you have to do is hit return, but i usually don't remember to do that beforehand. Fortunately, all you have to do is hit Control-A, which moves your shell cursor to the start of the line, and type the command (with a space at the end) then hit return (cursor can be anywhere on the line, doesn't have to be at the end).

You can also use cut and paste, or drag and drop text in the shell.


[ Reply to This | # ]

Pathname safety
Authored by: ManxStef on Feb 14, '06 01:03:03PM

Personally, if I'm doing an operation deemed "risky" such as rm -rf I always navigate down to the parent directory first, then use a relative path instead of an absolute e.g.

cd /path/to
sudo rm -rf delete

(Using tab-completion for the paths, too.) This is a fair bit safer IMO as you're a lot less likely to kill everything with a relative path than an accidental slash in an absolute.

[ Reply to This | # ]
Pathname safety
Authored by: sjk on Feb 16, '06 03:32:43PM

Good meta-hint!

[ Reply to This | # ]