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

Clash 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
bash shell-script awk logs
add a comment |Â
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
bash shell-script awk logs
If you are sure there are always 6 lines at beginning to remove,tail -n +6would 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
add a comment |Â
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
bash shell-script awk logs
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
bash shell-script awk logs
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 +6would 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
add a comment |Â
If you are sure there are always 6 lines at beginning to remove,tail -n +6would 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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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%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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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');
);
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');
);
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
If you are sure there are always 6 lines at beginning to remove,
tail -n +6would 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