I am trying to create an alias which when given some argument will look for the folder with contains the argument as pattern. Let the alias name be gohf.
Now, I will be using this alias like gohf <some-pattern>, for eg. gohf testing. Now this should look for a folder that contains “testing” in its name and take me to that folder in the last step.
Following is what I could think of.
alias gohf='cd `find . -type d | grep testing`';
The above alias works when the pattern is always “testing”.
How can I modify so that if the alias is used as say gohf game, then the alias should take me to the folder that contains game in its name.
Note:
Shell: ksh
I am assuming that there is only one folder for each pattern I input.
findtogrepis bad practice. the-nameor-inameflags do the same thing and can handle regex as well – h3rrmiller Jan 23 at 15:37gohf() { cd ´find . -type d | grep $1´ }...I copied this function to my .profile...but I get thegohf{: command not found– g4ur4v Jan 23 at 15:39.kshrcand do a. ./kshrc, just to test it. Also, try with what the guy down there suggested in his answer. – Martín Canaval Jan 23 at 15:45