copy and create destination directory using bash

0 votes

Can a command or flag create a directory in our desired destination? (considering it does not exist already)

for example,

cp -? file /path/to/copy/file/to/is/very/deep/there
Jul 15, 2019 in Linux Administration by Shubham
• 13,370 points
61 views

1 answer to this question.

0 votes
mkdir -p "$d" && cp file "$d"

try this

answered Jul 15, 2019 by Upasana
• 8,570 points

Related Questions In Linux Administration

0 votes
1 answer

redirecting stdout and stderr to file using bash

cmd >>file.txt 2>&1 Bash always executes and redirects ...READ MORE

answered Mar 19, 2019 in Linux Administration by ajs3033
• 7,280 points
110 views
+1 vote
3 answers
0 votes
1 answer

how to loop through the content of a file using bash

One of the ways to do it ...READ MORE

answered Feb 15, 2019 in Linux Administration by ajs3033
• 7,280 points
156 views
0 votes
1 answer

How to extract file base name without path and extension in bash?

You don't actually have to call the ...READ MORE

answered May 31, 2019 in Linux Administration by Shubham
• 13,370 points
354 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to run Unix shell script from Java code?

ProcessBuilder pb = new ProcessBuilder("myshellScript.sh", "myArg1", "myArg2"); ...READ MORE

answered Oct 26, 2018 in Java by Daisy
• 8,090 points
679 views
0 votes
1 answer

Adding yes/no/cancel prompts in shell script

You can use the read command. Here's ...READ MORE

answered Mar 12, 2019 in Linux Administration by ajs3033
• 7,280 points
68 views
0 votes
1 answer

HTTP POST and GET using cURL

You can just add | grep }| ...READ MORE

answered Jul 22, 2019 in Linux Administration by Upasana
• 8,570 points
77 views
0 votes
1 answer