cut

上級
1/10
user@linux:~/workspace$
cut -d ',' -f 1 data/users.csv

解説

-d ',' でカンマ区切り、-f 1 で1列目(id)を抽出します。ヘッダー行も含まれることに注意してください。

オプション

-d区切り文字を指定
-fフィールド(列)を指定
-f 11列目
-f 1,31列目と3列目
-f 1-31〜3列目
-f 1-1列目以降全て
-f -33列目まで
-c文字位置を指定
--output-delimiter出力区切り文字を変更
--complement指定以外を抽出
-bバイト位置を指定
1id,name,email,role,created_at
21,Alice Johnson,[email protected],admin,2025-01-15
32,Bob Smith,[email protected],user,2025-02-20
43,Carol Williams,[email protected],user,2025-03-10
54,David Brown,[email protected],moderator,2025-04-05
65,Eve Davis,[email protected],user,2025-05-12
76,Frank Miller,[email protected],user,2025-06-18
87,Grace Wilson,[email protected],admin,2025-07-22
98,Henry Taylor,[email protected],user,2025-08-30
109,Ivy Anderson,[email protected],user,2025-09-15
1110,Jack Thomas,[email protected],moderator,2025-10-01