-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask3.sh
40 lines (29 loc) · 1.04 KB
/
task3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!bin/bash
x=1
while [ $x -lt 51 ]
do
if [ ! -f /home/Army$x/post_alloted.txt ]
then
echo Date Post | column -t -s " " >/home/Army$x/post_alloted.txt
fi
if [ ! -f /home/Navy$x/post_alloted.txt ]
then
echo Date Post | column -t -s " " >/home/Navy$x/post_alloted.txt
fi
if [ ! -f /home/AirForce$x/post_alloted.txt ]
then
echo Date Post | column -t -s " " >/home/AirForce$x/post_alloted.txt
fi
x=$(expr $x + 1)
done
x=1
while [ $x -lt 51 ]
do
place=$(cat /root/position.log | grep 'Army'$x' ' | grep $(date "+%F") | awk -F " " '{print $3 $4}')
echo $(date "+%F") $place | column -t -s " " >>/home/Army$x/post_alloted.txt
place=$(cat /root/position.log | grep 'Navy'$x' ' | grep $(date "+%F") | awk -F " " '{print $3 $4}')
echo $(date "+%F") $place | column -t -s " " >>/home/Navy$x/post_alloted.txt
place=$(cat /root/position.log | grep 'AirForce'$x' ' | grep $(date "+%F") | awk -F " " '{print $3 $4}')
echo $(date "+%F") $place | column -t -s " " >>/home/AirForce$x/post_alloted.txt
x=$(expr $x + 1)
done