1

https://askubuntu.com/questions/250012/how-do-i-install-z-script

I was installing z script on Ubuntu. I followed the second answer and it worked.

# Download to latest to home dir
wget https://raw.githubusercontent.com/rupa/z/master/z.sh -O ~/z.sh
# Add to .bashrc
echo . /path/to/z.sh >> ~/.bashrc
# Add to .zshrc
echo . /path/to/z.sh >> ~/.zshrc

My .bashrc contains . /var/jenkins_home/z.sh w

But I could not figure out what echo . does in this line.

echo . /path/to/z.sh >> ~/.bashrc

Why is there a space before and after the period .?

Leonard
  • 2,978
  • 6
  • 21
  • 42
  • `.` when used before an executable, means to source it. Read this [link](https://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it). `.` and `source` are just synonymns. [Here](https://askubuntu.com/questions/25488/what-is-the-difference-between-source-and) read the difference between them. – Mihir Luthra Aug 20 '19 at 08:06

1 Answers1

1

The dot is not syntactic in this case, it's simply a (POSIX compliant) synonym for the source keyword (a bashism), which runs code within the current shell. So adding such a line to ~/.bashrc means that script will be run as part of the startup of Bash.

l0b0
  • 55,365
  • 30
  • 138
  • 223