In the folder I have many files with several parameters in the file names, for example (with only one parameter) file_a1.0.txt, file_a1.2.txtetc.
They are generated using C ++ code, and I will need to take the last one (in time). I do not know a priori what the value of this parameter will be when the code is interrupted. After that I need to copy the second line of this last file.
To copy the second line of any file, I know this command sedworks:
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 these two operations? Of course, you can perform the second operation for this sed operation, but I do not know how to include the file name from the channel as input for this sed command.
source
share