Alias for multiple sequential commands?

2

1

How do I create an alias c that will cd and then immediately ls?

alias c='cd; ls'

Is there some kind of way to insert a special variable that represents the input? Or is that not the way that alias operates at all?

funk-shun

Posted 2011-04-21T06:50:10.667

Reputation: 1 503

Answers

6

Correct. Use a function instead.

c() { cd "$1" ; ls ; }

Ignacio Vazquez-Abrams

Posted 2011-04-21T06:50:10.667

Reputation: 100 516

1OMG - what keywords can I use to Google on more similar stuff like this? – funk-shun – 2011-04-21T06:59:59.193

2http://tldp.org/LDP/abs/html/ – Ignacio Vazquez-Abrams – 2011-04-21T07:05:23.033