Trying to capitalize the content of the files that match the filename pattern "_base.txt"; then output the results to another folder with the original filename plus the "_cap.txt" in the end.
I plan to do this through 3,000 files. So I am testing it on a few files at the moment.
First I was able to get the content capitalized. But all output results were not redirected.
BASE="/home/dir/input/"
find "$BASE" -type f -iname "*.txt" -exec awk '{print toupper($0)}' {} +
Then I added the following, which allowed me to output to a new filename ended with "_cap.txt"
BASE="/home/dir/input/"
find "$BASE" -type f -iname "*_pv_bind_basefile.txt" -exec awk '{print toupper($0) >> (FILENAME "_cap.txt")}' {} +
The problem showed up when I try to output to a specific folder
BASE="/home/dir/input/"
OUT_FOLDER="/home/dir/output/"
find "$BASE" -type f -iname "*_pv_bind_basefile.txt" -exec awk '{print toupper($0) >> ($OUT_FOLDER FILENAME "_cap.txt")}' {} +
I got the following error message
awk: illegal field $(), name "OUT_FOLDER" input record number 1, file /home/dir/input/TAB1.a1.001.txt source line number 1
I tried several iterations to output the files and failed miserably after a few hours...It must be some simple thing that I overlooked or not knowing how to do it. Any suggestions would be highly appreciated. Thank you.