GNU “install” -d flag — how's it work?
I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.
In the manpage, it says:
SYNOPSIS
install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
-d, --directory
treat all arguments as directory names; create all components of
the specified directories
OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?
I tried doing a basic test by making an arbitrary directory structure on my local hard disk:
~>tree test
test
├── a
│ └── b
│ └── c
│ └── e.txt
└── d
4 directories, 1 file
And then running install -d and looking at what was created:
~>install -d test test2
~>tree test2
test2
0 directories, 0 files
Nothing happened!
Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.
coreutils
add a comment |
I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.
In the manpage, it says:
SYNOPSIS
install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
-d, --directory
treat all arguments as directory names; create all components of
the specified directories
OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?
I tried doing a basic test by making an arbitrary directory structure on my local hard disk:
~>tree test
test
├── a
│ └── b
│ └── c
│ └── e.txt
└── d
4 directories, 1 file
And then running install -d and looking at what was created:
~>install -d test test2
~>tree test2
test2
0 directories, 0 files
Nothing happened!
Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.
coreutils
add a comment |
I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.
In the manpage, it says:
SYNOPSIS
install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
-d, --directory
treat all arguments as directory names; create all components of
the specified directories
OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?
I tried doing a basic test by making an arbitrary directory structure on my local hard disk:
~>tree test
test
├── a
│ └── b
│ └── c
│ └── e.txt
└── d
4 directories, 1 file
And then running install -d and looking at what was created:
~>install -d test test2
~>tree test2
test2
0 directories, 0 files
Nothing happened!
Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.
coreutils
I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.
In the manpage, it says:
SYNOPSIS
install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
-d, --directory
treat all arguments as directory names; create all components of
the specified directories
OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?
I tried doing a basic test by making an arbitrary directory structure on my local hard disk:
~>tree test
test
├── a
│ └── b
│ └── c
│ └── e.txt
└── d
4 directories, 1 file
And then running install -d and looking at what was created:
~>install -d test test2
~>tree test2
test2
0 directories, 0 files
Nothing happened!
Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.
coreutils
coreutils
edited Oct 22 '14 at 16:16
derobert
74.5k8162216
74.5k8162216
asked Sep 22 '11 at 15:30
ashgromniesashgromnies
411148
411148
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
It looks like the install -D command is actually what I want.
Manpage:
-D create all leading components of DEST except the last, then copy SOURCE to DEST
Works great, except you have to specify every file individually.
8
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick withcp -r
– dtmland
Jul 8 '15 at 20:11
5
Does the install command have an equivalent tocp -r?
– Alexander
Jul 8 '16 at 10:53
add a comment |
install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp
2
Basically,install -dis the same asmkdirexcept that you can specify the mode, owner, SELinux context, and group all at once.
– ZiggyTheHamster
Aug 28 '17 at 19:40
add a comment |
Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY
find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f21260%2fgnu-install-d-flag-hows-it-work%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
It looks like the install -D command is actually what I want.
Manpage:
-D create all leading components of DEST except the last, then copy SOURCE to DEST
Works great, except you have to specify every file individually.
8
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick withcp -r
– dtmland
Jul 8 '15 at 20:11
5
Does the install command have an equivalent tocp -r?
– Alexander
Jul 8 '16 at 10:53
add a comment |
It looks like the install -D command is actually what I want.
Manpage:
-D create all leading components of DEST except the last, then copy SOURCE to DEST
Works great, except you have to specify every file individually.
8
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick withcp -r
– dtmland
Jul 8 '15 at 20:11
5
Does the install command have an equivalent tocp -r?
– Alexander
Jul 8 '16 at 10:53
add a comment |
It looks like the install -D command is actually what I want.
Manpage:
-D create all leading components of DEST except the last, then copy SOURCE to DEST
Works great, except you have to specify every file individually.
It looks like the install -D command is actually what I want.
Manpage:
-D create all leading components of DEST except the last, then copy SOURCE to DEST
Works great, except you have to specify every file individually.
answered Sep 22 '11 at 15:48
ashgromniesashgromnies
411148
411148
8
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick withcp -r
– dtmland
Jul 8 '15 at 20:11
5
Does the install command have an equivalent tocp -r?
– Alexander
Jul 8 '16 at 10:53
add a comment |
8
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick withcp -r
– dtmland
Jul 8 '15 at 20:11
5
Does the install command have an equivalent tocp -r?
– Alexander
Jul 8 '16 at 10:53
8
8
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with
cp -r– dtmland
Jul 8 '15 at 20:11
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with
cp -r– dtmland
Jul 8 '15 at 20:11
5
5
Does the install command have an equivalent to
cp -r?– Alexander
Jul 8 '16 at 10:53
Does the install command have an equivalent to
cp -r?– Alexander
Jul 8 '16 at 10:53
add a comment |
install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp
2
Basically,install -dis the same asmkdirexcept that you can specify the mode, owner, SELinux context, and group all at once.
– ZiggyTheHamster
Aug 28 '17 at 19:40
add a comment |
install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp
2
Basically,install -dis the same asmkdirexcept that you can specify the mode, owner, SELinux context, and group all at once.
– ZiggyTheHamster
Aug 28 '17 at 19:40
add a comment |
install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp
install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp
answered Sep 22 '11 at 15:44
Michael Mrozek♦Michael Mrozek
61.7k29192211
61.7k29192211
2
Basically,install -dis the same asmkdirexcept that you can specify the mode, owner, SELinux context, and group all at once.
– ZiggyTheHamster
Aug 28 '17 at 19:40
add a comment |
2
Basically,install -dis the same asmkdirexcept that you can specify the mode, owner, SELinux context, and group all at once.
– ZiggyTheHamster
Aug 28 '17 at 19:40
2
2
Basically,
install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.– ZiggyTheHamster
Aug 28 '17 at 19:40
Basically,
install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.– ZiggyTheHamster
Aug 28 '17 at 19:40
add a comment |
Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY
find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;
add a comment |
Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY
find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;
add a comment |
Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY
find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;
Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY
find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;
answered 39 mins ago
geckosgeckos
1412
1412
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f21260%2fgnu-install-d-flag-hows-it-work%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown