The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
question about alias hcliff Shell Programming and Scripting 1 03-04-2008 05:07 AM
One Question related to alias neerajrathi2 UNIX for Advanced & Expert Users 4 01-24-2008 05:43 AM
I/O and alias question cleansing_flame UNIX for Dummies Questions & Answers 2 11-15-2007 04:42 PM
a question about alias command jayyu317 UNIX for Dummies Questions & Answers 1 12-11-2006 11:07 PM
Alias's & Functions - simple question kornshellmaven Shell Programming and Scripting 6 11-01-2002 09:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2006
ospreyeagle ospreyeagle is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 3
unix question: user supplied input for 'alias'

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.
  #2 (permalink)  
Old 04-11-2006
dsbeerf's Avatar
dsbeerf dsbeerf is offline
Registered User
  
 

Join Date: Dec 2005
Location: Chicago, IL USA
Posts: 58
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.

Last edited by dsbeerf; 04-12-2006 at 01:40 AM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:38 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0