Matching the lines that have more then one space and printing them

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








up vote
1
down vote

favorite












I have a 23 folders and each folder has two subfolders (always same name) and each subfolder has exactly two files (always same name). So it looks like this:



Folder1/BindingDB/chiral.smi
nochiral.smi
Folder1/Xray/chiral.smi
nochiral.smi

Folder2/BindingDB/chiral.smi
nochiral.smi
Folder2/Xray/chiral.smi
nochiral.smi


For example chiral.smi file looks like this:



COCCNC(=O)[C@H]1[C@@H]([C@H]2CN3C(=O)C=CC=C3[C@@H]1N2C4=NC(=C(S4)C5=CC=CC=C5)C6=CC=C(C=C6)Cl)CO K00000004
C1[C@H]2[C@H](C=C([C@H]3[C@@H]2[C@H]4[C@@H]1[C@@H]([C@H]4C=C3)CC/C=C/CC5=CC=C(C=C5)O)C(=O)O)O K00000005
C[C@]12CCC[C@@]([C@@H]1CC[C@@]34[C@H]2C[C@H]5[C@@H](C3)[C@]5(C4)CO)(C)C(=O)O K00000006


So here, last two lines K00000005 and K00000006 have double space and I want to match these two lines.



I am trying to double check all chiral.smi and nochiral.smi files in my folders if they have lines that have double space (I should only have one space in each line of each file).



I have tried in bash something like this:



