how to rename output of split command to match the first word in each line? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsExtract data from a file and place in different files based on1 column valueHow to split a file by counting digit numbers within a row?Split string into array and print each element on a new line with commandlineHow to insert a line from file A above the FIRST LINE in file BSplitting a single file into multiple files based on matching strings in LinuxCompare two files and print only the first word of the lines which don't match along with a stringSplit single line into multiple lines, Newline character missing for all the lines in input filesplit file based on the first digit in the lineHow to print all the lines that's first word is the first word of a file?How to read a file line by line then take each line and insert into txt fileIterate print for each line in output

Road tyres vs "Street" tyres for charity ride on MTB Tandem

Simulating Exploding Dice

Why can't wing-mounted spoilers be used to steepen approaches?

Problems with Ubuntu mount /tmp

Didn't get enough time to take a Coding Test - what to do now?

Python - Fishing Simulator

How do you keep chess fun when your opponent constantly beats you?

Is this wall load bearing? Blueprints and photos attached

Working through the single responsibility principle (SRP) in Python when calls are expensive

What is this lever in Argentinian toilets?

How does ice melt when immersed in water?

Make it rain characters

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

how can a perfect fourth interval be considered either consonant or dissonant?

What force causes entropy to increase?

How to split my screen on my Macbook Air?

Typeface like Times New Roman but with "tied" percent sign

Match Roman Numerals

How are presidential pardons supposed to be used?

What are these Gizmos at Izaña Atmospheric Research Center in Spain?

Why does this iterative way of solving of equation work?

How did passengers keep warm on sail ships?

Can the DM override racial traits?

Did God make two great lights or did He make the great light two?



how to rename output of split command to match the first word in each line?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election ResultsExtract data from a file and place in different files based on1 column valueHow to split a file by counting digit numbers within a row?Split string into array and print each element on a new line with commandlineHow to insert a line from file A above the FIRST LINE in file BSplitting a single file into multiple files based on matching strings in LinuxCompare two files and print only the first word of the lines which don't match along with a stringSplit single line into multiple lines, Newline character missing for all the lines in input filesplit file based on the first digit in the lineHow to print all the lines that's first word is the first word of a file?How to read a file line by line then take each line and insert into txt fileIterate print for each line in output



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have input.txt file (with 4 lines)like this:



GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1


How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt



What I tried so far is this:



split -d -a 2 -l 1 input.txt output_


This is very far from the solution I need.



The solution per advice of @steeldriver is :



awk -F " " 'print >$1".txt"' input.txt









share|improve this question
























  • Related: Extract data from a file and place in different files based on1 column value

    – steeldriver
    yesterday












  • Thank you so much!!! That indeed solved my problem, I will post the solution above.

    – anikaM
    yesterday

















0















I have input.txt file (with 4 lines)like this:



GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1


How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt



What I tried so far is this:



split -d -a 2 -l 1 input.txt output_


This is very far from the solution I need.



The solution per advice of @steeldriver is :



awk -F " " 'print >$1".txt"' input.txt









share|improve this question
























  • Related: Extract data from a file and place in different files based on1 column value

    – steeldriver
    yesterday












  • Thank you so much!!! That indeed solved my problem, I will post the solution above.

    – anikaM
    yesterday













0












0








0








I have input.txt file (with 4 lines)like this:



GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1


How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt



What I tried so far is this:



split -d -a 2 -l 1 input.txt output_


This is very far from the solution I need.



The solution per advice of @steeldriver is :



awk -F " " 'print >$1".txt"' input.txt









share|improve this question
















I have input.txt file (with 4 lines)like this:



GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1


How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt



What I tried so far is this:



split -d -a 2 -l 1 input.txt output_


This is very far from the solution I need.



The solution per advice of @steeldriver is :



awk -F " " 'print >$1".txt"' input.txt






text-processing command-line split






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







anikaM

















asked yesterday









anikaManikaM

13




13












  • Related: Extract data from a file and place in different files based on1 column value

    – steeldriver
    yesterday












  • Thank you so much!!! That indeed solved my problem, I will post the solution above.

    – anikaM
    yesterday

















  • Related: Extract data from a file and place in different files based on1 column value

    – steeldriver
    yesterday












  • Thank you so much!!! That indeed solved my problem, I will post the solution above.

    – anikaM
    yesterday
















Related: Extract data from a file and place in different files based on1 column value

– steeldriver
yesterday






Related: Extract data from a file and place in different files based on1 column value

– steeldriver
yesterday














Thank you so much!!! That indeed solved my problem, I will post the solution above.

– anikaM
yesterday





Thank you so much!!! That indeed solved my problem, I will post the solution above.

– anikaM
yesterday










2 Answers
2






active

oldest

votes


















1














with Miller (https://github.com/johnkerl/miller) using



mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt


you will have this four files:



chr9q34.txt
GCM_TINF2.txt
GGTAACC_MIR4095P.txt
REACTOME_SIGNALING_BY_NOTCH1.txt





share|improve this answer






























    0














    Kindly use below command to achieve testes and worked fine



    count=`wc -l filename| awk 'print $1'`
    praveen@praveen:~$
    praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
    praveen@praveen:~$





    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512169%2fhow-to-rename-output-of-split-command-to-match-the-first-word-in-each-line%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      with Miller (https://github.com/johnkerl/miller) using



      mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt


      you will have this four files:



      chr9q34.txt
      GCM_TINF2.txt
      GGTAACC_MIR4095P.txt
      REACTOME_SIGNALING_BY_NOTCH1.txt





      share|improve this answer



























        1














        with Miller (https://github.com/johnkerl/miller) using



        mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt


        you will have this four files:



        chr9q34.txt
        GCM_TINF2.txt
        GGTAACC_MIR4095P.txt
        REACTOME_SIGNALING_BY_NOTCH1.txt





        share|improve this answer

























          1












          1








          1







          with Miller (https://github.com/johnkerl/miller) using



          mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt


          you will have this four files:



          chr9q34.txt
          GCM_TINF2.txt
          GGTAACC_MIR4095P.txt
          REACTOME_SIGNALING_BY_NOTCH1.txt





          share|improve this answer













          with Miller (https://github.com/johnkerl/miller) using



          mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt


          you will have this four files:



          chr9q34.txt
          GCM_TINF2.txt
          GGTAACC_MIR4095P.txt
          REACTOME_SIGNALING_BY_NOTCH1.txt






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          aborrusoaborruso

          373311




          373311























              0














              Kindly use below command to achieve testes and worked fine



              count=`wc -l filename| awk 'print $1'`
              praveen@praveen:~$
              praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
              praveen@praveen:~$





              share|improve this answer



























                0














                Kindly use below command to achieve testes and worked fine



                count=`wc -l filename| awk 'print $1'`
                praveen@praveen:~$
                praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
                praveen@praveen:~$





                share|improve this answer

























                  0












                  0








                  0







                  Kindly use below command to achieve testes and worked fine



                  count=`wc -l filename| awk 'print $1'`
                  praveen@praveen:~$
                  praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
                  praveen@praveen:~$





                  share|improve this answer













                  Kindly use below command to achieve testes and worked fine



                  count=`wc -l filename| awk 'print $1'`
                  praveen@praveen:~$
                  praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
                  praveen@praveen:~$






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 20 hours ago









                  Praveen Kumar BSPraveen Kumar BS

                  1,7751311




                  1,7751311



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512169%2fhow-to-rename-output-of-split-command-to-match-the-first-word-in-each-line%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      -command-line, split, text-processing

                      Popular posts from this blog

                      Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

                      Frič See also Navigation menuinternal link

                      Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant