0

i'm creating a small shell script, and i want to know if is there a builtin command to create a new folder without using the mkdir command. I googled it but i wasn't able to find a way to do that.

I dont have any specific motivation or restriction to do that, is more a curiosity about the builtin commands on bash.

I imagine is somenthing like the touch file => > file

Regars

demonofnight
  • 119
  • 1
  • 4

2 Answers2

3

This is not a 'builtins' solution (like touch is not a builtin), but it is a bash friendly solution.

Since this is a script, you imply planning. With this in mind, you create a directory, which you plan to use when the need arises within your script. When you need a new, empty directory, you will use the 'cp -r' command.

You would create a directory: /tmp/seed

In your script you need a directory called blue2013.

cp -r /tmp/seed ./blue123
RobW
  • 2,766
  • 1
  • 17
  • 22
  • 1
    If you want to make sure the directory stays empty so the recursive copy only copies the directory, `chmod -w /tmp/seed` Also, you may want to put your seed directory somewhere else so it doesn't get automatically deleted. – Dennis Williamson Jul 03 '13 at 18:35
2

We generally don't play games here and artificially restrict what can and can't be used just for the fun of it. The builtin commands are

bash, :, ., [, alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, com- popt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, true, type, typeset, ulimit, umask, unalias, unset, wait

You can find out more about them using man builtins.

user9517
  • 114,104
  • 20
  • 206
  • 289
  • 3
    It is useful to know alternatives for non-builtins such as `mkdir` or `ls` when working on a broken system. By the way, `echo *` is the substitute for `ls`. – Dennis Williamson Jul 03 '13 at 17:57