.csv
というディレクトリに複数のファイルがありますmydirectory
。まず、bash / awk / sedコマンドを使用して列に基づいてLeftChr
すべてのファイルをソートし、次に列に基づいRightChr
てresult
。
>Id LeftChr LeftPosition LeftStrand LeftLength RightChr RightPosition RightStrand
1979 chr1 825881 - 252 chr2 5726723 -
5480 chr2 826313 + 444 chr2 5727501 +
5492 chr5 869527 + 698 chr2 870339 +
1980 chr2 1584550 - 263 chr1 1651034 -
5491 chr14 1685863 + 148 chr1 1686679 +
5490 chr1 1691382 + 190 chr1 1693020 +
結果
>Id LeftChr LeftPosition LeftStrand LeftLength RightChr RightPosition RightStrand
5490 chr1 1691382 + 190 chr1 1693020 +
1979 chr1 825881 - 252 chr2 5726723 -
1980 chr2 1584550 - 263 chr1 1651034 -
5480 chr2 826313 + 444 chr2 5727501 +
5492 chr5 869527 + 698 chr2 870339 +
5491 chr14 1685863 + 148 chr1 1686679 +
ベストアンサー1
デフォルトでは「sort -k」だけで済みます。
for f in *.csv; do
# output of first line
head -1 $f
# output of any but first line, then sort after 2. then 6. column
tail -n +2 $f | sort -k 2,6
done