Thursday, June 24, 2021

Why and How to create a shell loop script to run same file in multiple directories

  Why ?

To run on command or execute the same file in different directory you will need to do this whether using a find command or with shell script to be in more flexible .

How ?

This is a shell script file  :

1- create a shell file(example):

vim check_file.sh

2- sample of for loop to execute "file.sh" and echo command in multiple directories (dir1, dir2, dir3 , dir4) :

#!/bin/sh

for dir in /path/dir*; do

        echo $dir

        $dir/file.sh

done;

No comments:

Post a Comment

Why and How to install Grid 19c on RHEL 8?

  Why ? Simply we will be requested to install Oracle Grid RAC DB on Redhat RHEL 8, below is my note for this installation . How ? 1-  OS in...