You are here

generate.sh in Lightning Workflow 8.3

#!/bin/bash

for file in $(ls *.md); do
  # Strip the .md extension off to determine the git tag.
  tag="${file%.*}"

  # Get the touch-compatible time that the tag was created.
  time=$(git tag --list $tag --format="%(creatordate:format:%Y%m%d%H%M.%S)")

  if [ $time ]; then
    # Update the file's modification time.
    touch -t $time $file
  else
    # Use the current time.
    touch $file
  fi
done

# List all the .md files, ordered by modification time, and
# cat each one, followed by an empty line. Finally, delete
# the last line of the output, since it's blank.
ls -t *.md | xargs -I{} sh -c "cat {}; echo" | sed '$ d'

File

logs/generate.sh
View source
  1. #!/bin/bash
  2. for file in $(ls *.md); do
  3. # Strip the .md extension off to determine the git tag.
  4. tag="${file%.*}"
  5. # Get the touch-compatible time that the tag was created.
  6. time=$(git tag --list $tag --format="%(creatordate:format:%Y%m%d%H%M.%S)")
  7. if [ $time ]; then
  8. # Update the file's modification time.
  9. touch -t $time $file
  10. else
  11. # Use the current time.
  12. touch $file
  13. fi
  14. done
  15. # List all the .md files, ordered by modification time, and
  16. # cat each one, followed by an empty line. Finally, delete
  17. # the last line of the output, since it's blank.
  18. ls -t *.md | xargs -I{} sh -c "cat {}; echo" | sed '$ d'