for i in */*/*.smi ; do sed -e "s/s2,/ /g" $i; done but it is not working. Also, when I run sed -e "s/s3,/ /g" *smi in subfolder (BindingDB or Xray) it prints all the lines that have only one space. Can anyone help me since I cannot figure out whats the problem?







share|improve this question






















  • Are you trying to check the files - or correct them?
    – steeldriver
    May 16 at 10:46










  • I am trying to check the files..but I came across the idea to open all of them in one txt file and then I just searched for double space and havent found it so it should be fine :)
    – sergio
    May 17 at 2:17














up vote
1
down vote

favorite












I have a 23 folders and each folder has two subfolders (always same name) and each subfolder has exactly two files (always same name). So it looks like this:



Folder1/BindingDB/chiral.smi
nochiral.smi
Folder1/Xray/chiral.smi
nochiral.smi

Folder2/BindingDB/chiral.smi
nochiral.smi
Folder2/Xray/chiral.smi
nochiral.smi


For example chiral.smi file looks like this:



COCCNC(=O)[C@H]1[C@@H]([C@H]2CN3C(=O)C=CC=C3[C@@H]1N2C4=NC(=C(S4)C5=CC=CC=C5)C6=CC=C(C=C6)Cl)CO K00000004
C1[C@H]2[C@H](C=C([C@H]3[C@@H]2[C@H]4[C@@H]1[C@@H]([C@H]4C=C3)CC/C=C/CC5=CC=C(C=C5)O)C(=O)O)O K00000005
C[C@]12CCC[C@@]([C@@H]1CC[C@@]34[C@H]2C[C@H]5[C@@H](C3)[C@]5(C4)CO)(C)C(=O)O K00000006


So here, last two lines K00000005 and K00000006 have double space and I want to match these two lines.



I am trying to double check all chiral.smi and nochiral.smi files in my folders if they have lines that have double space (I should only have one space in each line of each file).



I have tried in bash something like this:



for i in */*/*.smi ; do sed -e "s/s2,/ /g" $i; done but it is not working. Also, when I run sed -e "s/s3,/ /g" *smi in subfolder (BindingDB or Xray) it prints all the lines that have only one space. Can anyone help me since I cannot figure out whats the problem?







share|improve this question






















  • Are you trying to check the files - or correct them?
    – steeldriver
    May 16 at 10:46










  • I am trying to check the files..but I came across the idea to open all of them in one txt file and then I just searched for double space and havent found it so it should be fine :)
    – sergio
    May 17 at 2:17












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a 23 folders and each folder has two subfolders (always same name) and each subfolder has exactly two files (always same name). So it looks like this:



Folder1/BindingDB/chiral.smi
nochiral.smi
Folder1/Xray/chiral.smi
nochiral.smi

Folder2/BindingDB/chiral.smi
nochiral.smi
Folder2/Xray/chiral.smi
nochiral.smi


For example chiral.smi file looks like this:



COCCNC(=O)[C@H]1[C@@H]([C@H]2CN3C(=O)C=CC=C3[C@@H]1N2C4=NC(=C(S4)C5=CC=CC=C5)C6=CC=C(C=C6)Cl)CO K00000004
C1[C@H]2[C@H](C=C([C@H]3[C@@H]2[C@H]4[C@@H]1[C@@H]([C@H]4C=C3)CC/C=C/CC5=CC=C(C=C5)O)C(=O)O)O K00000005
C[C@]12CCC[C@@]([C@@H]1CC[C@@]34[C@H]2C[C@H]5[C@@H](C3)[C@]5(C4)CO)(C)C(=O)O K00000006


So here, last two lines K00000005 and K00000006 have double space and I want to match these two lines.



I am trying to double check all chiral.smi and nochiral.smi files in my folders if they have lines that have double space (I should only have one space in each line of each file).



I have tried in bash something like this:



for i in */*/*.smi ; do sed -e "s/s2,/ /g" $i; done but it is not working. Also, when I run sed -e "s/s3,/ /g" *smi in subfolder (BindingDB or Xray) it prints all the lines that have only one space. Can anyone help me since I cannot figure out whats the problem?







share|improve this question














I have a 23 folders and each folder has two subfolders (always same name) and each subfolder has exactly two files (always same name). So it looks like this:



Folder1/BindingDB/chiral.smi
nochiral.smi
Folder1/Xray/chiral.smi
nochiral.smi

Folder2/BindingDB/chiral.smi
nochiral.smi
Folder2/Xray/chiral.smi
nochiral.smi


For example chiral.smi file looks like this:



COCCNC(=O)[C@H]1[C@@H]([C@H]2CN3C(=O)C=CC=C3[C@@H]1N2C4=NC(=C(S4)C5=CC=CC=C5)C6=CC=C(C=C6)Cl)CO K00000004
C1[C@H]2[C@H](C=C([C@H]3[C@@H]2[C@H]4[C@@H]1[C@@H]([C@H]4C=C3)CC/C=C/CC5=CC=C(C=C5)O)C(=O)O)O K00000005
C[C@]12CCC[C@@]([C@@H]1CC[C@@]34[C@H]2C[C@H]5[C@@H](C3)[C@]5(C4)CO)(C)C(=O)O K00000006


So here, last two lines K00000005 and K00000006 have double space and I want to match these two lines.



I am trying to double check all chiral.smi and nochiral.smi files in my folders if they have lines that have double space (I should only have one space in each line of each file).



I have tried in bash something like this:



for i in */*/*.smi ; do sed -e "s/s2,/ /g" $i; done but it is not working. Also, when I run sed -e "s/s3,/ /g" *smi in subfolder (BindingDB or Xray) it prints all the lines that have only one space. Can anyone help me since I cannot figure out whats the problem?









share|improve this question













share|improve this question




share|improve this question








edited May 16 at 3:01

























asked May 16 at 2:52









sergio

565




565











  • Are you trying to check the files - or correct them?
    – steeldriver
    May 16 at 10:46










  • I am trying to check the files..but I came across the idea to open all of them in one txt file and then I just searched for double space and havent found it so it should be fine :)
    – sergio
    May 17 at 2:17
















  • Are you trying to check the files - or correct them?
    – steeldriver
    May 16 at 10:46










  • I am trying to check the files..but I came across the idea to open all of them in one txt file and then I just searched for double space and havent found it so it should be fine :)
    – sergio
    May 17 at 2:17















Are you trying to check the files - or correct them?
– steeldriver
May 16 at 10:46




Are you trying to check the files - or correct them?
– steeldriver
May 16 at 10:46












I am trying to check the files..but I came across the idea to open all of them in one txt file and then I just searched for double space and havent found it so it should be fine :)
– sergio
May 17 at 2:17




I am trying to check the files..but I came across the idea to open all of them in one txt file and then I just searched for double space and havent found it so it should be fine :)
– sergio
May 17 at 2:17










2 Answers
2






active

oldest

votes

















up vote
2
down vote













You can list the names of any .smi files in which any line contains two adjacent spaces with



grep --include='*.smi' -rl ' ' .


If you want to output the lines themselves, then remove the l option.






share|improve this answer



























    up vote
    0
    down vote













    If I understand it correctly, something like



    grep -l ' ' */*/*.smi


    will print the "double space" filenames



    If you want do normalize spaces (' ' -> ' ') you can try to



    sed -ri.bak 's/s2,/ /g' */*/*.smi


    and remove the backup files if all went well



    rm /*/*.smi.bak





    share|improve this answer






















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "89"
      ;
      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',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );








       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036769%2fmatching-the-lines-that-have-more-then-one-space-and-printing-them%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote













      You can list the names of any .smi files in which any line contains two adjacent spaces with



      grep --include='*.smi' -rl ' ' .


      If you want to output the lines themselves, then remove the l option.






      share|improve this answer
























        up vote
        2
        down vote













        You can list the names of any .smi files in which any line contains two adjacent spaces with



        grep --include='*.smi' -rl ' ' .


        If you want to output the lines themselves, then remove the l option.






        share|improve this answer






















          up vote
          2
          down vote










          up vote
          2
          down vote









          You can list the names of any .smi files in which any line contains two adjacent spaces with



          grep --include='*.smi' -rl ' ' .


          If you want to output the lines themselves, then remove the l option.






          share|improve this answer












          You can list the names of any .smi files in which any line contains two adjacent spaces with



          grep --include='*.smi' -rl ' ' .


          If you want to output the lines themselves, then remove the l option.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 17 at 2:30









          steeldriver

          62.1k1196163




          62.1k1196163






















              up vote
              0
              down vote













              If I understand it correctly, something like



              grep -l ' ' */*/*.smi


              will print the "double space" filenames



              If you want do normalize spaces (' ' -> ' ') you can try to



              sed -ri.bak 's/s2,/ /g' */*/*.smi


              and remove the backup files if all went well



              rm /*/*.smi.bak





              share|improve this answer


























                up vote
                0
                down vote













                If I understand it correctly, something like



                grep -l ' ' */*/*.smi


                will print the "double space" filenames



                If you want do normalize spaces (' ' -> ' ') you can try to



                sed -ri.bak 's/s2,/ /g' */*/*.smi


                and remove the backup files if all went well



                rm /*/*.smi.bak





                share|improve this answer
























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  If I understand it correctly, something like



                  grep -l ' ' */*/*.smi


                  will print the "double space" filenames



                  If you want do normalize spaces (' ' -> ' ') you can try to



                  sed -ri.bak 's/s2,/ /g' */*/*.smi


                  and remove the backup files if all went well



                  rm /*/*.smi.bak





                  share|improve this answer














                  If I understand it correctly, something like



                  grep -l ' ' */*/*.smi


                  will print the "double space" filenames



                  If you want do normalize spaces (' ' -> ' ') you can try to



                  sed -ri.bak 's/s2,/ /g' */*/*.smi


                  and remove the backup files if all went well



                  rm /*/*.smi.bak






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 17 at 8:36

























                  answered May 17 at 8:28









                  JJoao

                  1,24059




                  1,24059






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036769%2fmatching-the-lines-that-have-more-then-one-space-and-printing-them%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      pylint3 and pip3 broken

                      Missing snmpget and snmpwalk

                      How to enroll fingerprints to Ubuntu 17.10 with VFS491