<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk/22126/index.php?action=history&amp;feed=atom&amp;title=Advanced_UNIX_and_Pipes</id>
	<title>Advanced UNIX and Pipes - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk/22126/index.php?action=history&amp;feed=atom&amp;title=Advanced_UNIX_and_Pipes"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22126/index.php?title=Advanced_UNIX_and_Pipes&amp;action=history"/>
	<updated>2026-06-06T10:39:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://teaching.healthtech.dtu.dk/22126/index.php?title=Advanced_UNIX_and_Pipes&amp;diff=219&amp;oldid=prev</id>
		<title>Mick at 09:07, 20 November 2025</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22126/index.php?title=Advanced_UNIX_and_Pipes&amp;diff=219&amp;oldid=prev"/>
		<updated>2025-11-20T09:07:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://teaching.healthtech.dtu.dk/22126/index.php?title=Advanced_UNIX_and_Pipes&amp;amp;diff=219&amp;amp;oldid=218&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Mick</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk/22126/index.php?title=Advanced_UNIX_and_Pipes&amp;diff=218&amp;oldid=prev</id>
		<title>Mick: Created page with &quot;== Advanced UNIX and Pipes == This page covers standard input/output streams, redirection, pipes, file descriptors, and examples using Python scripts. These concepts are extremely useful in NGS analysis (e.g., chaining commands together, avoiding intermediate files, streaming FASTQ/BAM data, etc.).  === stdout, stdin, stderr === Every UNIX command uses three data streams:  * &#039;&#039;&#039;stdin&#039;&#039;&#039; (file descriptor 0) – input   * &#039;&#039;&#039;stdout&#039;&#039;&#039; (file descriptor 1) – normal output...&quot;</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22126/index.php?title=Advanced_UNIX_and_Pipes&amp;diff=218&amp;oldid=prev"/>
		<updated>2025-11-20T09:03:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Advanced UNIX and Pipes == This page covers standard input/output streams, redirection, pipes, file descriptors, and examples using Python scripts. These concepts are extremely useful in NGS analysis (e.g., chaining commands together, avoiding intermediate files, streaming FASTQ/BAM data, etc.).  === stdout, stdin, stderr === Every UNIX command uses three data streams:  * &amp;#039;&amp;#039;&amp;#039;stdin&amp;#039;&amp;#039;&amp;#039; (file descriptor 0) – input   * &amp;#039;&amp;#039;&amp;#039;stdout&amp;#039;&amp;#039;&amp;#039; (file descriptor 1) – normal output...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Advanced UNIX and Pipes ==&lt;br /&gt;
This page covers standard input/output streams, redirection, pipes, file descriptors, and examples using Python scripts. These concepts are extremely useful in NGS analysis (e.g., chaining commands together, avoiding intermediate files, streaming FASTQ/BAM data, etc.).&lt;br /&gt;
&lt;br /&gt;
=== stdout, stdin, stderr ===&lt;br /&gt;
Every UNIX command uses three data streams:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;stdin&amp;#039;&amp;#039;&amp;#039; (file descriptor 0) – input  &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;stdout&amp;#039;&amp;#039;&amp;#039; (file descriptor 1) – normal output  &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;stderr&amp;#039;&amp;#039;&amp;#039; (file descriptor 2) – error messages  &lt;br /&gt;
&lt;br /&gt;
Redirecting these streams:&lt;br /&gt;
&lt;br /&gt;
* `&amp;gt;`   – redirect stdout  &lt;br /&gt;
* `2&amp;gt;`  – redirect stderr  &lt;br /&gt;
* `&amp;lt;`   – redirect stdin  &lt;br /&gt;
* `&amp;gt;&amp;gt;`  – append  &lt;br /&gt;
* `|`   – pipe stdout → stdin  &lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls &amp;gt; listing.txt&lt;br /&gt;
grep HUMAN ex1.acc 2&amp;gt; errors.log&lt;br /&gt;
wc -l &amp;lt; ex1.acc&lt;br /&gt;
ls | wc -l&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== /dev/null (“black hole”) ===&lt;br /&gt;
Redirect output you want to ignore:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command &amp;gt; /dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pipes ===&lt;br /&gt;
Pipes connect the output of one command to the input of another.&lt;br /&gt;
&lt;br /&gt;
Simple examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep HUMAN ex1.acc | sort | uniq -c&lt;br /&gt;
cut -f1 ex1.tot | sort | head&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pipes allow commands to run in parallel and avoid writing temporary files.&lt;br /&gt;
&lt;br /&gt;
=== Using stdin/stdout in Python ===&lt;br /&gt;
Example program reading from stdin:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/python3&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
for line in sys.stdin:&lt;br /&gt;
    print(&amp;quot;Hello&amp;quot;, line.strip())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;world&amp;quot; | python3 hello.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== File descriptors and process substitution ===&lt;br /&gt;
Process substitution creates a temporary file-like object from a command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff &amp;lt;(sort file1) &amp;lt;(sort file2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful for tools that expect filenames.&lt;br /&gt;
&lt;br /&gt;
=== Example: Random name generator + greeting script ===&lt;br /&gt;
(Your cleaned-up versions go here.)&lt;br /&gt;
&lt;br /&gt;
=== Example: Integer generator + prime checker ===&lt;br /&gt;
(Place the simplified versions here.)&lt;br /&gt;
&lt;br /&gt;
=== Example: RSA key generator ===&lt;br /&gt;
(Optional section, for students who want the deeper CS example.)&lt;br /&gt;
&lt;br /&gt;
=== Benchmarking ===&lt;br /&gt;
Using the `time` command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
time python3 script.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use this when comparing pipelines vs intermediate files.&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
These advanced UNIX tools allow:&lt;br /&gt;
* streaming large data instead of creating intermediate files  &lt;br /&gt;
* chaining tools together efficiently  &lt;br /&gt;
* using Python and shell commands seamlessly  &lt;br /&gt;
* improving performance for large NGS pipelines&lt;/div&gt;</summary>
		<author><name>Mick</name></author>
	</entry>
</feed>