The first week of PreCourse is almost finished and we have worked with two main topics that are essential for any programmer: the command line and Git. I want to share with you some of the commands that I found interesting:
Shell commands
- which: Find out the pathname of a file or link
This command could be used to look for the shebang that you need to add on the ruby files that you want to be executed without invoking explicitely the ruby interpreter.
- tr: Translates (substitutes) sets of characters
In this example, we have used the tr command to replace the colon “:” by a newline. By doing so, it is more easy to read the paths of our environment variable $PATH
.
- export: set variables on a bash shell
In this case, we are not just setting a varible on the environment variable list, but also we are keeping it for further usage. Remember that by default the variables should be recreated every time a new session on a terminal starts. By adding the variable to the ~/.bash_profile file we do not need to recrate it again.
One of the common uses of a environment variable is storing sensitive data, such as passwords. In case we want to use an environment variable in our ruby program, we can invoke it like this:
This list is not completed yet…
Git commands
- How to delete a branch on GitHub (the website)
- Revert local changes to a file that is not staged
- Recreate one (or more) file(s) in your working directory as they were at that moment in time without altering history use