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 16, 2019 in Linux Administration by Shubham
• 13,490 points
897 views

1 answer to this question.

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

try this

answered Jul 16, 2019 by Upasana
• 8,620 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,300 points
22,307 views
0 votes
0 answers

Send private message to Discord user using bash and linux AT command

I'm running a Discord bot written in ...READ MORE

Apr 25, 2022 in Linux Administration by Edureka
• 13,690 points
1,252 views
0 votes
1 answer

How do you copy and paste into Git Bash

Press Insert. Likewise, to duplicate from the window, ...READ MORE

answered Jun 20, 2022 in Linux Administration by Rahul
• 3,380 points
1,823 views
+1 vote
3 answers
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,140 points
6,495 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 13, 2019 in Linux Administration by ajs3033
• 7,300 points
4,225 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,620 points
1,035 views
0 votes
1 answer

How can I find out which files differ in two directory trees?

Use this; diff -qr dir1/ dir2/ READ MORE

answered Jun 13, 2019 in Linux Administration by Upasana
• 8,620 points
780 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP