Cut
From Wikipedia, the free encyclopedia
使用例
a という名前のファイルに以下のような行があるとする。
foo:bar:baz:qux:quux one:two:three:four:five:six:seven alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu
各行の4番目の文字から10番目の文字を抜き出すには、以下のように指定する。
% cut -c 4-10 a
このコマンドの出力結果は以下のようになる。
:bar:ba :two:th ha:beta
コロン文字をフィールドの区切り文字(区切り記号、デリミタ)として、各行の5番目のフィールド以降を全て出力するには、以下のように指定する。
% cut -d : -f 5- a
このコマンドの出力結果は以下のようになる。
quux five:six:seven epsilon:zeta:eta:teta:iota:kappa:lambda:mu