Contact Contact Us
Contact Us

Searching in Linux

Searching Through Output

The grep is a very useful tool in Linux. It allows you to search large files or command output for specific data. A good example would be to find all the dot files in your home folder. Try to run ls -a ~ | grep . This will list the contents of your home folder, but ionstead of printing the output to the screen, we use the pipe operator (|) to pass the output to grep, and it will then find all the contents with a period in the name. You can also use grep -v to exclude output. Try running ls -a ~ | grep -v bash to get all your dot files, excluding your .bashrc

Other Options

grep has some other options that are useful as well. Take note of the following flags:

  • - -i - Ignore case
  • - -l - Show file names
  • - -w - Match the entire word passed in
  • - -n - Show line number of found line in file

That wraps up the basics of Linux. There's still a lot to learn, but these fundamentals will get you through 90% of what you will do as a bioinformatics researcher. A quick note before you go: It would be wise to pick a terminal editor of your choice and learn it well. It could be nano, vim, micro, ed, etc. Just know one for whenever you want to write to a file in your terminal.