Script S1 (which copies .dat files from one directory1 to
another directory2) run continuously.
Write Script S2 which kills S1 first, compresses all .dat
files in directory1 and directory2 successfully, re-run
Script S1 and stops self i.e. S2.
Answer Posted / vipul dalwala
script1.sh
#!/bin/bash
cp directory1/*.dat directory2/
script2.sh
#!/bin/bash
PSIDODSCRIPT1=`ps -a | awk '/script1\.sh/ && !/awk/ {print
$1}'
SELFID=$$
kill -9 ${PSIDODSCRIPT1}
find directory1 -name '*.dat' -exec gzip {} \;
if [ $? -eq 0 ]
then
find directory2 -name '*.dat' -exec gzip {} \;
if [ $? -eq 0 ]
then
sh script1.sh
kill -9 ${SELFID}
else
exit
fi
else
exit
fi
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
What is gui scripting?
Differentiate between ‘ and ” quotes.
Explain about the slow execution speed of shells?
How do I run a script on mac?
How do you know which shell I am using?
What language is bash written in?
What's the difference between scripting and coding?
What is the use of echo in shell script?
How do I stop script errors?
Is shell scripting difficult?
How can I set the default rwx permission to all users on every file which is created in the current shell?
What is a shell in operating system?
How do we create command aliases in a shell?
What is scripting autism?
How does path variable work?