Answers for "awk min and max passing bash variable to awk"

0

awk min and max passing bash variable to awk

min=`cat plot_data.dat | sort -nk2,2 | head -1 | awk '{print $2}'`
		 ^#your_FILE			 ^colum you need to find min  ^print the minimum

#assign your minimum to varible 
min_a=`cat plot_data.dat | sort -nk2,2 | head -1 | awk '{print $2}'` 

#get your minimum work like this,
cat plot_data.dat | awk -v ref=$min_a '{print $1"\t"$2-ref}' > ref_zero_plot_data.dat

#new data is here
cat ref_zero_plot_data.dat

#for maximum use tail -1
max=`cat plot_data.dat | sort -nk2,2 | tail -1 | awk '{print $2}'`
Posted by: Guest on August-03-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language