Skip to content

Instantly share code, notes, and snippets.

@rogersguedes
Created September 12, 2019 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogersguedes/6221f08825470e39f7a2882500cad28e to your computer and use it in GitHub Desktop.
Save rogersguedes/6221f08825470e39f7a2882500cad28e to your computer and use it in GitHub Desktop.
this scripts copies the first file modified in current folder. It was used to backup a config file generated by SW4STM32 during the OpenOCD firmware upload invocation.
#!/bin/bash
# this scripts copies the first file modified in current folder. It was used to backup a config file generated by
# SW4STM32 during the OpenOCD firmware upload invocation.
# 'inotifywait' binary is part of 'inotify-tools' package on Ubuntu 18.04.1 LTS
EVT_OUTPUT=`inotifywait -e modify,create,delete -r .`
FILE_NAME=`echo ${EVT_OUTPUT} | sed "s/[^ ]\+\s\+[^ ]\+\s\+\([^ ]\+\)/\1/g"`
cp ${FILE_NAME} ${FILE_NAME}.bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment