Matching the lines that have more then one space and printing them
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
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?
bash text-processing
add a comment |Â
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?
bash text-processing
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
add a comment |Â
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?
bash text-processing
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?
bash text-processing
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
add a comment |Â
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
add a comment |Â
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.
add a comment |Â
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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered May 17 at 2:30
steeldriver
62.1k1196163
62.1k1196163
add a comment |Â
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
edited May 17 at 8:36
answered May 17 at 8:28
JJoao
1,24059
1,24059
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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