AWK is a handy tool to process large text files. Ever came across a need to replace 100 or more text files value in a single column? Of course, the old school method is to do it manually which is definitely time consuming and not efficient at all. Below is a sample code how to replace value in a column for all text files found in the directory specified. #!/bin/bash for file in /home/pc_text/Documents/source/* do xfilename=$(basename $file) #echo "$xfilename" if you need to display the filename while the code is running awk 'FNR==1{print $0}' $file >> /home/pc_text/Documents/output/$xfilename awk 'NR>1{print $1 , $2 , $3 , $4 , "0.873" , $6 , $7 }' $file >> /home/pc_text/Documents/output/$xfilename done Code explanation: for file in /home/pc_text/Documents/source/* - get all text files for processing xfilename=$(basename $file) – get all the filename of the text files awk...
Make the world a better place by sharing knowledge, ideas and anything that you can give that comes from the heart.