Bash: combining of the composition of the multiple log files based on the search pattern

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











up vote
0
down vote

favorite












I have a folder with many of the txt files. Where each of the file is present in the following format:



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335


My aim: is to loop the files within the folder and combine them together within the one global output. Notable in the example, I want to consider only the strings after (and including it) the "19 (this number is different in each of the file) contacts" , thus skipping the first six lines of the file.



Possible work-flow for the realization:



# make a log file which will contain info from all files going to be looped on the next step.
echo "This is a beginning of the global output" > ./final_output.txt
# that is a key phrase which is the indicator of the first string which should be taken from each of the files
key= "#any of the digit# contacts"

#now I want to loop each of the files with the aim to add all of the strings after (and including) $key to the final_output.txt
for file in $folder/*.txt; do
file_title=$(basename "$file")
# 1- print the $file_title within the final_output.txt
# 2 - add all of the strings from the file into the final_output.txt
# NB ! I need to take only the strings after (and including) the key-phrace

done






share|improve this question




















  • If you are sure there are always 6 lines at beginning to remove, tail -n +6 would do the trick
    – Patrick Mevzek
    Dec 7 '17 at 15:00










  • i want more complex general sollution to do the search againt the keyword. BTW what command can add the name of the lopped file to the beggining of the big log ?
    – user3470313
    Dec 7 '17 at 16:35














up vote
0
down vote

favorite












I have a folder with many of the txt files. Where each of the file is present in the following format:



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335


My aim: is to loop the files within the folder and combine them together within the one global output. Notable in the example, I want to consider only the strings after (and including it) the "19 (this number is different in each of the file) contacts" , thus skipping the first six lines of the file.



Possible work-flow for the realization:



# make a log file which will contain info from all files going to be looped on the next step.
echo "This is a beginning of the global output" > ./final_output.txt
# that is a key phrase which is the indicator of the first string which should be taken from each of the files
key= "#any of the digit# contacts"

#now I want to loop each of the files with the aim to add all of the strings after (and including) $key to the final_output.txt
for file in $folder/*.txt; do
file_title=$(basename "$file")
# 1- print the $file_title within the final_output.txt
# 2 - add all of the strings from the file into the final_output.txt
# NB ! I need to take only the strings after (and including) the key-phrace

done






share|improve this question




















  • If you are sure there are always 6 lines at beginning to remove, tail -n +6 would do the trick
    – Patrick Mevzek
    Dec 7 '17 at 15:00










  • i want more complex general sollution to do the search againt the keyword. BTW what command can add the name of the lopped file to the beggining of the big log ?
    – user3470313
    Dec 7 '17 at 16:35












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a folder with many of the txt files. Where each of the file is present in the following format:



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335


My aim: is to loop the files within the folder and combine them together within the one global output. Notable in the example, I want to consider only the strings after (and including it) the "19 (this number is different in each of the file) contacts" , thus skipping the first six lines of the file.



Possible work-flow for the realization:



# make a log file which will contain info from all files going to be looped on the next step.
echo "This is a beginning of the global output" > ./final_output.txt
# that is a key phrase which is the indicator of the first string which should be taken from each of the files
key= "#any of the digit# contacts"

#now I want to loop each of the files with the aim to add all of the strings after (and including) $key to the final_output.txt
for file in $folder/*.txt; do
file_title=$(basename "$file")
# 1- print the $file_title within the final_output.txt
# 2 - add all of the strings from the file into the final_output.txt
# NB ! I need to take only the strings after (and including) the key-phrace

done






share|improve this question












I have a folder with many of the txt files. Where each of the file is present in the following format:



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335


My aim: is to loop the files within the folder and combine them together within the one global output. Notable in the example, I want to consider only the strings after (and including it) the "19 (this number is different in each of the file) contacts" , thus skipping the first six lines of the file.



Possible work-flow for the realization:



# make a log file which will contain info from all files going to be looped on the next step.
echo "This is a beginning of the global output" > ./final_output.txt
# that is a key phrase which is the indicator of the first string which should be taken from each of the files
key= "#any of the digit# contacts"

#now I want to loop each of the files with the aim to add all of the strings after (and including) $key to the final_output.txt
for file in $folder/*.txt; do
file_title=$(basename "$file")
# 1- print the $file_title within the final_output.txt
# 2 - add all of the strings from the file into the final_output.txt
# NB ! I need to take only the strings after (and including) the key-phrace

done








share|improve this question











share|improve this question




share|improve this question










asked Dec 7 '17 at 14:50









user3470313

1




1











  • If you are sure there are always 6 lines at beginning to remove, tail -n +6 would do the trick
    – Patrick Mevzek
    Dec 7 '17 at 15:00










  • i want more complex general sollution to do the search againt the keyword. BTW what command can add the name of the lopped file to the beggining of the big log ?
    – user3470313
    Dec 7 '17 at 16:35
















  • If you are sure there are always 6 lines at beginning to remove, tail -n +6 would do the trick
    – Patrick Mevzek
    Dec 7 '17 at 15:00










  • i want more complex general sollution to do the search againt the keyword. BTW what command can add the name of the lopped file to the beggining of the big log ?
    – user3470313
    Dec 7 '17 at 16:35















If you are sure there are always 6 lines at beginning to remove, tail -n +6 would do the trick
– Patrick Mevzek
Dec 7 '17 at 15:00




If you are sure there are always 6 lines at beginning to remove, tail -n +6 would do the trick
– Patrick Mevzek
Dec 7 '17 at 15:00












i want more complex general sollution to do the search againt the keyword. BTW what command can add the name of the lopped file to the beggining of the big log ?
– user3470313
Dec 7 '17 at 16:35




i want more complex general sollution to do the search againt the keyword. BTW what command can add the name of the lopped file to the beggining of the big log ?
– user3470313
Dec 7 '17 at 16:35










2 Answers
2






active

oldest

votes

















up vote
0
down vote













Taken the example of 3 files



file1



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file3



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file4



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



Below is code which will save the output from 19contacts,17contacts,12 contacts till the end of file



 for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i; done > /var/tmp/outputfile.txt


output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer




















  • Thank you it works very good! Here the expression for SED is looking exactly for the pattern like "digit contacts", does not it? One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12










  • Use below command to get the same for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i| head -1| awk -v i="$i" 'print $0" " "from" " " i' ; sed -n '/^[0-9]/,$p' $i;done. it will print as example 19 contacts from file1
    – Praveen Kumar BS
    Dec 7 '17 at 18:26










  • Kindly Vote for my answer
    – Praveen Kumar BS
    Dec 7 '17 at 18:27










  • Thanks! is it possible that the script write not the path to the file at the end but rather the name of the file (w.o. its extension?) As I will reach 15 posts I will vote for your answer !!
    – user3470313
    Dec 8 '17 at 13:58










  • OK No problem Will wait for your vote. Can You please explain your query clearly
    – Praveen Kumar BS
    Dec 8 '17 at 15:50

















up vote
0
down vote













I Found another Method with the same input files



Code:



 for i in file1 file3 file4; do sed '1,6d' $i; done > /var/tmp/outputfile.txt


Output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer




















  • Thank you! One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12











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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f409490%2fbash-combining-of-the-composition-of-the-multiple-log-files-based-on-the-search%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
0
down vote













Taken the example of 3 files



file1



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file3



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file4



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



Below is code which will save the output from 19contacts,17contacts,12 contacts till the end of file



 for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i; done > /var/tmp/outputfile.txt


output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer




















  • Thank you it works very good! Here the expression for SED is looking exactly for the pattern like "digit contacts", does not it? One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12










  • Use below command to get the same for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i| head -1| awk -v i="$i" 'print $0" " "from" " " i' ; sed -n '/^[0-9]/,$p' $i;done. it will print as example 19 contacts from file1
    – Praveen Kumar BS
    Dec 7 '17 at 18:26










  • Kindly Vote for my answer
    – Praveen Kumar BS
    Dec 7 '17 at 18:27










  • Thanks! is it possible that the script write not the path to the file at the end but rather the name of the file (w.o. its extension?) As I will reach 15 posts I will vote for your answer !!
    – user3470313
    Dec 8 '17 at 13:58










  • OK No problem Will wait for your vote. Can You please explain your query clearly
    – Praveen Kumar BS
    Dec 8 '17 at 15:50














up vote
0
down vote













Taken the example of 3 files



file1



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file3



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file4



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



Below is code which will save the output from 19contacts,17contacts,12 contacts till the end of file



 for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i; done > /var/tmp/outputfile.txt


output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer




















  • Thank you it works very good! Here the expression for SED is looking exactly for the pattern like "digit contacts", does not it? One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12










  • Use below command to get the same for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i| head -1| awk -v i="$i" 'print $0" " "from" " " i' ; sed -n '/^[0-9]/,$p' $i;done. it will print as example 19 contacts from file1
    – Praveen Kumar BS
    Dec 7 '17 at 18:26










  • Kindly Vote for my answer
    – Praveen Kumar BS
    Dec 7 '17 at 18:27










  • Thanks! is it possible that the script write not the path to the file at the end but rather the name of the file (w.o. its extension?) As I will reach 15 posts I will vote for your answer !!
    – user3470313
    Dec 8 '17 at 13:58










  • OK No problem Will wait for your vote. Can You please explain your query clearly
    – Praveen Kumar BS
    Dec 8 '17 at 15:50












up vote
0
down vote










up vote
0
down vote









Taken the example of 3 files



file1



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file3



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file4



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



Below is code which will save the output from 19contacts,17contacts,12 contacts till the end of file



 for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i; done > /var/tmp/outputfile.txt


output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer












Taken the example of 3 files



file1



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file3



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



file4



Allowed overlap: -3
H-bond overlap reduction: 0.4
Ignore contacts between atoms separated by 4 bonds or less
Detect intra-residue contacts: False
Detect intra-molecule contacts: False

12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335



Below is code which will save the output from 19contacts,17contacts,12 contacts till the end of file



 for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i; done > /var/tmp/outputfile.txt


output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 7 '17 at 15:17









Praveen Kumar BS

1,010128




1,010128











  • Thank you it works very good! Here the expression for SED is looking exactly for the pattern like "digit contacts", does not it? One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12










  • Use below command to get the same for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i| head -1| awk -v i="$i" 'print $0" " "from" " " i' ; sed -n '/^[0-9]/,$p' $i;done. it will print as example 19 contacts from file1
    – Praveen Kumar BS
    Dec 7 '17 at 18:26










  • Kindly Vote for my answer
    – Praveen Kumar BS
    Dec 7 '17 at 18:27










  • Thanks! is it possible that the script write not the path to the file at the end but rather the name of the file (w.o. its extension?) As I will reach 15 posts I will vote for your answer !!
    – user3470313
    Dec 8 '17 at 13:58










  • OK No problem Will wait for your vote. Can You please explain your query clearly
    – Praveen Kumar BS
    Dec 8 '17 at 15:50
















  • Thank you it works very good! Here the expression for SED is looking exactly for the pattern like "digit contacts", does not it? One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12










  • Use below command to get the same for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i| head -1| awk -v i="$i" 'print $0" " "from" " " i' ; sed -n '/^[0-9]/,$p' $i;done. it will print as example 19 contacts from file1
    – Praveen Kumar BS
    Dec 7 '17 at 18:26










  • Kindly Vote for my answer
    – Praveen Kumar BS
    Dec 7 '17 at 18:27










  • Thanks! is it possible that the script write not the path to the file at the end but rather the name of the file (w.o. its extension?) As I will reach 15 posts I will vote for your answer !!
    – user3470313
    Dec 8 '17 at 13:58










  • OK No problem Will wait for your vote. Can You please explain your query clearly
    – Praveen Kumar BS
    Dec 8 '17 at 15:50















Thank you it works very good! Here the expression for SED is looking exactly for the pattern like "digit contacts", does not it? One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
– user3470313
Dec 7 '17 at 16:12




Thank you it works very good! Here the expression for SED is looking exactly for the pattern like "digit contacts", does not it? One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
– user3470313
Dec 7 '17 at 16:12












Use below command to get the same for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i| head -1| awk -v i="$i" 'print $0" " "from" " " i' ; sed -n '/^[0-9]/,$p' $i;done. it will print as example 19 contacts from file1
– Praveen Kumar BS
Dec 7 '17 at 18:26




Use below command to get the same for i in file1 file3 file4; do sed -n '/^[0-9]/,$p' $i| head -1| awk -v i="$i" 'print $0" " "from" " " i' ; sed -n '/^[0-9]/,$p' $i;done. it will print as example 19 contacts from file1
– Praveen Kumar BS
Dec 7 '17 at 18:26












Kindly Vote for my answer
– Praveen Kumar BS
Dec 7 '17 at 18:27




Kindly Vote for my answer
– Praveen Kumar BS
Dec 7 '17 at 18:27












Thanks! is it possible that the script write not the path to the file at the end but rather the name of the file (w.o. its extension?) As I will reach 15 posts I will vote for your answer !!
– user3470313
Dec 8 '17 at 13:58




Thanks! is it possible that the script write not the path to the file at the end but rather the name of the file (w.o. its extension?) As I will reach 15 posts I will vote for your answer !!
– user3470313
Dec 8 '17 at 13:58












OK No problem Will wait for your vote. Can You please explain your query clearly
– Praveen Kumar BS
Dec 8 '17 at 15:50




OK No problem Will wait for your vote. Can You please explain your query clearly
– Praveen Kumar BS
Dec 8 '17 at 15:50












up vote
0
down vote













I Found another Method with the same input files



Code:



 for i in file1 file3 file4; do sed '1,6d' $i; done > /var/tmp/outputfile.txt


Output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer




















  • Thank you! One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12















up vote
0
down vote













I Found another Method with the same input files



Code:



 for i in file1 file3 file4; do sed '1,6d' $i; done > /var/tmp/outputfile.txt


Output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer




















  • Thank you! One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12













up vote
0
down vote










up vote
0
down vote









I Found another Method with the same input files



Code:



 for i in file1 file3 file4; do sed '1,6d' $i; done > /var/tmp/outputfile.txt


Output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335





share|improve this answer












I Found another Method with the same input files



Code:



 for i in file1 file3 file4; do sed '1,6d' $i; done > /var/tmp/outputfile.txt


Output



19 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
17 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335
12 contacts
atom1 atom2 overlap distance
:128.B@BB :300.C@BB -1.676 4.996
:179.B@BB :17.C@BB -1.898 5.218
:182.B@BB :17.C@BB -2.015 5.335






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 7 '17 at 15:25









Praveen Kumar BS

1,010128




1,010128











  • Thank you! One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12

















  • Thank you! One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
    – user3470313
    Dec 7 '17 at 16:12
















Thank you! One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
– user3470313
Dec 7 '17 at 16:12





Thank you! One question: is it possible to add near the begining of each entity the name of the file from which it has been taken e.g: 19 contacts from file1 ?
– user3470313
Dec 7 '17 at 16:12


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409490%2fbash-combining-of-the-composition-of-the-multiple-log-files-based-on-the-search%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)