Reputation: 310
This feels like a silly question, but my touch
command seems to have broken. Trying to create the ~/.bash_profile
file using the command: touch ~/.bash_profile
and seeing the following when I send the command: -bash: touch: No such file or directory.
I've search quite a bit for an answer but haven't found the same problem so far. Can anyone assist? What exactly do I need to do in order to make the touch command work?
Upvotes: 7
Views: 6521
Reputation: 2011
You might like to run the touch
command through OS X's equivalent of strace
(I think that command exists on OS X, actually, although there appear to be others), go through the output and examine what errors are generated, if any. Pasting the output to a pastebin may also be a good idea.
I think this is one of those instances where the call to strerror()
inside touch
's C code is referencing an insane value of errno
. (This is where all those "Error performing <X>
: Success" messages come from. There was an error, but errno
subsequently got set to 0
by a successful command before errno
was captured and the error message printed.)
Upvotes: 5
Reputation: 107070
I have OS X Mavericks, and I use Kornshell, but I'll switch over to bash:
Let's try touching a non-existent file:
$ touch foo
Nope. That worked. Let's try touching a file you don't own:
$ touch /usr/bin/true
touch true: Permission denied
Nope, that's what I expected and not what the OP got. Let's try with a symbolic link
ln -s foo bar
touch bar
Nope, worked. Let's try it with a directory:
$ touch Applications
Nope, also worked.
Try this:
$ sum /usr/bin/touch
6205 9 /usr/bin/touch
$ file /usr/bin/touch
/usr/bin/touch: Mach-O 64-bit executable x86_64
If you're using Mavericks, I assume you should get the same results.
Upvotes: 3