Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 to write script that will run in background and do following task: As soon as I extract "xyz.tar.gz" file to desktop it should write "a.cpp" file to desktop,and if a.cpp file already presents on desktop it should replace existing file..please help..stuck since hour..tar file name and file to be written are specific so it can hardcoded in script..

share|improve this question

inotify-tools package contains command-line tools to monitor file modification messages from kernel's inotify module. You can use inotifywait to monitor some file for changes

inotifywait filename.ext

the script will block at this line and will only continue when the file is modified.

Just a general idea... the script would look something like

while [ 1 ] 
    inotifywait ~/Desktop/filename.ext
    echo "Hello" > ~/Desktop/a.cpp
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.