タグ

shellとcutに関するreponのブックマーク (1)

  • cut コマンド | コマンドの使い方(Linux) | hydroculのメモ

    cut コマンド 2016/06/11 タブ区切りでフィールドを選択して出力する、または各行の中の一部を範囲指定して出力するコマンド。 cutコマンドの使用例と、同じことをするPerlワンライナーの例 ## タブ区切りで最初の列と3列目だけを抽出して、タブ区切りで出力する $ cut -f1,3 foo.txt $ cat foo.txt | cut -f1,3 $ cat foo.txt | perl -anle 'print "$F[0]\t$F[2]"' ## 以下のようにしても列の順番は入れ替えてくれない $ cut -f3,1 foo.txt ## Perlならできる $ cat foo.txt | perl -anle 'print "$F[2]\t$F[0]"' ## 各行の4文字目以降を出力する $ cut -b4- foo.txt $ cat foo.txt | cut

  • 1