Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • vishal.rossi
    Member
    • Apr 2013
    • 25

    Extracting specific lines/rows with awk

    I have to extract the line/row which begins with 1 10515 15143 128 2....and so on. The file is huge and doesn't begin with 1 in all the cases.

    Can anyone tell me how to extract with awk or with some other command.
    Thanks


    HWI-ST0764:99:C0BV6ACXX:4:1204:6906:61789 83 1 15143 0 = 14831 -406 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2107:4589:43565 83 1 15176 41 = 14914 -362 Library0
    ---------------------------------------------
    1 15015 15143 128 2 3.00995 >Deletion_xxx_00000000<

    HWI-ST0764:99:C0BV6ACXX:4:2301:8245:154739 83 1 16419 16 = 16094 -425 Library0
    HWI-ST0764:99:C0BV6ACXX:4:1108:15472:66215 99 1 16249 15 = 16540 391 Library0
    HWI-ST0764:99:C0BV6ACXX:4:1108:3056:153621 1123 1 16249 15 = 16558 391 Library0
    ---------------------------------------------
    1 16350 16419 69 3 15.3084 >Deletion_xxx_00000001<

    HWI-ST0764:99:C0BV6ACXX:4:2302:16721:121399 83 1 69682 12 = 69383 -399 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2204:19244:40995 83 1 69785 36 = 69523 -362 Library0
    HWI-ST0764:99:C0BV6ACXX:4:1101:7617:39485 83 1 69797 29 = 69536 -361 Library0
    ---------------------------------------------
    1 69637 69682 45 3 16.6685 >Deletion_xxx_00000002<

    HWI-ST0764:99:C0BV6ACXX:4:1204:14771:27644 99 1 367948 0 = 368253 369 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2103:1214:124930 83 1 368340 0 = 368023 -417 Library0
    ---------------------------------------------
    1 368124 368253 129 2 -0 >Deletion_xxx_00000003<

    HWI-ST0764:99:C0BV6ACXX:4:2306:18464:168765 83 1 802031 57 = 801722 -403 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2202:17216:184485 99 1 801733 37 = 802023 369 Library0
    HWI-ST0764:99:C0BV6ACXX:4:1102:11251:109896 83 1 802054 57 = 801737 -408 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2101:20094:111155 83 1 802052 57 = 801755 -397 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2304:14851:200592 83 1 802033 60 = 801771 -362 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2204:16036:62667 99 1 801789 37 = 802080 372 Library0
    HWI-ST0764:99:C0BV6ACXX:4:1307:14444:68097 99 1 801800 57 = 802117 403 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2206:4525:22206 83 1 802136 0 = 801822 -399 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2106:3993:7815 83 1 802110 57 = 801830 -379 Library0
    HWI-ST0764:99:C0BV6ACXX:4:1204:5671:93720 1107 1 802121 57 = 801830 -379 Library0
    HWI-ST0764:99:C0BV6ACXX:4:1205:12390:55233 99 1 801835 37 = 802137 386 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2103:16357:92085 83 1 802136 7 = 801839 -390 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2306:16690:178455 83 1 802141 7 = 801847 -374 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2304:8284:19653 99 1 801852 37 = 802140 381 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2304:18678:164778 99 1 801853 37 = 802136 376 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2106:6319:57635 83 1 802150 5 = 801859 -387 Library0
    HWI-ST0764:99:C0BV6ACXX:4:2304:5415:115448 99 1 801860 37 = 802143 382 Library0
    ---------------------------------------------
    1 801961 802023 62 17 9.95808 >Deletion_xxx_00000004<
  • mastal
    Senior Member
    • Mar 2009
    • 666

    #2
    Extracting specific lines/rows with awk

    How many different patterns/lines are you trying to extract?

    Grep will also work:
    $grep 'pattern' in.txt > out.txt

    check
    $grep --help

    for the different options you can use with grep.

    Comment

    • rhinoceros
      Senior Member
      • Apr 2013
      • 372

      #3
      You mean you need to extract lines that begin with '1'? If so,

      grep '^1' file.txt > out.txt
      savetherhino.org

      Comment

      Latest Articles

      Collapse

      • SEQadmin2
        Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
        by SEQadmin2


        Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

        The systematic characterization of the human proteome has
        ...
        07-20-2026, 11:48 AM
      • SEQadmin2
        Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
        by SEQadmin2



        Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
        ...
        07-09-2026, 11:10 AM
      • SEQadmin2
        Cancer Drug Resistance: The Lingering Barrier to Rising Survival
        by SEQadmin2



        Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

        There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
        07-08-2026, 05:17 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, Today, 12:17 PM
      0 responses
      10 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, Yesterday, 11:41 AM
      0 responses
      11 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-20-2026, 11:10 AM
      0 responses
      23 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-13-2026, 10:26 AM
      0 responses
      37 views
      0 reactions
      Last Post SEQadmin2  
      Working...