Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting the error:

touch: cannot touch `/opt/tsrm/compliance/cme/log/20121207.log`: No such file or directory

on the touch command: touch $LOGFILE

I also checked the link: touch: cannot touch `foo': No such file or directory, But I didn't understand the answer.

Note: I was also getting mkdir: cannot create directory; I fixed this by adding the -p option.

Could this be something with the version of Linux I am working in?

share|improve this question
up vote 7 down vote accepted

You do not have the path that holds the file:


That's where the error come from.

share|improve this answer

Sounds like you misspelled the path. For example, this folder /stuff/more_stuff does not exist. This gives me the result:

user@linux:~ $ touch /stuff/more_stuff/stuff.file
touch: cannot touch `/stuff/more_stuff/stuff.file': No such file or directory

Both /stuff and /stuff/more_stuff need to exist in order for touch to work.

share|improve this answer

Yes there might be chances of miss typo or directory not exists .

LOG_DIR=`dirname $LOGFILE`
[ ! -d $LOG_DIR ] && mkdir -p $LOG_DIR
touch $LOGFILE
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.