我有一個要求在shell中讀取CSV文件,那麼我確定單元格中有單行的CSV文件。但是,如果我們在CSV文件的單元格中有多行,那麼我無法分隔CSV文件。在bash中讀取一個CSV文件
Filename Lines
/etc/hosts example.test.com
example2.test.com
/etc/resolv.conf nameserver dns.test.com
search test.com
我會從一個CSV文件中的用戶輸入,並具有給定的行添加到提檔。這裏有一個CSV文件的每個單元格中有多行,如果我嘗試捕捉它以不同的順序給出的文件。
[[email protected] ~]$ cat test2.csv
"Filename","Lines"
"/etc/hosts","example.test.com"
,"example2.test.com"
"/etc/resolv.conf","nameserver dns.test.com"
,"search test.com"
有什麼辦法可以從該文件中讀取多行,並且行數總是不一樣。
http://stackoverflow.com/questions/1560393/bash-shell-scripting-csv解析 –
給出數據文件;在'bash'中你想用它做什麼?如標準輸出所示重新格式化它?或者將數據存儲在'bash'數組中?或者是其他東西? –
http://stackoverflow.com/questions/12739515/ – Vahid