meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
general:computerenvironment:shell_basic_commands [2019/12/01 21:34] rubengeneral:computerenvironment:shell_basic_commands [2020/09/07 18:20] (current) – [If / Else] ingo
Line 19: Line 19:
 Remember to call the file only in the first command given: Remember to call the file only in the first command given:
 cat ejemplo.txt | grep "xxxxx" cat ejemplo.txt | grep "xxxxx"
 +
 +----
 +Tip: You can create this file with:
 +<code>
 +nano ejemplo.txt
 +</code>
 +paste the contents of the ejemplo file into the nano editor and close it using STRG/CMD + X
 +
 +Alternatively you can download the file by clicking on its name and do the exercises in a linux environment on your local computer (for example using mobaXterm on windows, or in the command line on macOS).
 +----
 +
  
 ===== Reading files + counting lines ===== ===== Reading files + counting lines =====
Line 42: Line 53:
 </code> </code>
  
 +----
 +
 +===== Tab completion =====
 +
 +You can auto-complete paths by pressing the tab key once or twice anytime while writing a path. If the auto-completion does not work, there might be something wrong with your path..
 +
 +You can check out [[https://youtu.be/igwD7cL6QOk|this video]] to see how it works.
 ---- ----
  
Line 161: Line 179:
 If a directory does not exist, 'mv' renames the file instead</hidden> If a directory does not exist, 'mv' renames the file instead</hidden>
 <hidden Grep and quotations> <hidden Grep and quotations>
 +Trying to find all ">" symbols in the following file:
 +<file txt important_sequence.fasta>
 +>Important_sequence1
 +AAATTCTCACCCCTCAGAAA
 +>Important_sequence2
 +ACCTCAGAAAAATTCTCACC
 +</file>
 <code> <code>
-echo -e $">Important_sequence\nAAATTCTCACCCCTCAGAAA" > important_sequence.fasta 
-cat important_sequence.fasta 
 grep > important_sequence.fasta grep > important_sequence.fasta
 </code> </code>
Line 189: Line 212:
 ---- ----
  
-====== Part II ======+====== Slightly more advanced bash commands ======
  
 ===== For-loop ===== ===== For-loop =====
Line 217: Line 240:
  
 <hidden Exercise> <hidden Exercise>
-Find the lines that contain "a", "b", and "c" in ejemplo.txt, and save them into their respective files. +Find the lines that contain "a", "b", and "c" in ejemplo.txt, and save them into their respective files (a.txt, b.txt, c.txt)
 This means, each file should look like this: This means, each file should look like this:
 <file txt a.txt> <file txt a.txt>
Line 224: Line 247:
 axaxa bxbxb axaxa bxbxb
 </file> </file>
-</hidden> 
 Hint: let me start the command for you: Hint: let me start the command for you:
 <code> <code>
 for i in a b c; do ... for i in a b c; do ...
 </code> </code>
 +</hidden>
 +
  
 ---- ----
Line 271: Line 295:
   * -gt = is greater than   * -gt = is greater than
   * -lt = is lesser than   * -lt = is lesser than
 +