นี่คือผลลัพธ์:
3,aac-lc, 93.8, aaclc, 77.3, h.264, 1024.6, h.264, 1029.1, 31, 31, 0,0,0.000000,31,31,0,0,0.000000,7,0,0,0.000000,30,1280 720,10,0,0,0.000000,30,1280 720
ฉันลองกับสถานการณ์ 2:
การจัดเก็บในอาร์เรย์
@arr=split(',',$stats); echo "statistics: $stats"การจัดเก็บในตัวแปร
echo $stats | cut -d ',' -f | read s1 echo $s1
แต่สถานการณ์ไม่ทำงาน
awk '{ split("3,aac-lc, 93.8, aaclc, 77.3, h.264, 1024.6, h.264, 1029.1, 31, 31, 0,0,0.000000,31,31,0,0,0.000000,7,0,0,0.000000,30,1280 720,10,0,0,0.000000,30,1280 720 ",arr,","); print arr[1]; }'หรือecho "3,aac-lc, 93.8, aaclc, 77.3, h.264, 1024.6, h.264, 1029.1, 31, 31, 0,0,0.000000,31,31,0,0,0.000000,7,0,0,0.000000,30,1280 720,10,0,0,0.000000,30,1280 720" | awk '{ split($0,arr,","); print arr[1]; }'สิ่งนี้ควรใช้งานได้