sed with filename from pipe -


I have several files with many parameters of file names in one folder, such as (with only one parameter) File_a1.0 .txt , file_a1.2.txt etc.
These are generated by C ++ code and I will need to produce the last time (on time). When a code expires, I do not know the priority of the value of this parameter. After this I have to copy the second line of this final file.

To copy the second line of any file, I know that this sed command works:

  sed -n 2p filename  

I also know how to find the last generated file:

  ls -rtl file_a * .txt | Tail-1  

Question:

How to combine both of these tasks? It is certainly possible that the second operation pipe is done for that operation, but I know how to insert the filename from the pipe as input in that command.

You can use it,

  ls -rt1 file_a * .txt | Tail-1 Xargs sed -n '2p'  

(OR)

  sed -n '2p' `ls -rt1 file_a * .txt | Tail -1` cad-n '2p' $ (ls-rt1 file_a * .txt | tail -1)  

Comments