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,450 points
94 views

1 answer to this question.

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

try this

answered Jul 15, 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,280 points
689 views
+1 vote
3 answers
0 votes
2 answers

how to loop through the content of a file using bash

#!/bin/bash for i in  `cat peptides.txt` do echo $i done READ MORE

answered Sep 4 in Linux Administration by Prakash K. Aithal
690 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,450 points
1,951 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,110 points
2,257 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
928 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
211 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
102 views