Untitled
unknown
sh
a month ago
709 B
1
Indexable
Never
#!/bin/bash function print_usage { echo -en "Usage $0 [arg]\n\n" echo -en "\t--major\tPrint major version number.\n" echo -en "\t--minor\tPrint minor version number.\n" exit 1 } if [[ -n "$2" ]];then echo -en "Too many arguments.\n\n" print_usage fi if [[ -z "$1" ]];then bash --version|awk -F'version ' '/[Bb]ash.*version/ {split($2,a,".");print a[1]"."a[2]}' exit 0 fi case $1 in --major) bash --version|awk -F'version ' '/[Bb]ash.*version/ {split($2,a,".");print a[1]}';; --minor) bash --version|awk -F'version ' '/[Bb]ash.*version/ {split($2,a,".");print a[2]}';; *) echo -en "What are you even doing?\n\n" print_usage;; esac
Leave a Comment