From 4c9a0a9f7cc7117fc0459d2e16a692b99a04a80b Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 15 Feb 2024 10:17:53 +0100 Subject: New note sed files --- _posts/2024-02-15-extract-lines-from-file.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 _posts/2024-02-15-extract-lines-from-file.md diff --git a/_posts/2024-02-15-extract-lines-from-file.md b/_posts/2024-02-15-extract-lines-from-file.md new file mode 100644 index 0000000..28a5b61 --- /dev/null +++ b/_posts/2024-02-15-extract-lines-from-file.md @@ -0,0 +1,20 @@ +--- +title: "Extract lines from a file with sed" +permalink: /extract-lines-from-file-with-sed.html +date: 2024-02-14T01:04:28+02:00 +layout: post +type: note +draft: false +--- + +Easy way to extract line ranges (like from line 200 to line 210) with sed. + +```sh +sed -n '200,210p' data/Homo_sapiens.GRCh38.dna.chromosome.18.fa + +# then pipe it to a new file with + +sed -n '200,210p' data/Homo_sapiens.GRCh38.dna.chromosome.18.fa > new.fa +``` + +`head` or `tail` could be used to extract from begining of the end of the file. -- cgit v1.2.3