Monday, May 6, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 796  / 2 Years ago, fri, march 25, 2022, 12:39:46

Most of the time when I do a cd command I also do a ls to see what other files or folder are in that directory. So I want to execute ls everytime I change the directory. I know I can do cd foo && ls but is it really necessary to do && ls everytime?


More From » command-line

 Answers
0

There are 2 ways to do this. You can create an alias as LnxSlck posted or another one is creating a function in .bash_aliases



mycd(){ cd "$1" && ls; }

[#36941] Sunday, March 27, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tatoethin

Total Points: 377
Total Questions: 110
Total Answers: 98

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;