-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter.sh
53 lines (43 loc) · 1.28 KB
/
filter.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
48
49
50
51
52
#!/bin/bash -
#===============================================================================
#
# FILE: filter.sh
#
# USAGE: ./filter.sh
#
# DESCRIPTION: Filters data from $PWD/tmp/output.csv and other .csv files
# doesnt get header data
# retrieves only Canadian female residents
# takes NULL emails and replaces with dummy address: [email protected]
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: DAVID MARILUCH (), [email protected]
# ORGANIZATION: WSU
# CREATED: 02/15/2017 04:53
# REVISION: ---
#===============================================================================
#set -o nounset # Treat unset variables as an error
# help function
help()
{
echo "Usage: this script is executed inside expand.sh (e.g ./expand.sh)"
}
# check for --help call as 1st parameter
if [[ $1 == "--help" ]]
then
help
exit 1
fi
# csv file structure from $file input
# id, first_name, last_name, email,gender,country
file=$1
awksrc="$PWD/filter.awk"
output="$PWD/tmp/outfile.csv"
echo "Filtering $file by female Canadian residents"
echo "Appending users to $output"
# awk to take values and append it to new output file
awk -f $awksrc $file >> $output
exit 0