-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconvert_long.sh
More file actions
executable file
·29 lines (24 loc) · 1.02 KB
/
Copy pathconvert_long.sh
File metadata and controls
executable file
·29 lines (24 loc) · 1.02 KB
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
#!/bin/bash
############################################################
# This script will lookup long country names and convert #
# a two or three letter short form for stripped.csv #
# IE: convert 'United States' to 'USA' #
# #
# VE3RD 2022-02-10 #
############################################################
set -o errexit
set -o pipefail
sudo mount -o remount,rw /
cat /usr/local/etc/stripped.csv | # piping file contents to the loop
while read line; do # reading the input stream line by line
# echo "$line"
# echo "$line" | cut -d "," -f 7
cntry=$(echo "$line" | cut -d "," -f 7)
# echo "Short: $cntry"
# size=${#cntry}
cntry2=$(awk "/$cntry/" ./country.csv | cut -d "," -f2)
if [ ! -z cntry2 ]; then
# sudo sed -i 's/United States/USA/g' /usr/local/etc/stripped.csv
sudo sed -i #s/'"$cntry"'/'"$cntry2"'/# /usr/local/etc/stripped.csv
fi
done