LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   alias issue (https://www.linuxquestions.org/questions/programming-9/alias-issue-699094/)

DoME69 01-22-2009 05:52 AM

alias issue
 
how can i use 2 words for alias

example
alias kuku kuak 'bla bla bla'

rizhun 01-22-2009 06:00 AM

DoME69,

I don't think that's possible, you may have to make do with an under-score -- kuku_kuak

wje_lq 01-22-2009 06:01 AM

In bash, you can't.

DoME69 01-22-2009 06:09 AM

Quote:

Originally Posted by wje_lq (Post 3417233)
In bash, you can't.

I`m using cshell.

rizhun 01-22-2009 06:23 AM

I don't think the shell is relevant.
*nix works with: <cmd> <args>
So, kuak is always going to be an argument.

You'll have to frig it, save the following as kuku:

Code:

#!/bin/bash

ARG=$1

[[ ${ARG} = "kuak" ]] && {
  /path/to/script/you/want/to/alias -options
}

Then make it executable:
Code:

$ chmod +x kuku
Then, as long as the dir its saved in is in your $PATH, you can run:
Code:

kuku kuak
NB: ^^ this is weird.

pixellany 01-22-2009 06:43 AM

Quote:

Originally Posted by DoME69 (Post 3417239)
I`m using cshell.

I don't see how you could do this on any Unix-like system.

Suppose I type "pwd dog". since pwd does not take any arguments, "dog" is simply ignored. If I then enter "dog pwd", it tells me that "dog" is not a valid command.

I tried to create a two-word alias:
Code:

[mherring@Ath ~]$ alias one two="ls -l"
bash: alias: one: not found
[mherring@Ath ~]$ alias "one two"="ls -l"
bash: alias: `one two': invalid alias name
[mherring@Ath ~]$

In the first case, alias tries to print the existing value of the alias "one" which does not exist. It then correctly creates the alias "two".

In the second case, alias does the right thing and refuses to create the two-word alias.

So---try this on cshell and see if it's any different.

colucix 01-22-2009 09:37 AM

What the second word is intended to be? Please, can you provide a practical example of what do you want to achieve? In other words, why two separate words are a requirement and prevent the usage of the underscore instead of the blank space? If the second word is intended as an argument, I've already shown the usage of alias arguments in C-shell in your previous thread.

wje_lq 01-22-2009 11:16 AM

The paranoid in me is wondering whether the goal of the above thread is the same as the goal of this thread and the goal of this thread.

pixellany 01-22-2009 12:01 PM

Quote:

Originally Posted by wje_lq (Post 3417536)
The paranoid in me is wondering whether the goal of the above thread is the same as the goal of this thread and the goal of this thread.

Perhaps DoME69 will share with us what the end goal is......


All times are GMT -5. The time now is 05:09 AM.