LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-15-2014, 08:29 AM   #1
nouse
LQ Newbie
 
Registered: Sep 2013
Posts: 21

Rep: Reputation: Disabled
Command Line: Splitting a txt file according to regular expressions in each line


Hi there,

i have the following problem to solve:

I have a huge text file containing sequences like this:

>HH3_5 M02542:50:000000000-ACBUJ:1:2117:9387:24782 orig_bc=CGTAGGCT
TTTTATATATATATATTAGCGCGCG....and so on
>HH4_4 M02542:50:000000000-ACBUJ:1:2117:9387:24783 orig_bc=AGTAGGCG
TTTTAGCCGCTGCTCGTCGCTATATATATATTAGCGCGCG....and so on

I want to split the file by the information in the header, namely orig_bc=CGTAGGCT

In the end i want to have separate files that contain all header lines with the same orig_bc ID PLUS every line until a line begins with ">".


In this example:

File CGTAGGCT
>HH3_5 M02542:50:000000000-ACBUJ:1:2117:9387:24782 orig_bc=CGTAGGCT
TTTTATATATATATATTAGCGCGCG....and so on


File AGTAGGCG
>HH4_4 M02542:50:000000000-ACBUJ:1:2117:9387:24783 orig_bc=AGTAGGCG
TTTTAGCCGCTGCTCGTCGCTATATATATATTAGCGCGCG....and so on
 
Old 12-15-2014, 10:45 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Sounds like a plan. What have you done to solve it? I would suggest awk, perl, ruby or such languages
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] awk/se: splitting a multi-line input at a regular expression and rearranging sarenace Programming 9 11-27-2012 09:00 AM
[SOLVED] splitting every word in a text file to a new line. imran042 Programming 7 05-25-2012 05:29 PM
[SOLVED] find: expressions using variable in command line moocan Programming 10 03-21-2012 08:51 AM
Import a txt file and read line by line, polyline by polyline C++ 924199952 Programming 2 02-16-2012 05:35 AM
How to process multi-line regular expressions? MTK358 Linux - Newbie 14 02-25-2010 12:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration