Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

3 Answers 3

up vote 4 down vote accepted

You do not have the path that holds the file:

/opt/tsrm/compliance/cme/log/

That's where the error come from.

share|improve this answer
add comment

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
add comment

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

LOGFILE="/opt/tsrm/compliance/cme/log/20121207.log"
LOG_DIR=`dirname $LOGFILE`
[ ! -d $LOG_DIR ] && mkdir -p $LOG_DIR
touch $LOGFILE
share|improve this answer
add comment

Your Answer

 
discard

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.