2010-07-15 4 views
1

Escaping * omble chevalier dans alias cShellEscaping * ombles dans alias cShell

je veux écrire un C Shell Alias ​​qui peut trouver des fichiers à partir d'un motif

soit l'équivalent de trouver. -name "pattern *"

Le motif myfind doit faire au-dessus de cmd où myfind est le nom d'alias. Comment puis-je échapper au * dans l'alias csh?

alias myfind 'trouver. -name! ** '

Répondre

1

Vous n'avez pas besoin de s'échapper. Cela fonctionne comme -

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

Les guillemets simples sont plus ou moins équivalent à échapper. –

+0

D'accord. J'aurais dû dire "pas besoin d'échapper '*' s spécifiquement" – Gopi

0
# 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" 

exemples à l'invite

/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