-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtn.sh
More file actions
executable file
·34 lines (26 loc) · 716 Bytes
/
tn.sh
File metadata and controls
executable file
·34 lines (26 loc) · 716 Bytes
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
#!/bin/bash
# Simple note-taking script
# Author: Edwin
#get the date
date=$(date)
#get the topic
topic="$1"
# This folder contains personal files which is omitted by .gitignore
# so we create it each time a user clones the repo for the first time
tempdir="${BSHOME}/temp"
if [ ! -d $tempdir ]; then
echo "Creating ${tempdir}"
mkdir ${tempdir}
else
echo "${tempdir} already exists"
fi
#filename to write to
filename="${tempdir}/${topic}notes.txt"
read -p "Your note: " note
if [[ $note ]]; then
echo "$date: $note" >> "$filename"
echo "Note '$note' saved to $filename"
exit 0
else
echo "No input; note wasn't saved." 1>&2 /dev/stderr # piping the echo to standard error stream
fi