How to make underscore separate into space separate? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-3
down vote

favorite












I have the following data:



ID Affection rs3117294 rs2747453 rs2747454 rs2747457 rs3131888
D0024949 0 C_C A_G A_G A_A A_G
D0024302 0 A_C A_A A_G A_A A_A
D0023151 0 C_C A_G A_A A_A G_G
D0022042 0 A_C A_A G_G A_A A_A
D0021275 0 C_C A_G A_G A_A A_G
D0021163 0 A_A A_A G_G A_A A_A
D0020795 0 A_A A_A G_G A_C A_G
D0020691 0 A_A A_A G_G A_C A_G
D0019121 0 A_A A_A G_G C_C G_G


I want to make the underscore a space, so that C_C to be C C.



How can I do that? Please make the code general to apply it to the whole data I have.



I got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete.







share|improve this question














closed as unclear what you're asking by peterh, Stephen Rauch, G-Man, DarkHeart, Romeo Ninov Nov 21 '17 at 7:55


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • i got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete
    – Marwah Soliman
    Nov 21 '17 at 1:29















up vote
-3
down vote

favorite












I have the following data:



ID Affection rs3117294 rs2747453 rs2747454 rs2747457 rs3131888
D0024949 0 C_C A_G A_G A_A A_G
D0024302 0 A_C A_A A_G A_A A_A
D0023151 0 C_C A_G A_A A_A G_G
D0022042 0 A_C A_A G_G A_A A_A
D0021275 0 C_C A_G A_G A_A A_G
D0021163 0 A_A A_A G_G A_A A_A
D0020795 0 A_A A_A G_G A_C A_G
D0020691 0 A_A A_A G_G A_C A_G
D0019121 0 A_A A_A G_G C_C G_G


I want to make the underscore a space, so that C_C to be C C.



How can I do that? Please make the code general to apply it to the whole data I have.



I got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete.







share|improve this question














closed as unclear what you're asking by peterh, Stephen Rauch, G-Man, DarkHeart, Romeo Ninov Nov 21 '17 at 7:55


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • i got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete
    – Marwah Soliman
    Nov 21 '17 at 1:29













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











I have the following data:



ID Affection rs3117294 rs2747453 rs2747454 rs2747457 rs3131888
D0024949 0 C_C A_G A_G A_A A_G
D0024302 0 A_C A_A A_G A_A A_A
D0023151 0 C_C A_G A_A A_A G_G
D0022042 0 A_C A_A G_G A_A A_A
D0021275 0 C_C A_G A_G A_A A_G
D0021163 0 A_A A_A G_G A_A A_A
D0020795 0 A_A A_A G_G A_C A_G
D0020691 0 A_A A_A G_G A_C A_G
D0019121 0 A_A A_A G_G C_C G_G


I want to make the underscore a space, so that C_C to be C C.



How can I do that? Please make the code general to apply it to the whole data I have.



I got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete.







share|improve this question














I have the following data:



ID Affection rs3117294 rs2747453 rs2747454 rs2747457 rs3131888
D0024949 0 C_C A_G A_G A_A A_G
D0024302 0 A_C A_A A_G A_A A_A
D0023151 0 C_C A_G A_A A_A G_G
D0022042 0 A_C A_A G_G A_A A_A
D0021275 0 C_C A_G A_G A_A A_G
D0021163 0 A_A A_A G_G A_A A_A
D0020795 0 A_A A_A G_G A_C A_G
D0020691 0 A_A A_A G_G A_C A_G
D0019121 0 A_A A_A G_G C_C G_G


I want to make the underscore a space, so that C_C to be C C.



How can I do that? Please make the code general to apply it to the whole data I have.



I got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete.









share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '17 at 5:44









peterh

3,94592755




3,94592755










asked Nov 21 '17 at 1:21









Marwah Soliman

4818




4818




closed as unclear what you're asking by peterh, Stephen Rauch, G-Man, DarkHeart, Romeo Ninov Nov 21 '17 at 7:55


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by peterh, Stephen Rauch, G-Man, DarkHeart, Romeo Ninov Nov 21 '17 at 7:55


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • i got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete
    – Marwah Soliman
    Nov 21 '17 at 1:29

















  • i got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete
    – Marwah Soliman
    Nov 21 '17 at 1:29
















i got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete
– Marwah Soliman
Nov 21 '17 at 1:29





i got the following from someone "not my code" sed '1d' plink.raw | sed 's/_/ /g' > plinkv2.raw, but it gave me empty cells the data is not complete
– Marwah Soliman
Nov 21 '17 at 1:29











2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










GNU sed:



sed -itmp 's/(w)_(w)/1 2/g' file


This will overwrite file and save a backup of original to file.tmp.



POSIX sed:



sed 's/([[:alpha:]])_([[:alpha:]])/1 2/g' file > file2


You have to redirect to another file. Copy file2 to the original if that's what you want.



