I tried something like:
alias fdi 'find . -type d -iname "*\!^*"'
but this only looks for exact names passed as argument.
fdi abc
will only output:
./d/abc
not this:
./d/greabcyup
I am not just looking for exact name. It should also show ./d/greabcyup
Update: I did
echo $0
tcsh
Is this c-shell or tcsh?
I dbl-checked with orielly lunix in a nutshell , !^
is meant to be the first word in the current command line, so I don't think it is doing what you want.
You can dbl check that theory for yourself, with echo abc def !^
from cmd-line. (I don't have a csh handy).
But it's clear that when you create the alias, it is not getting the first word (alias) OR the first word of the alias (find) embedded in the alias. It's probably about the order of evaluation for csh.
In general any alias in most shells (not just csh) can't take arguments. It will append whatever was included on the invocation at the end. So your alias expands, with the abc argument as
find . -type d -iname abc
And the results your getting, support that. (You might see something helpful by turning on the csh debugging, by changing your top hash-bang line to #!/bin/csh -vx
)
This is why other shells have functions,
function fdi() {
find . -type d -iname "$@"
}
If you can't use another shell because of policy, (bash,ksh,zsh are all powerful programming languages), and you're going to use csh regularly, be sure to pickup a copy of the 'The Unix C shell Field Guide, Gail & Paul Anderson. A really exceptionally well written book.
IHTH.