Skip to content

Commit 317eeb1

Browse files
authored
Update III Control Statements in Bash Scripting.py
1 parent 9fc2c1a commit 317eeb1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Introduction to Bash Scripting/III Control Statements in Bash Scripting.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,15 @@
8888
- Inside the IF statement, move matching files to the good_logs/ directory.
8989
- Try your script on all of the files in the directory (that is, run it four times - once for each file). It should move only one of them.
9090
"""
91+
# Create variable from first ARGV element
92+
sfile=$1
93+
94+
# Create an IF statement on sfile's contents
95+
if grep -q 'SRVM_' $sfile && grep -q 'vpt' $sfile; then
96+
# Move file if matched
97+
mv $sfile good_logs/
98+
fi
99+
100+
repl:~/workspace$ bash script.sh logfiles8.txt
101+
repl:~/workspace$ bash script.sh logdays.txt
102+
repl:~/workspace$ bash script.sh log1.txt

0 commit comments

Comments
 (0)