mirror of
https://github.com/techarkit/shell-scripting-tutorial.git
synced 2025-08-12 23:43:19 +00:00
Create for-loop.sh
This commit is contained in:
19
for-loop.sh
Normal file
19
for-loop.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Purpose: For loop example
|
||||||
|
#Version:1.0
|
||||||
|
#website: https://arkit.co.in
|
||||||
|
#Created Date: Wed May 16 19:26:02 IST 2018
|
||||||
|
#Modified Date:
|
||||||
|
#Author: Ankam Ravi Kumar
|
||||||
|
# START #
|
||||||
|
for i in `cat hostfile`
|
||||||
|
do
|
||||||
|
ping -c 1 $i > /tmp/pingresults
|
||||||
|
valid=`echo $?`
|
||||||
|
if [ $valid -gt 1 ]; then
|
||||||
|
echo "$i Host is not reachable"
|
||||||
|
else
|
||||||
|
echo "$i Host is Up"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# END #
|
Reference in New Issue
Block a user