cmd () { history | tail -${2:-10} | awk -v tofind=${1:-[0-9]} '($0!~/ cmd /) && ($0~tofind) { print }' } its execution is simple: $ cmd [] [ ] If you run cmd alone you pick one of the last commands except "cmd" itself from the last 10 lines of the history file. $ cmd If you specify the variable you pick all the commands matching your criteria $ cmd bash If you specify option and variable you pick all the command matching your criteria in the last rows $ cmd bash 30
No comments:
Post a Comment