hi,
I would like to write out certain columns (number is not fixed) from datafile. My program starts like:
echo "chose columns separated by commas";
read col;
awk -v c=$col 'BEGIN{
search=",";
n=split(c,a,search);
for (i=1;i<=n;i++) {
print a;
}}{......}' dataFile.dat > newDataFile.dat
If for exapmple col="3,6,9" then just these 3 columns of dataFile.dat are ptinted out into newDataFile.dat; If col="2,4,7,3,66,7" then these 6 columns are printed out.
How to print out variable number of columns in awk?
k.
I would like to write out certain columns (number is not fixed) from datafile. My program starts like:
echo "chose columns separated by commas";
read col;
awk -v c=$col 'BEGIN{
search=",";
n=split(c,a,search);
for (i=1;i<=n;i++) {
print a;
}}{......}' dataFile.dat > newDataFile.dat
If for exapmple col="3,6,9" then just these 3 columns of dataFile.dat are ptinted out into newDataFile.dat; If col="2,4,7,3,66,7" then these 6 columns are printed out.
How to print out variable number of columns in awk?
k.