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 want a create a file with a specific extension(.done). I am using the command touch. Something Like:

touch `basename $UNZIPFILE`".done" 

It's creating the file but in current directory. I want to create this file in a specific directory. Is there a option to provide the directory ?

I checked : http://ss64.com/bash/touch.html , but could not figure out.

I can think of one option is before this command I can do a cd requiredDIR

Is there any other way, I can specify the Directory on the same command, so that I dont have to change the Directory?

share|improve this question
I don't understand the question: why aren't you running touch "$UNZIPFILE.done"? – Gilles Dec 14 '12 at 23:10
up vote 1 down vote accepted

basename remove the directory part. You may get it back with command dirname

touch "$(dirname "$UNZIPFILE")/$(basename "$UNZIPFILE").done"
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.