Output sar command results to a csv file
I'm relatively new to shell programming and would like to know if there is a simple way to output the results of the sar command to a csv file. Using sar > file1.csv does the job, but it is not properly formatted. All the data is present in one column. I tried this, but it was worse sar -d -u -w 1 1 | grep -v Average | grep -v Linux | tr -s ' ' ',' | tr -d '\n' > file1.csv Can anyone give me the right script to store the output of the sar command in a csv file. Help will be appreciated. sar -d -u -w 1 1 | grep -v Average | grep -v Linux |awk '{if ($0 ~ /[0-9]/) { print $1","$2","$4","$5","$6;