1

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..

1 Answer 1

1

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

#!/bin/bash
while [ 1 ] 
do
    inotifywait ~/Desktop/filename.ext
    echo "Hello" > ~/Desktop/a.cpp
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .