Hi,
I would like to have bash function that would convert space-separated data table into comma-separated one. This is what I put together so far
function dat2csv() {
for fl in `find -type f -name "$1" -print`; do
#echo $fl;
bNm="$(basename $fl .dat)"; # echo $bNm;
of=$bNm".csv"; #echo $of;
echo $fl ">" $of;
sed 's/ /,/g' $fl > $of
done
}
This works but if I have table that is separated by 2 spaces than it fails. How to make this function useful in genaral case (separated by 1, 2 ... n spaces)?
thx
p.
I would like to have bash function that would convert space-separated data table into comma-separated one. This is what I put together so far
function dat2csv() {
for fl in `find -type f -name "$1" -print`; do
#echo $fl;
bNm="$(basename $fl .dat)"; # echo $bNm;
of=$bNm".csv"; #echo $of;
echo $fl ">" $of;
sed 's/ /,/g' $fl > $of
done
}
This works but if I have table that is separated by 2 spaces than it fails. How to make this function useful in genaral case (separated by 1, 2 ... n spaces)?
thx
p.