about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-10-11 15:05:32 -0400
committerZach DeCook <zachdecook@librem.one>2021-10-11 15:05:32 -0400
commitb5f1684628e292d44ca00921900402258422b227 (patch)
treeea1532e0f68ed3ae2406562ae4e03359e0f7cc26
parent7c22f7a4006e2cf154a301529aa8b93fce42f735 (diff)
downloadswipeGuess-b5f1684628e292d44ca00921900402258422b227.tar.gz
make method to split file into multiple files based on first and last letters
-rw-r--r--functions.sh6
-rwxr-xr-xmakeDir.sh9
2 files changed, 15 insertions, 0 deletions
diff --git a/functions.sh b/functions.sh
new file mode 100644
index 0000000..440219b
--- /dev/null
+++ b/functions.sh
@@ -0,0 +1,6 @@
+firstLetter(){
+	echo "$1"|grep -o '^.'
+}
+lastLetter(){
+	echo "$1"|grep -o '.$'
+}
diff --git a/makeDir.sh b/makeDir.sh
new file mode 100755
index 0000000..aa9f782
--- /dev/null
+++ b/makeDir.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+dir="$1"
+rm $dir/*
+source functions.sh
+while read -r line; do
+	fl=$(firstLetter "$line")
+	ll=$(lastLetter "$line")
+	echo "$line" >> "$dir/$fl$ll"
+done