Linked Questions
25 questions linked to/from Script to change current directory (cd, pwd)
1
vote
2
answers
168
views
How to change directory in shell script running in zsh shell
I am working on a shell script (shell used, its version and OS are below). The script runs commands in a local git repository/directory with has several tags. The script outputs some string from ...
0
votes
0
answers
18
views
How can I signal/force the parent shell to change directory? [duplicate]
I have this command called reclone, and this is my script:
. load
sudo -v
extract
sudo rm -rf /$organization/$repository
cd /$organization
git clone --depth 1 [email protected]:$organization/$...
0
votes
0
answers
19
views
how to move working directory prompt inside of script [duplicate]
forgive me, the title was hard to come up with as i'm not even sure how to ask this any other way. i have a script that moves it's contents and then nukes the remains. here's the script (works just ...
0
votes
1
answer
456
views
cd does not take variable as argument in bash script [duplicate]
I'm trying to make a bash script that will give me a command that will take a number n as argument and change the directory to the nth directory listed by running ls in the working directory. Here's ...
0
votes
0
answers
15
views
Why doesn't the directory stack persist from inside a script? [duplicate]
I was working on a script to set up a project-specific environment. I created a script to set up the directory stack as suggested in the first comment to this question. Console output provided ...
-1
votes
1
answer
2k
views
Add variable to cd directory path
I know these questions might have been asked somewhere but their solutions don't really work. I need help.
I want to add a variable to a directory name then change directory to it. The approach below ...
0
votes
1
answer
39
views
change directory in shell script based on prompt [duplicate]
I'm currently at /opt and running a small shell script. My "no" condition works perfectly, however, my yes condition doesn't work, I 'am still at /opt.
while true; do
read -p "go to log location ?...
0
votes
1
answer
850
views
Unable to validate directory from user input
I'm trying to prompt user repeatedly enter a directory and then the script will then check if the directory exists, if not keep prompting till the user enter a valid directory.
my code:
#!/bin/bash
...
0
votes
1
answer
942
views
Bash script did not change the directory as written [duplicate]
Here is my script to change the directory
[user@linux ~]$ cat script.sh
echo Before: $(pwd)
cd "$1"
echo After : $(pwd)
[user@linux ~]$
When I tested it, it did not really change the directory as ...
-2
votes
1
answer
2k
views
CD $Variable not working when used in a (Bash) Shell Script [duplicate]
File name: Test.sh
#!/bin/bash
ZDir="$(echo /usr/src)"
cd "$ZDir"
When I execute the script ./Test.sh, the command cd doesn't do anything.
If I try to do it directly in the bash terminal, it works ...
2
votes
2
answers
6k
views
Changing current directory with a bash script? [duplicate]
I was wondering if it's possible to change directory of a shell from a bash script, but keep the directory change persistent to more than just the subshell.
I'm aware that when you run cd inside a ...
0
votes
2
answers
895
views
How do I make a cd command take effect outside of the bash script subshell? [duplicate]
I made this script:
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "only use one argument"
exit 1
fi
mkdir $1
sleep 0.5
cd $1
exit 0
I wanted to make a script that I would later put into /usr/bin, ...
8
votes
5
answers
5k
views
$ find -exec cd => gives error: => find: ‘cd’: No such file or directory
When I run this command it works:
$ find . -inum 888696 -exec ls '{}' \;
Conversation.pst Outlook Data File Outlook Data File.sbd Trash Unsent Messages
Inbox.pst Outlook Data File.msf ...
3
votes
1
answer
384
views
Why can't I use cd in a bash script? [duplicate]
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 ...
0
votes
0
answers
42
views
Script that uses new directory [duplicate]
I have a script that I need to run an application which, at the end, changes the working directory. (I'm modifying an ".sh" script and am new to Unix.) I then need to run some commands in that new ...