Often I run into a problem, I need to create a directory using mkdir and I have to cd into it. Some times I need to create a directory structure like this: ~/code/folder/sub_folder, the folder might be missing or the code might be missing. So I found the following shell command which will mkdir with padding and changes i.e cd to the created directory.

I think an alias could do that. Another good one is cd then ls.

09 hilabete

An alias only runs a single command

29 hilabete

Nice short helper!

Why would you eval cd "\"\$$#\"" ??? So you’re passing all arguments to mkdir potentially making several folders (mkcd test1/foo1 test2/foo2), then moving into the last provided argument ($# is 1 when there is one argument and $1 is the argument) via some exec magic. To be fair it does look safe (but execs always look safe :D) but why not move into the first provided argument instead (&& cp "$1") and avoid that dance entirely?

29 hilabete

I have a little function for that

mkdirpushd () {
        mkdir -p ${1}
        pushd ${1}

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.


  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

  • 0 users online
  • 15 users / day
  • 22 users / week
  • 57 users / month
  • 234 users / 6 months
  • 19 subscribers
  • 1.74K Posts
  • Modlog