jeudi 30 décembre 2021

Join all files in a folder with specific filename pattern and omitting comments

Disclaimer: I am not expecting someone else to do all this for me (since this deserves a pay). However, any hint will help.

I have the current folder structure:

/components/cht/phrases-*-cht.txt
/components/chs/phrases-*-chs.txt

What I want to do, demonstrated in Makefile-style bash script (for example "cht"):

@> phrases-cht.int && awk 'NR>1 && FNR==1{print ""};1' ./components/cht/phrases-*-cht.txt | sed -e "/^#/d" > ./Build/DerivedData/phrases-cht.int

Which means:

  1. Concat all files of "phrases-*-cht.txt" from /components/cht/ into a temporary file phrases-cht.int (or better somewhere in the RAM if possible).
  2. Remove all lines started with # (if possible please also remove inline comments begun with //).

P.S.: If okay please do not use "boost". Cpp 17 is okay as long as its compiled executables are executable in Windows Vista or Windows 7.

Aucun commentaire:

Enregistrer un commentaire