次の入力テキストファイルがあります。
table columns are:
number of vertices
total surface area (mm^2)
total gray matter volume (mm^3)
average cortical thickness +- standard deviation (mm)
integrated rectified mean curvature
integrated rectified gaussian curvature
folding index
intrinsic curvature index
structure name
72 6.18 1307 87.23 987 0.566 2 3 1.8 SUBJECT_89765432/label/lh.APD57_20d.label
table columns are:
....(repeat)
次のようにコンマ区切りの変数を出力するファイルを作成したいと思います。
Id,surface area (mm^2),gray matter volume (mm^3),avg cortical thickness +- sd (mm),mean curvature,gaussian curvature,folding index,curvature index,hemi,ROI
SUBJECT_89765432,72,6.18,1307,87.23,987,2,3,1.18, lh, 20d
SUBJECT_...(repeat)
どうすればいいですか?とても感謝しています!
ベストアンサー1
sed '/SUBJECT_/!d;s/ /,/g;s/\(.*\),\(SUBJECT_[0-9]*\).*/\2,\1/'
/SUBJECT_/!d
キーワードのない行をすべて削除します。 (スクリプトを介してヘッダを作成する必要はありません。)s/ /,/g
スペースの代わりにカンマを使用してくださいs/\(.*\),\(SUBJECT_[0-9]*\).*/\2,\1/
並べ替える