]> apps.delaporte.us Git - minion.git/blobdiff - bin/mg
Fix for bash octal
[minion.git] / bin / mg
diff --git a/bin/mg b/bin/mg
index e803fe65a39790e9b17d3b44d6c2eb594ce9eca0..567d1b4e2b71d7d5960774f23c19b5d3396b8f49 100755 (executable)
--- a/bin/mg
+++ b/bin/mg
@@ -4,13 +4,16 @@
 # Optionally include a second search term
 
 year=`date +%Y`
+month=`date +%m`
 # File to gather all content into
 topic=$1
 if [ ! -n "$1" ]; then
        echo "A topic to gather is required."
        exit 1
 fi
-fname=$(printf "$HOME/Journal/$year/%02d-$topic.md" $(date +%m))
+
+mkdir -p "$HOME/Journal/$year"
+fname="$HOME/Journal/$year/$month-$topic.md"
 archive="$HOME/Journal/archive-$year/" 
 
 # Files to gather
@@ -28,7 +31,7 @@ fi
 if [ -n "$more_files" ]; then
        echo "Will merge $more_files into $fname"
 else
-       echo "Nothing to gather for $2"
+       echo "No second keyword."
 fi
 
 echo ""
@@ -39,13 +42,21 @@ if [[ ! $input == "Y" && ! $input == "y" ]]; then
        exit 1
 fi
 
-echo "Huzzah!"
-cat $files >> $fname.gathered
+for f in $files; do
+       echo "Gathering $f into $fname"
+       cat "$f" >> "$fname.gathered"
+done
+
 mkdir -p $archive
 mv $files $archive
 
 if [ -n "$more_files" ]; then
-       cat $more_files >> $fname.gathered
+
+       for f in $more_files; do
+               echo "Gathering $f into $fname"
+               cat "$f" >> "$fname.gathered"
+       done
+
        mv $more_files $archive
 fi