Alias for Multiple Sequential Commands?

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?

1 Answer

Correct. Use a function instead.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest