Skip to content

Instantly share code, notes, and snippets.

@melaniehoff
Created July 6, 2020 22:50
Show Gist options
  • Save melaniehoff/e3a9419ef060c2cae98f14fa3edcd42a to your computer and use it in GitHub Desktop.
Save melaniehoff/e3a9419ef060c2cae98f14fa3edcd42a to your computer and use it in GitHub Desktop.
#!/bin/bash -
#title :treepoem.sh
#description :This script will sequentially print a directory, along with the file name and directory name.
#author :Matthew Ragan & Zoe Sandoval
#date :20200702
#==============================================================================
treeFunction(){
# Function to Sequence Printed Files
# For 'each' file ending in .txt that is found in the current terminal directory
# 'do'
# print each using the 'cat' command
# then using the 'sleep' command,
# wait a variable number of seconds
# before printing the next file.
# args:
# $1 = the directory to use for 'find'
# $2 = the number of seconds used for sleep
for each in $(find $1 -name "*.txt")
do
echo
dirname $each | sed -e "s,[^/]*/, | ,g"
echo $each | sed -e "s,[^/]*/, | ,g"
echo
cat $each
echo
sleep $2
done
}
# args:
# . = current working directory
# 1 = number of seconds for 'sleep'
alias treepoem="treeFunction . 2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment