3

I made a very simple script

#!/bin/bash mkdir $1 && cd $1 

when I execute

myscript test 

It creates test directory but doesn't go inside just after. I don't understand why, on my fedora 27 this script works without any issue but on my debian stretch this behavior occurs. Could someone explain why I am having this bug.

0

1 Answer 1

4

You can and it works perfectly. But when the script is done, its environment (including its working directory) is destroyed.

Try source myscript test to execute your script as though you had typed its commands into your actual interactive shell and you working directory will have been changed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.