开发者

Escaping * char in cshell alias

Escaping * char in cshell 开发者_StackOverflow社区alias

i want to write a C Shell Alias which can find files starting with a pattern

ie equivalent of find . -name "pattern*"

myfind pattern should do above cmd where myfind is the alias name. How do i escape the * in csh alias ?

alias myfind 'find . -name !**'


You dont need to escape. This works as -

alias myfind "find . -name 'pattern*'"


# the above post doesn't take into account \* arguments (including spaces in arguments)


# The original alias is useful for when you have time to type quotes or your
# arguments need to be regular expressions
alias ff 'find . -iname \!* -follow -print'

# alias fff (below) is of limited utility, because your arguments can't be regular
# expressions or enclosed in quotes.  It is useful for quick and dirty situations
# when you want to cut and paste things with spaces in them without using quotes.
# the combination of double quotes and single quotes here is very important.
# rules of thumb for "I hate typing quotes" style aliases:
#   enclose alias arguments \* in this construct:    '"\*"'
#   conversely, enclose wildcards in this construct: "'*'"
alias fff "find . -iname '*'"'"\!*"'"'*' -follow -print"

examples at prompt

/Projects/mbox/Installers/Mbox Studio Installer>alias ff
find . -iname !* -follow -print
/Projects/mbox/Installers/Mbox Studio Installer>ff "Mbox *.app"
./ROOT/Applications/Mbox Studio/Mbox Remote.app
./ROOT/Applications/Mbox Studio/Mbox Studio.app
./ROOT/Applications/Mbox Utilities/Mbox Controller.app
/Projects/mbox/Console>alias fff
find . -iname '*'"!*"'*' -follow -print
/Projects/mbox/Installers/Mbox Studio Installer>fff Mbox Studio
./NightlyBuild/DiskImages/Mbox Studio 3.6D3435.dmg
./NightlyBuild/DiskImages/Mbox Studio 3.6D3438.dmg
./ROOT/Applications/Mbox Studio
./ROOT/Applications/Mbox Studio/Mbox Studio.app
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