[LUNA] simple(ton?) bash question ....
Paul F. Pearson
pfpearson at mchsi.com
Fri Nov 21 10:49:40 CST 2014
(1) Consider some of the bash and bourne shell tutorials.
(2) when declaring functions in bash/sh, you use empty parens. Also, the keyword 'function' is a bash-ism -- not wrong, but IMO it doesn't add much.
(3) You likely should consider using quotes as a habit, to help avoid corner cases (sadly, some file names contain whitespace).
Here's my take on what you're trying to acheive (hasn't been tested, so beware...).
$ lltr10 () { lltr "$*" | tail -10 }
$ export lltr10
or
$ function lltr10 () { lltr "$*" | tail -10 }
$ export lltr10
------
Paul F. Pearson
We all laugh in the same language
----- "William A. Mahaffey III" <wam at hiwaay.net> wrote:
> .... I am trying to setup some aliases under bash. Since bash
> apparently
> can't use positional parameters in aliases, I am then trying a
> function:
>
>
> [root at Q6600:/etc, Tue Nov 18, 10:54 AM] 1075 # function lltr10 (lltr
> $*
> | tail -10); export lltr10
> -bash: syntax error near unexpected token `ls'
> [root at Q6600:/etc, Tue Nov 18, 10:54 AM] 1076 # function lltr10 (lltr
> "$*" | tail -10); export lltr10
> -bash: syntax error near unexpected token `ls'
> [root at Q6600:/etc, Tue Nov 18, 10:55 AM] 1077 # function lltr10 (lltr
> "$@" | tail -10); export lltr10
> -bash: syntax error near unexpected token `ls'
> [root at Q6600:/etc, Tue Nov 18, 10:55 AM] 1078 # function lltr10 (lltr
> $@
> | tail -10); export lltr10
> -bash: syntax error near unexpected token `ls'
> [root at Q6600:/etc, Tue Nov 18, 10:55 AM] 1079 # which lltr
> alias lltr='llt -r'
> [root at Q6600:/etc, Tue Nov 18, 11:00 AM] 1080 # which llt
> alias llt='ll -t'
> [root at Q6600:/etc, Tue Nov 18, 11:00 AM] 1081 # which ll
> alias ll='la -lis'
> [root at Q6600:/etc, Tue Nov 18, 11:00 AM] 1082 # which la
> alias la='lf -a'
> [root at Q6600:/etc, Tue Nov 18, 11:00 AM] 1083 # which lf
> alias lf='ls -F'
> /bin/ls
> [root at Q6600:/etc, Tue Nov 18, 11:00 AM] 1084 #
>
> What am I doing wrong here :-/ ? TIA for any & all clues ....
>
>
> --
>
> William A. Mahaffey III
>
>
> ----------------------------------------------------------------------
>
> "The M1 Garand is without doubt the finest implement of war
> ever devised by man."
> -- Gen. George S. Patton Jr.
>
> _______________________________________________
> LUNA mailing list
> LUNA at lunagroup.us
> http://lunagroup.us/mailman/listinfo/luna
More information about the LUNA
mailing list