cd doesn t work in my shell script

0 votes

I'm writing this script.

#!/bin/bash
cd /home/tree/projects/python

I saved this file as proj, added execute permission with chmod, and copied it to /usr/bin. When I call it by: proj, it does nothing. 

Am I doing something wrong?

May 24, 2019 in Linux Administration by Upasana
• 8,620 points
1,633 views

1 answer to this question.

0 votes

One way to get around this is to use an alias:

alias proj="cd /home/tree/projects/python"

You can also run the script in your current process with the "dot" command:

. proj
answered May 24, 2019 by Shubham
• 13,490 points

Related Questions In Linux Administration

0 votes
1 answer

Adding yes/no/cancel prompts in shell script

You can use the read command. Here's ...READ MORE

answered Mar 13, 2019 in Linux Administration by ajs3033
• 7,300 points
4,063 views
0 votes
2 answers

How do I use a shell script to SSH in to a remote machine to execute commands?

Sorry in advance for any formatting. Check out ...READ MORE

answered Feb 7, 2021 in Linux Administration by anonymous
16,906 views
0 votes
1 answer

How do I check if a directory exists in a Bash shell script?

To check if a directory exists in ...READ MORE

answered Jun 7, 2022 in Linux Administration by Korak
• 5,820 points
1,597 views
0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31, 2019 in Linux Administration by Omkar
• 69,230 points
948 views
0 votes
1 answer
0 votes
1 answer

Chmod 777 to a folder and all contents

To help you with your doubt, if ...READ MORE

answered Feb 9, 2022 in Linux Administration by Rahul
• 9,670 points
7,474 views
0 votes
1 answer

Spark Kill Running Application

you can copy the application id from ...READ MORE

answered Apr 25, 2018 in Apache Spark by kurt_cobain
• 9,390 points
1,592 views
+1 vote
1 answer

Unable to access Jenkins. I newly installed Jenkins but for some reason I cannot access it.

Try changing the port, Change JENKINS_AJP_PORT="xyz" to JENKINS_AJP_PORT="abc" If changing the ...READ MORE

answered Jul 4, 2018 in Jenkins by Sophie may
• 10,610 points
7,962 views
0 votes
1 answer

Using shell variables in an awk script

Using -v is, imo, The best way because ...READ MORE

answered Jul 1, 2019 in Linux Administration by Shubham
• 13,490 points
2,452 views
0 votes
1 answer

Writing a heredoc to a file in a script

try to use tee: tee newfile <<EOF line 1 line 2 line ...READ MORE

answered May 20, 2019 in Linux Administration by Shubham
• 13,490 points
1,386 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP