Is there a way to create a directory and access it in a single command chain?
I wanted to create a directory and access it after creation in a single command chain using:
mkdir directory_name && cd directory_name
is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?
to be able to make a directory and access it without repeating the directory name?
linux bash
add a comment |
I wanted to create a directory and access it after creation in a single command chain using:
mkdir directory_name && cd directory_name
is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?
to be able to make a directory and access it without repeating the directory name?
linux bash
2
Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?
– Kamil Maciorowski
Jan 31 at 15:16
I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.
– Mrwan Ashraf
Jan 31 at 15:18
On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?
– Bodo
Jan 31 at 15:33
@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.
– Mrwan Ashraf
Jan 31 at 15:37
add a comment |
I wanted to create a directory and access it after creation in a single command chain using:
mkdir directory_name && cd directory_name
is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?
to be able to make a directory and access it without repeating the directory name?
linux bash
I wanted to create a directory and access it after creation in a single command chain using:
mkdir directory_name && cd directory_name
is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?
to be able to make a directory and access it without repeating the directory name?
linux bash
linux bash
edited Jan 31 at 15:22
Mrwan Ashraf
asked Jan 31 at 15:14
Mrwan AshrafMrwan Ashraf
13
13
2
Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?
– Kamil Maciorowski
Jan 31 at 15:16
I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.
– Mrwan Ashraf
Jan 31 at 15:18
On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?
– Bodo
Jan 31 at 15:33
@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.
– Mrwan Ashraf
Jan 31 at 15:37
add a comment |
2
Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?
– Kamil Maciorowski
Jan 31 at 15:16
I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.
– Mrwan Ashraf
Jan 31 at 15:18
On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?
– Bodo
Jan 31 at 15:33
@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.
– Mrwan Ashraf
Jan 31 at 15:37
2
2
Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?
– Kamil Maciorowski
Jan 31 at 15:16
Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?
– Kamil Maciorowski
Jan 31 at 15:16
I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.
– Mrwan Ashraf
Jan 31 at 15:18
I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.
– Mrwan Ashraf
Jan 31 at 15:18
On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?
– Bodo
Jan 31 at 15:33
On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?
– Bodo
Jan 31 at 15:33
@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.
– Mrwan Ashraf
Jan 31 at 15:37
@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.
– Mrwan Ashraf
Jan 31 at 15:37
add a comment |
1 Answer
1
active
oldest
votes
here is how to do it based on the answer i have found:
mkdir directory_name && cd "$_"
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f1400621%2fis-there-a-way-to-create-a-directory-and-access-it-in-a-single-command-chain%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
here is how to do it based on the answer i have found:
mkdir directory_name && cd "$_"
add a comment |
here is how to do it based on the answer i have found:
mkdir directory_name && cd "$_"
add a comment |
here is how to do it based on the answer i have found:
mkdir directory_name && cd "$_"
here is how to do it based on the answer i have found:
mkdir directory_name && cd "$_"
answered Jan 31 at 15:45
Mrwan AshrafMrwan Ashraf
13
13
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1400621%2fis-there-a-way-to-create-a-directory-and-access-it-in-a-single-command-chain%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
2
Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?
– Kamil Maciorowski
Jan 31 at 15:16
I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.
– Mrwan Ashraf
Jan 31 at 15:18
On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?
– Bodo
Jan 31 at 15:33
@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.
– Mrwan Ashraf
Jan 31 at 15:37