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 in Linux Administration by Shubham
• 13,290 points
20 views

1 answer to this question.

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

try this

answered Jul 15 by Upasana
• 8,530 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 in Linux Administration by ajs3033
• 7,280 points
36 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 in Linux Administration by ajs3033
• 7,280 points
66 views
0 votes
1 answer
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,050 points
102 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 in Linux Administration by ajs3033
• 7,280 points
28 views
0 votes
1 answer

HTTP POST and GET using cURL

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

answered Jul 22 in Linux Administration by Upasana
• 8,530 points
17 views
0 votes
1 answer