git – getting ALL previous version of a specific file/folder
The script would:
– extract all file versions to /tmp/all_versions_exported
– take 1 argument – relative path to the file inside git repo
– give result filenames numeric prefix (sortable)
– mention inspected filename in result files (to tell apples apart from oranges:)
– mention commit date in the result filename (see output example below)
– not create empty result files
Linux Bash Scripting Part3 – Parameters and Options
To pass data to your shell script, you should use command line parameters.
Options are single letters with a dash before it.
How to Make Simple Graphical Shell Scripts with Zenity on Linux
Zenity adds graphical interfaces to shell scripts with a single command.
Shell parameter expansion: bash native regular expresssion for replacements
The ‘$’ character introduces parameter expansion, command substitution, or arithmetic expansion. The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name.
When braces are used, the matching ending brace is the first ‘}’ not escaped by a backslash or within a quoted string, and not within an embedded arithmetic expansion, command substitution, or parameter expansion.
Create User Accounts with Random Password with a bash script
#!/bin/bash #### # This script automatically creates user accounts with random passwords. # # Author: Russ Sanderlin # Date: 01/21/15 # ### if [ $# -lt 1 ]; then echo "Please supply a user name" echo "Example: " $0 "jsmith" exit fi # Declare local variables, generate random password. newuser=$1 randompw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1) # Create new user and assign random password. useradd $newuser echo $newuser:$randompw | chpasswd echo "UserID:" $newuser "has been created with the following password:" $randompw