Skip to main content
Rephrase title to reflect actual requirement
Source Link
AdminBee
  • 23.6k
  • 25
  • 56
  • 77

Add specificlast line of output to separate file in bash

I have written a bash script that performs 100 iterations of a programme. The output for each of these iterations has 14 lines, but I only need the 14th one for the rest of my analyses (AKA the last line).

I've read the answers to similar questions, but they all assume named lines for the output; whereas the 10th line of my output looks like this:

1 0 0.005 63.01

1 0 0.005 63.01

With no name for grep to hold on to.

I would like to take this 10th line, and for each iteration done in the bash script, attach the output to the bottom of another file (total_output.txt) like so:

left right p-value ratio

1 0 0.005 63.01
1 0 0.02 67.23

And so on for each iteration. Preferably, this would be in the same bash script as well and without having to save out the programme output for each iteration.

I'm still pretty new to Linux and bash scripting, so apologies if this question seems stupid. I couldn't really understand how to apply the answers to similar questions to my problem.

Add specific line of output to separate file in bash

I have written a bash script that performs 100 iterations of a programme. The output for each of these iterations has 14 lines, but I only need the 14th one for the rest of my analyses (AKA the last line).

I've read the answers to similar questions, but they all assume named lines for the output; whereas the 10th line of my output looks like this:

1 0 0.005 63.01

With no name for grep to hold on to.

I would like to take this 10th line, and for each iteration done in the bash script, attach the output to the bottom of another file (total_output.txt) like so:

left right p-value ratio

1 0 0.005 63.01
1 0 0.02 67.23

And so on for each iteration. Preferably, this would be in the same bash script as well and without having to save out the programme output for each iteration.

I'm still pretty new to Linux and bash scripting, so apologies if this question seems stupid. I couldn't really understand how to apply the answers to similar questions to my problem.

Add last line of output to separate file in bash

I have written a bash script that performs 100 iterations of a programme. The output for each of these iterations has 14 lines, but I only need the 14th one for the rest of my analyses (AKA the last line).

I've read the answers to similar questions, but they all assume named lines for the output; whereas the 10th line of my output looks like this:

1 0 0.005 63.01

With no name for grep to hold on to.

I would like to take this 10th line, and for each iteration done in the bash script, attach the output to the bottom of another file (total_output.txt) like so:

left right p-value ratio

1 0 0.005 63.01
1 0 0.02 67.23

And so on for each iteration. Preferably, this would be in the same bash script as well and without having to save out the programme output for each iteration.

I'm still pretty new to Linux and bash scripting, so apologies if this question seems stupid. I couldn't really understand how to apply the answers to similar questions to my problem.

added 13 characters in body
Source Link
hemr3
  • 3
  • 1
  • 3

I have written a bash script that performs 100 iterations of a programme. The output for each of these iterations has around 1014 lines, but I only need the 10th14th one for the rest of my analyses (AKA the last line).

I've read the answers to similar questions, but they all assume named lines for the output; whereas the 10th line of my output looks like this:

1 0 0.005 63.01

With no name for grep to hold on to.

I would like to take this 10th line, and for each iteration done in the bash script, attach the output to the bottom of another file (total_output.txt) like so:

left right p-value ratio

1 0 0.005 63.01
1 0 0.02 67.23

And so on for each iteration. Preferably, this would be in the same bash script as well and without having to save out the programme output for each iteration.

I'm still pretty new to Linux and bash scripting, so apologies if this question seems stupid. I couldn't really understand how to apply the answers to similar questions to my problem.

I have written a bash script that performs 100 iterations of a programme. The output for each of these iterations has around 10 lines, but I only need the 10th one for the rest of my analyses.

I've read the answers to similar questions, but they all assume named lines for the output; whereas the 10th line of my output looks like this:

1 0 0.005 63.01

With no name for grep to hold on to.

I would like to take this 10th line, and for each iteration done in the bash script, attach the output to the bottom of another file (total_output.txt) like so:

left right p-value ratio

1 0 0.005 63.01
1 0 0.02 67.23

And so on for each iteration. Preferably, this would be in the same bash script as well and without having to save out the programme output for each iteration.

I'm still pretty new to Linux and bash scripting, so apologies if this question seems stupid. I couldn't really understand how to apply the answers to similar questions to my problem.

I have written a bash script that performs 100 iterations of a programme. The output for each of these iterations has 14 lines, but I only need the 14th one for the rest of my analyses (AKA the last line).

I've read the answers to similar questions, but they all assume named lines for the output; whereas the 10th line of my output looks like this:

1 0 0.005 63.01

With no name for grep to hold on to.

I would like to take this 10th line, and for each iteration done in the bash script, attach the output to the bottom of another file (total_output.txt) like so:

left right p-value ratio

1 0 0.005 63.01
1 0 0.02 67.23

And so on for each iteration. Preferably, this would be in the same bash script as well and without having to save out the programme output for each iteration.

I'm still pretty new to Linux and bash scripting, so apologies if this question seems stupid. I couldn't really understand how to apply the answers to similar questions to my problem.

edited tags
Link
AdminBee
  • 23.6k
  • 25
  • 56
  • 77
Source Link
hemr3
  • 3
  • 1
  • 3
Loading