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.
Excuse me for using the wrong " ` "
– lmcanavals Jan 23 '13 at 15:27findtogrepis bad practice. the-nameor-inameflags do the same thing and can handle regex as well – h3rrmiller Jan 23 '13 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 '13 at 15:39.kshrcand do a. ./kshrc, just to test it. Also, try with what the guy down there suggested in his answer. – lmcanavals Jan 23 '13 at 15:45ksh .profile– g4ur4v Jan 23 '13 at 15:47$(…)in your code:gohf() { cd $(find . -type d | grep $1); }. – manatwork Jan 23 '13 at 15:50()? – g4ur4v Jan 23 '13 at 15:52stuff?, 2)$(…)doesn't conflict with Markdown syntax. – manatwork Jan 23 '13 at 15:55