Forum: Geek Forum Topic: Unix Question started by: demonk Posted by demonk on Jul. 16 2001,18:33
Ok all you Unix Gurus, I have a question. In your .chsrc or .bashrc or .whatever file you can define aliases, so that I can type ll and realy get the ls -l command. Well, how would I define an alias so that if I did "ll -mycommand" I would get "ls -l -mycommand -secondcommand" or whatever. It's the first part, the defining what will be aliased that I'm having problems with. It will only see the first part of the command, and none of the command line options, and will just spit out an error when the command is run. Hope that wasn't too cryptic.
Posted by damien_s_lucifer on Jul. 16 2001,19:25
csh and similar :alias ll ls -l ũ Ū ū Ŭ continue the $n series if you think you'll ever want to pass more than 4 arguments. bash and similar : this passes ALL arguments; no need to add anything more. This message has been edited by damien_s_lucifer on July 17, 2001 at 02:32 PM Posted by demonk on Jul. 16 2001,19:29
No, I want to do thisalias ll -ũ ls -l -a ũ or something to that extent. Let me give you a real world example: alias (ael def) (ael def -lm1) please ignore the (), I put them there just to show you want is the first part and what is the second part. See if someon types ael def, I want to automatically at that -lm1. But, if someone types ael, I don't want the -lm1 added since it wouldn't work with the def part. Posted by damien_s_lucifer on Jul. 16 2001,19:39
ah. Well, you won't be able to do that with the alias command; you'll have to write a shell script or use Perl.What you're essentially saying is "If there's no argument, do one thing, but if there IS an argument, do something else." In Perl : #!/usr/bin/perl if ($ARGV[1])
This message has been edited by damien_s_lucifer on July 17, 2001 at 02:40 PM |