Both use the concept of "back-references". Surrounding text with (..) in the pattern makes it available in the substitution with 1, 2, etc.






share|improve this answer




















  • can you put a tab instead of the space?
    – Marwah Soliman
    Nov 21 '17 at 1:44










  • Just replace the space with t. Since your question asks for space I need to leave the answer consistent with that so as not to confuse other people.
    – B Layer
    Nov 21 '17 at 1:46











  • between the 1 and 2 ??
    – Marwah Soliman
    Nov 21 '17 at 1:48










  • it gave me AtC , no tab !
    – Marwah Soliman
    Nov 21 '17 at 1:50










  • a separated by a tab b...
    – Marwah Soliman
    Nov 21 '17 at 2:02


















up vote
0
down vote













Please find the below command and output


it replaces _ with spaces through out the file



awk 'gsub("_"," ",$0);print $0' j.txt 
D0024949 0 C C A G A G A A A G
D0024302 0 A C A A A G A A A A
D0023151 0 C C A G A A A A G G
D0022042 0 A C A A G G A A A A
D0021275 0 C C A G A G A A A G
D0021163 0 A A A A G G A A A A
D0020795 0 A A A A G G A C A G
D0020691 0 A A A A G G A C A G
D0019121 0 A A A A G G C C G G


IF want it to be replace only first match



sed "s/_/ /1" inputfile



Let us know for any clarification kindly provide the proper input and output






