以下の例についてcutコマンドと自作したコマンドの出力が一致することを確認した
gcc -o out cut.c
./out -f 2-3 -d "," comma.txt
- 入力
1,2,3,4,5
a,b,c,d,e
- 出力
2,3
b,c
./out -f 1,3,5 -d " " space.txt
- 入力
1 2 3 4 5
6 7 8 9 0
- 出力
1 3 5
6 8 0
./out -f 2-3 -d "," -s comma2.txt
- 入力
1,2,3,4,5
6,7,8,9,0
HELLO!
- 出力
2,3
7,8
./out -c 4- text.txt
- 入力
HELLO WORLD!
1A2B3C4D5E
- 出力
LO WORLD!
B3C4D5E
./out -c 1,3,5 num.txt
- 入力
12345
67890
- 出力
135
680
./out -f 1,3-4,9- -d "," comma3.txt
- 入力
1,2,3,4,5,6,7,8,9,0
a,b,c,d,e,f,g,h,i,j
- 出力
1,3,4,9,0
a,c,d,i,j
./out -c 2,3,, num.txt
cut: fields are numbered from 1
Try 'cut --help' for more information.
./out -c 3 aaaaaa.txt
cut: aaaaaa.txt:No such file or directory