I have several thousands of files with coded weather information in a folder. To every file I need to add a header and footer with control characters. This is not the problem as I have the header and footer in separate files (achieved with the cat
command in a bash script).
However, the modified files need to retain their original names - this gives me a problem as I only have a very basic scripting knowledge. The reason for keeping them is that these files will be parsed and decoded. The file names contain vital information for how the decoders will process the content.
All the files that are to be decoded are in a separate file, list_of_files_to_decode.txt
.
A part of the folder content can look like this:
a_snvs02wiix170600_c_eswi_20121117062131_76.txt
a_smci40babj170600_c_kwbc_20121117061545_3.txt
a_sath40vtbb170600_c_ekmi_20121117061604_95.txt
a_usxx40mynn70600cca_c_edzw_20121117062020_34.txt
a_siin40dems170600_c_ojam_20121117062020_40.txt
a_smxx40fapr170600rra_c_lowm_20121117062604_67.txt
list_of_files_to_decode.txt
start-seq.txt
stop-seq.txt
I have checked the web, and tested some of my own ideas - using awk
and sed
- but I can't really find that any suitable way of how I can achieve this in an easy way. So, I would appreciate some help or hints of how to proceed.