---
title: LPIC101_cut_B16
tags: 
author: [Yukiko](https://image.docswell.com/user/yukiko_it)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/D7Y4ZN6PEM.jpg?width=480
description: LPIC101_cut_B16 by Yukiko
published: April 22, 26
canonical: https://image.docswell.com/s/yukiko_it/KR8Q82-2026-04-22-004742
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/D7Y4ZN6PEM.jpg)

LPIC-101 v5.0
｜ 小豆 本対 応
cut コマンド
テキストから「特定の列だけ」切り出す定番ツール
新卒・文系・未経験のための IT 研修
-d（区切り）+ -f（フィールド番号）の2点セット
うさうさラーメン店方式


# Page. 2

![Page Image](https://bcdn.docswell.com/page/VENY3XZMJ8.jpg)

PROBLEM
今日のお題 ― B問題セット 問16
/etc/passwd からユーザー名(1列目)とホームディレクトリ(6列目)のリストを出力するものはどれですか。
1
cut -d : -f 1,6 /etc/passwd
2
sort -t : -k 1,6 /etc/passwd
3
fmt -f 1,6 /etc/passwd
4
paste -f 1,6 /etc/passwd
5
split -c 1,6 /etc/passwd
※ 単一選択（正解は1つ）
LPIC-101 ｜ cut ― 列を切り出す
2 / 10


# Page. 3

![Page Image](https://bcdn.docswell.com/page/Y79P98ZWE3.jpg)

① この用語
cutコマンドの仕事
用語
cut
行から必要な列だけ切り出す
うさうさラーメン店で例えると
注文票の形式:
名前:席:麺:具:スープ:支払
「名前と支払方法だけ抜いて」
各行を区切り文字(-d)で
分割し、指定した列(-f)だけ
取り出して出力する。
対象はCSV、TSV、
/etc/passwd のような
「1行1レコード形式」のテキスト。
↓
cut -d : -f 1,6
-d : = 区切りはコロン
-f 1,6 = 1列目と6列目
=「名前と支払だけ抽出」
LPIC-101 ｜ cut ― 列を切り出す
3 / 10


# Page. 4

![Page Image](https://bcdn.docswell.com/page/G78D981R7D.jpg)

② 簡単に
cut の2点セット: -d と -f
cut -d 区切り文字 -f 列番号 ファイル
-d (delimiter)
-f (field)
区切り文字を指定
フィールド番号を指定
-d :
-f 1
→ コロン区切り(passwd)
→ 1列目だけ
-d ,
-f 1,6
→ カンマ区切り(CSV)
→ 1列目と6列目
省略時はタブ
-f 1-3
→ 1〜3列目（範囲）
★ 覚え方: -d で切って、-f で選ぶ（d=区切り、f=フィールド）
LPIC-101 ｜ cut ― 列を切り出す
4 / 10


# Page. 5

![Page Image](https://bcdn.docswell.com/page/L7LMWRQ2JR.jpg)

③ 詳しく①
/etc/passwd の7列構造
Linux のユーザー情報は /etc/passwd にコロン区切りで1ユーザー1行で格納される
yuki:x:1001:1001:Yukiko I.:/home/yuki:/bin/bash
1
ユーザー名
2
yuki
5
GECOS(氏名)
Yukiko I.
パスワード
3
x (shadow)
6
ホームdir
/home/yuki
UID
1001
7
4
GID
1001
ログインshell
/bin/bash
★ 今回: 1列目（ユーザー名）と 6列目（ホームdir）
LPIC-101 ｜ cut ― 列を切り出す
5 / 10


# Page. 6

![Page Image](https://bcdn.docswell.com/page/4EMY9R19EW.jpg)

③ 詳しく②
紛らわしい他コマンド ― それぞれ別仕事
コマンド
何をする
典型的な使い方
-f の意味
cut
列を切り出す
cut -d : -f 1,6 file
field（列番号）
sort
行を並び替える
sort -t : -k 1 file
-f なし / -k が近い
paste
複数ファイルを横に結合
paste a.txt b.txt
-f は存在しない
split
ファイルを分割
split -l 100 big.txt
-f は存在しない
fmt
段落を整形
fmt -w 70 memo.txt
-f なし / -w が近い
罠: sort/paste/split/fmt はどれも「列抽出」ではない。sort の -t/-k は「並び替えのキー」
LPIC-101 ｜ cut ― 列を切り出す
6 / 10


# Page. 7

![Page Image](https://bcdn.docswell.com/page/PER9GRL9J9.jpg)

③ 詳しく③
実機ハンズオン（Ubuntu / RHEL 共通）
cut は GNU coreutils。Ubuntu/RHEL/CentOS どれでも同じ挙動。気軽に試せる。
Terminal ― cut を試す
# /etc/passwd の先頭3行
$ head -3 /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
# ★ 正解: 1列目と6列目だけ抽出
$ cut -d : -f 1,6 /etc/passwd
root:/root
daemon:/usr/sbin
yuki:/home/yuki
# 範囲指定も可能
$ cut -d : -f 1-3 /etc/passwd | head -1
root:x:0
LPIC-101 ｜ cut ― 列を切り出す
7 / 10


# Page. 8

![Page Image](https://bcdn.docswell.com/page/P7XQXRW3EX.jpg)

APPLY
原理原則で5択を斬る
#
コマンド
判定
理由
1
cut -d : -f 1,6 ...
○ 正解
列切り出しの王道。-d で区切り、-f で列番号を指定
2
sort -t : -k 1,6 ...
× 誤り
sort は並び替え。1,6 は「1列目から6列目をキーに並べる」意味
3
fmt -f 1,6 ...
× 誤り
fmt は段落整形。そもそも -f オプションを持たない
4
paste -f 1,6 ...
× 誤り
paste は複数ファイル横結合。-f は非対応
5
split -c 1,6 ...
× 誤り
split はファイル分割。-c はバイト数指定で列とは無関係
→ 正解は 1番。「-d 区切り + -f 列番号」がcutの文法。
LPIC-101 ｜ cut ― 列を切り出す
8 / 10


# Page. 9

![Page Image](https://bcdn.docswell.com/page/37K9WRVN7D.jpg)

ANSWER
正解 ― cut の -d + -f
正解 ①
cut -d : -f 1,6 /etc/passwd
「: で切って、1番目と6番目を取り出す」
実行イメージ（入力 → 出力）
入力 (/etc/passwd)
出力 (1列目と6列目)
root:x:0:0:root:/root:/bin/bash
yuki:x:1001:1001:Yukiko:/home/yuki:/bin/bash
root:/root
yuki:/home/yuki
LPIC-101 ｜ cut ― 列を切り出す
→
9 / 10


# Page. 10

![Page Image](https://bcdn.docswell.com/page/LJ3W18MZJ5.jpg)

④ 原理原則・一言でまとめ
cut は
「-d で切って、-f で選ぶ」2点セット。
-d
-f
1,6
delimiter 区切り
field 列番号
複数列はカンマ
/etc/passwd は : 区切りの7列。1=ユーザ名、6=ホームdir
面白きなき世を面白く ─ 石黒 友季子


