I am trying to write a command output to a csv file .Below is the command i want to use to write the data into a csv file
ps -eo pid,comm,pmem,vsz | grep process | awk '{print $1",",$2",",$3",",$4}'
How we can do this in Perl . Header of the csv file should have and then corresponding values for this :
pid,comm,pmem,vsz
I was trying to do something like this but it is not working for me :
echo "execution started.."
pid,comm,pmem,vsz >> out.txt
while [ true ]; do
echo "running.."
sleep 2
ps -eo pid,comm,pmem,vsz | grep process | awk '{print $1",",$2",",$3",",$4}' >> out.txt
done