I want to change the directory in linux using bash file. Below is the code snippet used.
#!/bin/bash
alias proj="cd /home/prag/Downloads"
But on running the bash file there is not response, i.e. it stays in the same directory. Why is it so.? Why doesn’t alias work here or should I do something different.?
Running the bash file won’t work as the change to the current working directory stays within the script (as it is a separate process to the process that gives you your command prompt – bash).
Add the alias to your ~/.bash_aliases or ~/.bashrc file (former is preferable, latter might be quicker if the former doesn’t exist) and then it should work.