Bash aliases to enhance your productivity
From BITS wiki
Go back to parent page Introduction to Linux for bioinformatics
IO=ntro
You specify aliases in the .bashrc file in your home directory.
alias myalias="<my fancy command>"
Change 'my fancy command' to a real command!!
Before you can use your new aliases, you have to reload the .bashrc file. You do this by
$ source ~/.bashrc
or
$ . ~/.bashrc
Now, let's do this exercise.
Sometimes you might want to open a big text file from the end on, and start scrolling towards the top. We will create an alias for this in this exercise.
Create an alias that starts scrolling from the bottom. Tip: it's less and the appropriate option you must configure. |
---|
Read through the man page of less. To help you: you can search for the string "at the end". Open the man page of less
$ man less |
Type "/at the end" and <ENTER>. Less will search in the content for "at the end". Examine the entries with the string./ Go to the following result by typing "/" followed by ENTER. |
The option is +G
|
Add the alias by opening .bashrc with an editor, and adding the line:
alias sell="less +G" |
When you have changed the content of .bashrc, it needs to be reloaded. Close your terminal and fire it up again. OR execute:
$ . ~/.bashrc $ source ~/.bashrc |
We now have sell to our disposal, which starts scrolling large text files from the end of the file.
$ sell /var/log/syslog |
Show all aliases on your system
Forgot an alias? To see all your aliases, run the command
$ alias
Go back to parent page Introduction to Linux for bioinformatics