coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion: cdm command


From: Mourad Bougarne
Subject: Re: Suggestion: cdm command
Date: Tue, 12 Jan 2021 18:33:43 +0100

Ok, thanks for the clarification.

On Tue, Jan 12, 2021, 16:55 Bernhard Voelker <mail@bernhard-voelker.de>
wrote:

> On 1/12/21 3:20 PM, Mourad Bougarne wrote:
> > Hello,
> >
> > I know that there's a command option to create a directory if not exists
> > using mkdir -p DIRECTORY_NAME, but what I suggest is create a directory
> if
> > not exists when we change it, so:
> >
> > $ cd non-exists-directory
> > $ bash: cd: non-exists-directory: No such file or directory
> >
> > With the command that I suggest we can do:
> > cdm: change directory make if not exists
> > $ cdm non-exists-directory
> >
> > Regards,
> > Mourad
>
> This is not possible as a separate tool, because the working directory of
> the calling shell process would not change.
>
> What about a simple shell function?
>
>
>   $ function cdm() { mkdir "$1" && cd "$1"; }
>
>   $ cdm hello
>
>   $ cd ..
>
>   $ cdm hello
>   mkdir: cannot create directory 'hello': File exists
>
> Have a nice day,
> Berny
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]