Find and replacestep 1 of 4 · intermediate
Support
The command is shown. Click it to run, or type your own.
By the end of this lesson you can
- Substitute text with
sed 's/old/new/' - Replace every match on a line with the
gflag - Delete lines by address, e.g.
sed '1d'to drop a header - Print a range of lines with
sed -n '2,4p'
Before you startComfort reading and piping text: cat, grep, and |.
s/OLD/NEW/ substitutes the first match on each line. Let's rename chr to chromosome.
Replace chr with chromosome in variants.tsv.
before
chr1 BRCA1 chr7 TP53sed s/chr/chromosome/gafter
chromosome1 BRCA1 chromosome7 TP53Key concept
"Stream editor" means sed never changes the file on disk, it edits the text as it flows past and prints the result. To keep the changes you redirect them to a new file (sed '...' in.tsv > out.tsv). Your original is always safe.
Type a command, or click the suggested one. ↑/↓ recall history, Tab completes file names. New to this? Hit Explain this command to see it in plain English.
workspace/shared/data0 files
Booting the WebAssembly runtime…