1

I created a shell script and wish to add it to bashrc. I opened /home/jub/bashrc and added the following to the end of the file:

alias myfilesync = './/home/jub/Documents/scripts/myfilesync.sh'

Then from terminal, executed:

source ~/.bashrc

Then I try to execute either

myfilesync

or

./myfilesync

Either way, the result is "No such file or directory".

What am I doing wrong?

closed as off-topic by jasonwryan, Jeff Schaller, cuonglm, cas, garethTheRed Jun 15 '16 at 6:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – jasonwryan, Jeff Schaller, cuonglm, cas, garethTheRed
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is the space before the equals sign a copy/paste typo or in the actual bashrc file? You'll also want to name the file .bashrc – Jeff Schaller Jun 14 '16 at 22:45
1

Provided the script you just wrote is placed in your home directory, which I am assuming is, /home/jub, your alias directive should be

alias myfilesync='/home/jub/Documents/scripts/myfilesync.sh'

i.e., you need to drop the leading ./

  • 2
    There also cannot be any spaces around the =. – Peschke Jun 14 '16 at 22:52
  • 1
    It also might be worth while to explain why they need to drop the ./ – Peschke Jun 14 '16 at 22:52
  • Thanks, dropped the `.` and the spaces around the = sign, and it worked. How do I mark the question as answered? – jub Jun 14 '16 at 23:16
1

Just other answer

Open and edit your .bashrc

alias myfilesync='/home/jub/Documents/scripts/myfilesync.sh'

Please note there are no spaces between =

Please note there's no leading ./, while you are specifying the path of the script, it is not needed

Check the script has the execute permission

Close your current terminal session and try again. If you want to skip this step, just set up the alias in your current prompt

$ alias myfilesync='/home/jub/Documents/scripts/myfilesync.sh'

Not the answer you're looking for? Browse other questions tagged or ask your own question.