I have a program to scan the log files and I want to pipe the output to 'less'.
I want to create an alias such that following are equivalent
scanlog chunky.lst = /udd/n2man/utils/scanlog chunky.lst|less
where chunky is user supplied file which can change.
Is this possible as an alias or do I need to create a script?
thanks,
OE
ps: Sorry for rather uninformative title.
I do not see (upon looking) where you can do this with aliases in ksh. So I am assuming that you want this as generic as possible.
I am recommending using a function. they work in SH, KSH, & BASH.
One way would be:
logscan () {
/udd/n2man/utils/scanlog $1 | less
}
Better would be:
logscan () {
if [ $# -ne 1 ]; then
echo "usage: logscan: logscan <file>"
return 1
fi
}
/udd/n2man/utils/scanlog $1 | less
}
I make it a habit not to name functions the same name as an existing program. Unless I want to FORCE myself NEVER to use the program.
[Which *is* possible.]
P.S.: There STILL exist some versions of the bourne shell that do NOT recognize functions. If you have one, my heart bleeds for you.