0

A simple example:

Let's say I have one alias being sourced somewhere as:

alias ls 'ls -o'

I'd like to have a second alias add on to this:

alias ls 'ls -a'

So that when I execute it, I'm really getting:

ls -o -a

Is this possible? Of course in the above example, the second overwrites the first.

Why would I want this? The first alias (much more complicated than the example) is publicly shared from the company server, and I'd prefer not duplicate it in case the original is modified.

I'm using C shell.

bdonlan
  • 224,562
  • 31
  • 268
  • 324
ack
  • 14,285
  • 22
  • 55
  • 73
  • I think you will find a much better answer at http://serverfault.com – Andrew Hare Jun 27 '09 at 00:32
  • You *really* need to tell us what shell you're using. One answer assumes bash, but your alias statements are invalid bash aliases (you need to use = to define aliases in bash) – camh Jun 27 '09 at 01:17

1 Answers1

1
eval "$(alias -p|grep '^alias ls='|sed "s/'$/ -o'/")"

Note that this assumes you're using bash.

bdonlan
  • 224,562
  • 31
  • 268
  • 324