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


Please Help Members By Posting Answers For Below Questions

Write down the syntax of "for " loop

839


What is the equivalent of a file shortcut that we have a window on a linux system?

862


What is bash command used for?

809


Explain about login shell?

843


What are the different communication commands available in the shell?

755


How to find duplicate record in file using shell script?

1111


How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?

929


Write a script to print the first 10 elements of fibonacci series.

2114


What is the use of "$#" in shell scripting?

780


What are different types of shell?

701


Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.

2066


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

3228


Which scripting language is best for automation?

740


write a shell script to check the failed jobs?

4179


What does .sh file contain?

751