Skip to content

Instantly share code, notes, and snippets.

@macrat
Created November 11, 2015 13:13
Show Gist options
  • Select an option

  • Save macrat/92404fe1ecee1cabc559 to your computer and use it in GitHub Desktop.

Select an option

Save macrat/92404fe1ecee1cabc559 to your computer and use it in GitHub Desktop.
シェルスクリプトでCGIカウンター的なやつ。flock便利!
#!/bin/bash
file='count.log'
flock ${file} sh -c "expr `cat ${file} 2>/dev/null` + 1 >${file}; echo -e \"Content-Type: text/plain\n`cat ${file}`\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment