| Subject: | Re: How to create parameterized aliases in bashrc |
|---|---|
| From: | Dave B <daveb@xxxxxxxxxxxx> |
| Date: | Sat, 26 Jul 2008 11:03:29 +0200 |
| Newsgroups: | gnu.bash.bug |
Aman Jain wrote:
> Hi
>
> I would like to create an alias to show Nth line of a file.
>
> I tried something like
> alias shline='head -$1 $2 | tail -1' #$1 is the line number and $2
> is the filename
> # Usage should be :
> $ shline 5 file.txt
>
> But it isn't working......
You can't pass parameters to aliases.
> Can anyone suggest a better alternative
Use a function.
shline() { head -n $1 "$2" | tail -n 1; }
--
D.
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | How to create parameterized aliases in bashrc, Aman Jain |
|---|---|
| Next by Date: | Re: kill job vs. pid, Paul Jarc |
| Previous by Thread: | How to create parameterized aliases in bashrc, Aman Jain |
| Next by Thread: | set -x output of test operator is irretating, Toralf Förster |
| Indexes: | [Date] [Thread] [Top] [All Lists] |