share|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    GNU sed:



    sed -itmp 's/(w)_(w)/1 2/g' file


    This will overwrite file and save a backup of original to file.tmp.



    POSIX sed:



    sed 's/([[:alpha:]])_([[:alpha:]])/1 2/g' file > file2


    You have to redirect to another file. Copy file2 to the original if that's what you want.



    Both use the concept of "back-references". Surrounding text with (..) in the pattern makes it available in the substitution with 1, 2, etc.






    share|improve this answer




















    • can you put a tab instead of the space?
      – Marwah Soliman
      Nov 21 '17 at 1:44










    • Just replace the space with t. Since your question asks for space I need to leave the answer consistent with that so as not to confuse other people.
      – B Layer
      Nov 21 '17 at 1:46











    • between the 1 and 2 ??
      – Marwah Soliman
      Nov 21 '17 at 1:48










    • it gave me AtC , no tab !
      – Marwah Soliman
      Nov 21 '17 at 1:50










    • a separated by a tab b...
      – Marwah Soliman
      Nov 21 '17 at 2:02















    up vote
    1
    down vote



    accepted










    GNU sed:



    sed -itmp 's/(w)_(w)/1 2/g' file


    This will overwrite file and save a backup of original to file.tmp.



    POSIX sed:



    sed 's/([[:alpha:]])_([[:alpha:]])/1 2/g' file > file2


    You have to redirect to another file. Copy file2 to the original if that's what you want.



    Both use the concept of "back-references". Surrounding text with (..) in the pattern makes it available in the substitution with 1, 2, etc.






    share|improve this answer




















    • can you put a tab instead of the space?
      – Marwah Soliman
      Nov 21 '17 at 1:44










    • Just replace the space with t. Since your question asks for space I need to leave the answer consistent with that so as not to confuse other people.
      – B Layer
      Nov 21 '17 at 1:46











    • between the 1 and 2 ??
      – Marwah Soliman
      Nov 21 '17 at 1:48










    • it gave me AtC , no tab !
      – Marwah Soliman
      Nov 21 '17 at 1:50










    • a separated by a tab b...
      – Marwah Soliman
      Nov 21 '17 at 2:02













    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    GNU sed:



    sed -itmp 's/(w)_(w)/1 2/g' file


    This will overwrite file and save a backup of original to file.tmp.



    POSIX sed:



    sed 's/([[:alpha:]])_([[:alpha:]])/1 2/g' file > file2


    You have to redirect to another file. Copy file2 to the original if that's what you want.



    Both use the concept of "back-references". Surrounding text with (..) in the pattern makes it available in the substitution with 1, 2, etc.






    share|improve this answer












    GNU sed:



    sed -itmp 's/(w)_(w)/1 2/g' file


    This will overwrite file and save a backup of original to file.tmp.



    POSIX sed:



    sed 's/([[:alpha:]])_([[:alpha:]])/1 2/g' file > file2


    You have to redirect to another file. Copy file2 to the original if that's what you want.



    Both use the concept of "back-references". Surrounding text with (..) in the pattern makes it available in the substitution with 1, 2, etc.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '17 at 1:33









    B Layer

    3,9241525




    3,9241525











    • can you put a tab instead of the space?
      – Marwah Soliman
      Nov 21 '17 at 1:44










    • Just replace the space with t. Since your question asks for space I need to leave the answer consistent with that so as not to confuse other people.
      – B Layer
      Nov 21 '17 at 1:46











    • between the 1 and 2 ??
      – Marwah Soliman
      Nov 21 '17 at 1:48










    • it gave me AtC , no tab !
      – Marwah Soliman
      Nov 21 '17 at 1:50










    • a separated by a tab b...
      – Marwah Soliman
      Nov 21 '17 at 2:02

















    • can you put a tab instead of the space?
      – Marwah Soliman
      Nov 21 '17 at 1:44










    • Just replace the space with t. Since your question asks for space I need to leave the answer consistent with that so as not to confuse other people.
      – B Layer
      Nov 21 '17 at 1:46











    • between the 1 and 2 ??
      – Marwah Soliman
      Nov 21 '17 at 1:48










    • it gave me AtC , no tab !
      – Marwah Soliman
      Nov 21 '17 at 1:50










    • a separated by a tab b...
      – Marwah Soliman
      Nov 21 '17 at 2:02
















    can you put a tab instead of the space?
    – Marwah Soliman
    Nov 21 '17 at 1:44




    can you put a tab instead of the space?
    – Marwah Soliman
    Nov 21 '17 at 1:44












    Just replace the space with t. Since your question asks for space I need to leave the answer consistent with that so as not to confuse other people.
    – B Layer
    Nov 21 '17 at 1:46





    Just replace the space with t. Since your question asks for space I need to leave the answer consistent with that so as not to confuse other people.
    – B Layer
    Nov 21 '17 at 1:46













    between the 1 and 2 ??
    – Marwah Soliman
    Nov 21 '17 at 1:48




    between the 1 and 2 ??
    – Marwah Soliman
    Nov 21 '17 at 1:48












    it gave me AtC , no tab !
    – Marwah Soliman
    Nov 21 '17 at 1:50




    it gave me AtC , no tab !
    – Marwah Soliman
    Nov 21 '17 at 1:50












    a separated by a tab b...
    – Marwah Soliman
    Nov 21 '17 at 2:02





    a separated by a tab b...
    – Marwah Soliman
    Nov 21 '17 at 2:02













    up vote
    0
    down vote













    Please find the below command and output


    it replaces _ with spaces through out the file



    awk 'gsub("_"," ",$0);print $0' j.txt 
    D0024949 0 C C A G A G A A A G
    D0024302 0 A C A A A G A A A A
    D0023151 0 C C A G A A A A G G
    D0022042 0 A C A A G G A A A A
    D0021275 0 C C A G A G A A A G
    D0021163 0 A A A A G G A A A A
    D0020795 0 A A A A G G A C A G
    D0020691 0 A A A A G G A C A G
    D0019121 0 A A A A G G C C G G


    IF want it to be replace only first match



    sed "s/_/ /1" inputfile



    Let us know for any clarification kindly provide the proper input and output






    share|improve this answer
























      up vote
      0
      down vote













      Please find the below command and output


      it replaces _ with spaces through out the file



      awk 'gsub("_"," ",$0);print $0' j.txt 
      D0024949 0 C C A G A G A A A G
      D0024302 0 A C A A A G A A A A
      D0023151 0 C C A G A A A A G G
      D0022042 0 A C A A G G A A A A
      D0021275 0 C C A G A G A A A G
      D0021163 0 A A A A G G A A A A
      D0020795 0 A A A A G G A C A G
      D0020691 0 A A A A G G A C A G
      D0019121 0 A A A A G G C C G G


      IF want it to be replace only first match



      sed "s/_/ /1" inputfile



      Let us know for any clarification kindly provide the proper input and output






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Please find the below command and output


        it replaces _ with spaces through out the file



        awk 'gsub("_"," ",$0);print $0' j.txt 
        D0024949 0 C C A G A G A A A G
        D0024302 0 A C A A A G A A A A
        D0023151 0 C C A G A A A A G G
        D0022042 0 A C A A G G A A A A
        D0021275 0 C C A G A G A A A G
        D0021163 0 A A A A G G A A A A
        D0020795 0 A A A A G G A C A G
        D0020691 0 A A A A G G A C A G
        D0019121 0 A A A A G G C C G G


        IF want it to be replace only first match



        sed "s/_/ /1" inputfile



        Let us know for any clarification kindly provide the proper input and output






        share|improve this answer












        Please find the below command and output


        it replaces _ with spaces through out the file



        awk 'gsub("_"," ",$0);print $0' j.txt 
        D0024949 0 C C A G A G A A A G
        D0024302 0 A C A A A G A A A A
        D0023151 0 C C A G A A A A G G
        D0022042 0 A C A A G G A A A A
        D0021275 0 C C A G A G A A A G
        D0021163 0 A A A A G G A A A A
        D0020795 0 A A A A G G A C A G
        D0020691 0 A A A A G G A C A G
        D0019121 0 A A A A G G C C G G


        IF want it to be replace only first match



        sed "s/_/ /1" inputfile



        Let us know for any clarification kindly provide the proper input and output







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '17 at 2:19









        Praveen Kumar BS

        1,010128




        1,010128












            Popular posts from this blog

            Peggy Mitchell

            The Forum (Inglewood, California)

            Palaiologos