The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing non Awk Argument in Awk saifurshaon Shell Programming and Scripting 1 03-19-2009 06:57 AM
passing Argument Shahul Shell Programming and Scripting 4 11-13-2008 08:50 AM
How to create a alias with an argument ting123 UNIX for Dummies Questions & Answers 1 07-11-2007 08:43 PM
passing argument into awk prkfriryce Shell Programming and Scripting 4 02-01-2007 04:44 PM
1 alias 2 commands 1 argument seba UNIX for Dummies Questions & Answers 3 09-01-2001 12:26 AM

Reply
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 06-19-2009
ramparts ramparts is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 5
Using * when passing argument to alias

I have some folders with this structure:

/data/me/a123xxx

Where "xxx" is some changing series of letters, and "123" changes so folders might look like:
Code:
/data/me/a123xxx
/data/me/a234ysd
/data/me/a534sds

etc. The numbers are what matter to me (they identify the folder), so I created an alias:

alias gal 'cd /data/me/a\!*'

So if I type gal 123* it'll bring me into the first folder.

But I'd like to have to just type in gal 123 (and not have the * there). How do I put that * into the alias?

---------- Post updated 06-19-09 at 02:22 PM ---------- Previous update was 06-18-09 at 07:44 PM ----------

That might have been too long, here's a shorter version of my question:

How do I make an alias for a command "gal" so that if I type in:


Code:
gal 123

It will be interpreted as:


Code:
cd /data/me/a123*


Last edited by Yogesh Sawant; 06-19-2009 at 10:11 AM.. Reason: added code tags
  #2 (permalink)  
Old 06-19-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,805
Create a function - not an alias. Put it in your login script.
  #3 (permalink)  
Old 06-19-2009
ramparts ramparts is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 5
Thanks! I've never used functions before in UNIX - what would that look like?

---------- Post updated at 06:19 PM ---------- Previous update was at 04:00 PM ----------

Oh, also, I'm using CSH (putting this all in my .cshrc file).... doing some reading it seems like this doesn't support functions? So.... is there any way for me to do what I'm trying to in my .cshrc?
  #4 (permalink)  
Old 06-22-2009
wireonfire wireonfire is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 19
You don't need to use function for csh - argument can be passed to alias in csh. Function is only for bash.
  #5 (permalink)  
Old 06-22-2009
ramparts ramparts is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 5
Thanks... so how do I pass the argument to alias in csh? I think since the argument has a * in it (!*), I can't pass an actual * immediately afterward.
  #6 (permalink)  
Old 06-22-2009
wireonfire wireonfire is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 19
alias ee "more /usr/include/asm-generic/errno-base.h | grep $1" -- alias in .cshrc

to use it,
$ ee 11

But don't know if it'll work for your case, which is more complicated.
  #7 (permalink)  
Old 06-22-2009
ramparts ramparts is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 5
Thanks! So... what does that do? I tried that in my shell and got "define EAGAIN", "try again", etc.
Reply

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 02:20 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