“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 23 in Linux Administration by Upasana
• 8,550 points
56 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 23 by Shubham
• 13,350 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 12 in Linux Administration by ajs3033
• 7,280 points
49 views
0 votes
1 answer
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 in Linux Administration by Omkar
• 68,160 points
49 views
0 votes
1 answer

To run a shell script on a Unix console or Mac terminal

To run a non-executable sh script, use: sh myscript To run ...READ MORE

answered May 16 in Linux Administration by Upasana
• 8,550 points
64 views
0 votes
1 answer
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,280 points
229 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
• 9,870 points
414 views
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
101 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 in Linux Administration by Shubham
• 13,350 points
89 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 in Linux Administration by Shubham
• 13,350 points
61 views