| Author |
problems with quoting
|
|
| Mark P 2005-10-25, 5:53 pm |
| I'm trying to write a little alias (in tcsh) to display the .h and .cpp
files in a directory. I can do this at the command line as:
find . -maxdepth 1 | egrep '\.(h|cpp)$'
When I try to define this as an alias however:
alias srcfind "find . -maxdepth 1 | egrep '\.(h|cpp)$'"
I get "Illegal variable name." I believe this is because of the $ but I
can't figure how to prevent the shell from trying to expand this. Any
suggestions?
Thanks,
Mark
| |
| Christophe Gaubert 2005-10-25, 5:53 pm |
| Mark P a écrit :
> I'm trying to write a little alias (in tcsh) to display the .h and .cpp
> files in a directory. I can do this at the command line as:
>
> find . -maxdepth 1 | egrep '\.(h|cpp)$'
Why not :
ls *.cpp *.h
?
--
Christophe Gaubert
http://perso.wanadoo.fr/christophe.gaubert
Mail posté depuis un système libre GNU/Linux
| |
| Michael Tosch 2005-10-25, 5:53 pm |
| Mark P wrote:
> I'm trying to write a little alias (in tcsh) to display the .h and .cpp
> files in a directory. I can do this at the command line as:
>
> find . -maxdepth 1 | egrep '\.(h|cpp)$'
>
> When I try to define this as an alias however:
>
> alias srcfind "find . -maxdepth 1 | egrep '\.(h|cpp)$'"
>
> I get "Illegal variable name." I believe this is because of the $ but I
> can't figure how to prevent the shell from trying to expand this. Any
> suggestions?
>
alias srcfind "find . -maxdepth 1 | egrep '\.(h|cpp)"\$"'"
seems to work - the $ is \escaped outside the "string".
However, your expression is faster and more precise with
find . -maxdepth 1 \( -name '*.h' -o -name '*.cpp' \)
or
ls -1 *.h *.cpp
--
Michael Tosch @ hp : com
| |
| Mark P 2005-10-25, 5:53 pm |
| Christophe Gaubert wrote:
> Mark P a écrit :
>
>
>
> Why not :
> ls *.cpp *.h
> ?
>
>
Why not indeed. As you can see I'm quite a newb. Thanks for the tip.
| |
| Mark P 2005-10-25, 5:53 pm |
| Michael Tosch wrote:
> Mark P wrote:
>
>
>
> alias srcfind "find . -maxdepth 1 | egrep '\.(h|cpp)"\$"'"
>
> seems to work - the $ is \escaped outside the "string".
>
> However, your expression is faster and more precise with
>
> find . -maxdepth 1 \( -name '*.h' -o -name '*.cpp' \)
Thanks. I hadn't known about the boolean options.
>
> or
>
> ls -1 *.h *.cpp
>
As always, I miss the obvious 
Thanks,
Mark
|
|
|
|