Re: Newbie alias question
- From: pk <pk@xxxxxxxxxx>
- Date: Tue, 13 May 2008 17:05:33 +0200
On Tuesday 13 May 2008 16:37, wswilson wrote:
Running in bash mac os 10.4:
alias lc="wc -l $1 | awk '{print $1}'"
Why is the awk command not receiving the output from wc? Am I doing
this completely wrong?
You could do what you want just by doing
wc -l < "$1"
The problem with your code is that you can't pass positional parameters to
aliases. In your case (and in almost all cases, for that matter) you should
use a function instead of an alias:
$ lc () { wc -l "$1" | awk '{print $1}' }
$ cat file2
foo
bar
$ lc file2
2
--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
.
- Follow-Ups:
- Re: Newbie alias question
- From: pk
- Re: Newbie alias question
- References:
- Newbie alias question
- From: wswilson
- Newbie alias question
- Prev by Date: binary edit
- Next by Date: Re: Newbie alias question
- Previous by thread: Newbie alias question
- Next by thread: Re: Newbie alias question
- Index(es):