Reputation: 11317
I would like to know a solution to the following problem.
Problem: When I enter a number/string on command line, I should be able to interpret it in my own way, and do any action based on the contents of the string e.g. if it is a number then do action1, else do action 2, etc.
Example:
$ 85049
[ This should do 'cd /dir1/dir2/../85049' ]
I cannot make an alias for this, as I can enter any big number.
Any ideas, how to achieve this functionality via bash?
Upvotes: 0
Views: 576
Reputation: 10717
You can use the command_not_found_handle
function.
http://www.gnu.org/software/bash/manual/bashref.html#Command-Search-and-Execution
I don't think that's a very good idea though and would suggest that you rethink your original premise.
Upvotes: 2