I am working on an inventory script to be used which will collect computer information across many devices and am looking for the best way to end up with a csv file with the information
Currently, I have this:
touch ZI_IT_Inventory_output.txt
touch ZI_IT_Inventory_output.csv
user_whoami=$(whoami)
user_lscpu=$(lscpu | sed -nr '/Model name/ s/.*:\s*(.*) @ .*/\1/p' )
user_lshw=$(lshw -C display |grep 'product' | cut -f 2 -d":" | awk '{$1=$1}1' )
user_how_many_gpu=$(lspci | grep VGA | wc -l)
user_how_many_cpu=$(lscpu | sed -nr '/Model name/ s/.*:\s*(.*) @ .*/\1/p' | wc -l)
user_how_much_ram=$(lshw -c memory |grep 'size' | cut -d':' -f2- | cut -d' ' -f2)
echo $user_whoami>>ZI_IT_Inventory_output.txt
echo $user_lscpu>>ZI_IT_Inventory_output.txt
echo $user_lshw>>ZI_IT_Inventory_output.txt
echo $user_how_many_gpu>>ZI_IT_Inventory_output.txt
echo $user_how_many_cpu>>ZI_IT_Inventory_output.txt
echo $user_how_much_ram>>ZI_IT_Inventory_output.txt
Which creates a txt file of this:
ziadmin
Intel(R) Core(TM) i7-6700 CPU
HD Graphics 530
1
1
8GiB
Which is the best way I could output this as a csv file where all the data is on the same row but different columns