mkdir -p "$d" && cp file "$d"
(there’s no such option for cp
).
More Related Contents:
- When should I wrap quotes around a shell variable?
- What’s the magic of “-” (a dash) in command-line parameters?
- Aborting a shell script if any command returns a non-zero value
- What does $@ mean in a shell script?
- Better way to rename files based on multiple patterns
- Forcing bash to expand variables in a string loaded from a file
- What is the difference between using `sh` and `source`?
- Setting environment variables in Linux using Bash
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Does “argument list too long” restriction apply to shell builtins?
- Given two directory trees, how can I find out which files differ by content? [closed]
- How to sort a file in-place?
- How to run a shell script on a Unix console or Mac terminal?
- Using the passwd command from within a shell script
- Is it OK to use the same input file as output of a piped command?
- When to wrap quotes around a shell variable?
- How do you normalize a file path in Bash?
- Linux/Unix command to determine if process is running?
- Running shell script in parallel
- Difference between shell and environment variables
- What’s the point of eval/bash -c as opposed to just evaluating a variable?
- Need to remove the count from the output when using “uniq -c” command
- How do you run a script on login in *nix?
- How to permanently set $PATH on Linux/Unix [closed]
- How can I quickly sum all numbers in a file?
- Bash script process substitution Syntax error: “(” unexpected
- What does `set -x` do?
- Uppercasing First Letter of Words Using SED
- Exit code of variable assignment to command substitution in Bash
- Using `date` command to get previous, current and next month