Re: awk substitute
On 2006-08-17, Michael Tosch wrote:
>>>
>>> grep "Failed password" /var/log/authlog |tail -5 |
>>> while read line
>>> do
>>> set -f
>>> set -- $line
>>> echo "$1 $2 $3 $9 $10 $11 $12 `host $13`"
>>> done
>
> I see now that positional parameters are limited to $1...$9,
In a Bourne shell one can opnly access the first 9 positional
parameters. In a POSIX shell, all are accessible, but those with
double digits must be enclosed in braces:
echo "$1 $2 $3 $9 ${10} ${11} ${12} `host ${13}`"
> and $10 is treated as {$1}0.
You mean, ${1}0.
> So the shell code must changed to:
>
> grep "Failed password" /var/log/authlog |tail -5 |
> while read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14
> do
> echo "$a1 $a2 $a3 $a9 $a10 $a11 $a12 `host "$a13"`"
> done
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
|