Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- touch test1.txt
- ~/Desktop/$ ls
- ~/Desktop/$
- $ touch ~/Desktop/a/b/c/d/e/f/g/h/1.txt
- -p, --parents
- no error if existing, make parent directories as needed
- mkdir -p ~/Desktop/a/b/c/d/e/f/g/h/ && touch ~/Desktop/a/b/c/d/e/f/g/h/1.txt
- touch2() { mkdir -p "$(dirname "$1")" && touch "$1" ; }
- touch2 ~/Desktop/a/b/c/d/e/f/g/h/1.txt
- #!/bin/bash
- mkdir -p "$(dirname "$1")" &&
- touch "$1"
- touch2 ~/Desktop/a/b/c/d/e/f/g/h/1.txt
- bash-4.3$ install -D /dev/null mydir/one/two
- bash-4.3$ tree mydir
- mydir
- └── one
- └── two
- 1 directory, 1 file
- bash-4.3$
- bash-4.3$ for i in mydir/{'subdir one'/{file1,file2},'subdir 2'/{file3,file4}} ; do
- > install -D /dev/null "$i"
- > done
- bash-4.3$ tree mydir
- mydir
- ├── one
- │ └── two
- ├── subdir 2
- │ ├── file3
- │ └── file4
- └── subdir one
- ├── file1
- └── file2
- bash-4.3$ arr=( mydir/{'subdir one'/{file1,file2},'subdir 2'/{file3,file4}} )
- bash-4.3$ for i in "${arr[@]}"; do install -D /dev/null "$i"; done
- bash-4.3$ tree mydir
- mydir
- ├── one
- │ └── two
- ├── subdir 2
- │ ├── file3
- │ └── file4
- └── subdir one
- ├── file1
- └── file2
Add Comment
Please, Sign In to add comment