私はbashスクリプトに取り組んでいます。
var=$(ls -t1 | head -n1);
cat $var | sed 's/"//g' > latest.csv
cat latest.csv | sed -e 's/^\|$/"/g' -e 's/,/","/g' > from_epos.csv
echo "LATEST: $var";
これがスクリプト全体です。これは、現在のファイルからすべての引用符を削除し、各フィールド間に新しい引用符を追加するためのものです。
入力:
"sku","item","price","qty"
5135,"ITEM1",1.79,5
5338,"ITEM2",1.39,5
5318,"ITEM3",1.09,5
5235,"ITEM4",1.09,5
9706,"ITEM5",1.99,5
出力:
"sku","item","price","qty"
"5135","ITEM1","1.79","5
"
"5338","ITEM2","1.39","5
"
"5318","ITEM3","1.09","5
"
"5235","ITEM4","1.09","5
"
"9706","ITEM5","1.09","5
"
私の理想的な出力は次のとおりです。
"sku","item","price","qty"
"5135","ITEM1","1.79","5"
"5338","ITEM2","1.39","5"
"5318","ITEM3","1.09","5"
"5235","ITEM4","1.09","5"
"9706","ITEM5","1.99","5"
現在の出力では " のように行間にランダムな文字を入力しているようで、引用符は CR と LF の間にあります。
何が問題で、どうすれば理想のビジョンに到達できますか?
ありがとう、
アダム