Source_FIle:
/path/to file/A_B_C_D_201507290915.csv
Destination_File should be like :
/some/other/path/to file/A_B_C_D_201507290915.csv
I need to transform Source_FIle and storing with the same name in some other location.
Transformation is like converting all the rows of csv in column. CODE used:
#!/bin/bash
var=`echo A_B_C_D_*.csv | grep -oP '(?<=_)\d+(?=\.)'`
awk -F, '{for(i=1;i<=NF;i++){A[NR,i]=$i};if(NF>n){n=NF}}
END{for(i=1;i<=n;i++){
for(j=1;j<=NR;j++){
s=s?s","A[j,i]:A[j,i]}
print s;s=""}}' A_B_C_D_*.csv > /some/other/path/to file/A_B_C_D_$var.csv
It is working fine for one file but in case of multiple source files its giving ambiguous redirect error.