LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-22-2009, 05:52 AM   #1
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Rep: Reputation: 16
alias issue


how can i use 2 words for alias

example
alias kuku kuak 'bla bla bla'
 
Old 01-22-2009, 06:00 AM   #2
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
DoME69,

I don't think that's possible, you may have to make do with an under-score -- kuku_kuak
 
Old 01-22-2009, 06:01 AM   #3
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
In bash, you can't.
 
Old 01-22-2009, 06:09 AM   #4
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by wje_lq View Post
In bash, you can't.
I`m using cshell.
 
Old 01-22-2009, 06:23 AM   #5
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
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.

Last edited by rizhun; 01-22-2009 at 06:24 AM.
 
Old 01-22-2009, 06:43 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by DoME69 View Post
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.
 
Old 01-22-2009, 09:37 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 01-22-2009, 11:16 AM   #8
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
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.
 
Old 01-22-2009, 12:01 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by wje_lq View Post
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......
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Alias issue Atif_Khan Linux - Server 1 02-01-2007 12:31 PM
bashrc alias issue noir911 Linux - General 1 08-22-2006 05:24 AM
IP Alias issue Droo Linux - Networking 2 05-25-2006 05:47 PM
Bash alias: issue with character riotxix Linux - General 3 02-17-2006 10:00 PM
Alias question (2 commands for one alias) gflores Linux - Newbie 3 01-21-2006 12:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration