-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab2_scripts.sh
executable file
·47 lines (37 loc) · 1.07 KB
/
lab2_scripts.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
40
41
42
43
44
45
46
47
#!/bin/bash
# Author: Casey Tran
# Date: 1/30/2019
#Problem 1 Code:
echo "Enter a regular expression:"
read regex
echo "Enter a file name:"
read fileName
#Problem 2 Code:
grep $regex $fileName
#Problem 3.1 Code:
echo "The number of phone numbers is:"
grep -E -c "^[0-9]{3}-[0-9]{3}-[0-9]{4}$" regex_practice.txt
#Problem 3.2 Code:
echo "The number of emails is:"
grep -E -c ".com$" regex_practice.txt
#Problem 3.3 Code:
touch phone_results.txt
phone=$(grep -E "^303-[0-9]{3}-[0-9]{4}$" regex_practice.txt)
echo $phone > "phone_results.txt"
#Problem 3.4 Code:
touch email_results.txt
email=$(grep -E "@geocities.com$" regex_practice.txt)
echo $email > "email_results.txt"
#Problem 3.5 Code:
touch command_results.txt
command=$(grep $regex regex_practice.txt)
echo $command > "command_results.txt"
#Problem 4-7 Code:
git init
git add phone_results.txt
git add email_results.txt
git add command_results.txt
git add lab2_scripts.sh
git commit -m "Pushing phone, email and command texts with the script."
git remote add origin https://github.com/casey-tran/lab_2.git
git push origin master