From b5f1684628e292d44ca00921900402258422b227 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Mon, 11 Oct 2021 15:05:32 -0400 Subject: make method to split file into multiple files based on first and last letters --- functions.sh | 6 ++++++ makeDir.sh | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 functions.sh create mode 100755 makeDir.sh 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 -- cgit 1.4.1