别名'grep -w'标签''仅搜索第一个单词(标签)

时间:2013-02-23 11:17:57

标签: linux shell grep alias

alias cgrep='current_dir_grep'
function current_dir_grep_exact {
grep -w $1 .
}
alias cgrepe='current_dir_grep_exact'

grep -w 'label for' .有效,但cgrepe 'label for'只会搜索label的出现次数,而我希望在当前目录中找到出现label for

2 个答案:

答案 0 :(得分:1)

将参数放在引号中:

grep -w "$1" .

答案 1 :(得分:0)

bash(1)中,别名不接受参数。它有时看起来像他们一样,但他们没有。使用功能。