Append date to filename in linux

Info/Summary With bash scripting you can enclose commands in back ticks or parantheses. This works great for labling files, the following wil create a file name with the date appended to it. Methods Backticks – $ echo myfilename-“`date +”%d-%m-%Y”`” $(parantheses) – : $ echo myfilename-$(date +”%d-%m-%Y”) Example Usage: echo “Hello World” > “/tmp/hello-$(date +”%d-%m-%Y”).txt” (creates … Read more

How to monitor a complete directory tree for changes in Linux?

I’ve done something similar using the inotifywait tool: #!/bin/bash while true; do inotifywait -e modify,create,delete -r /path/to/your/dir && \ <some command to execute when a file event is recorded> done This will setup recursive directory watches on the entire tree and allow you to execute a command when something changes. If you just want to … Read more

How do I change bash history completion to complete what’s already on the line?

Probably something like # ~/.inputrc “\e[A”: history-search-backward “\e[B”: history-search-forward or equivalently, # ~/.bashrc if [[ $- == *i* ]] then bind ‘”\e[A”: history-search-backward’ bind ‘”\e[B”: history-search-forward’ fi (the if statement checks for interactive mode) Normally, Up and Down are bound to the Readline functions previous-history and next-history respectively. I prefer to bind PgUp/PgDn to these … Read more