2021-02-17から1日間の記事一覧

UNIXシステムコール ファイルを開いてファイル記述子を表示する

#include <sys/types.h> /* open */ #include <stdio.h> /* perror, printf */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ int main(void) { int fd; if ((fd = open("abc.txt", O_RDONLY)) == -1) { perror("open"); exit(1); } printf("fd = %d\n", fd); r</fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>…

odコマンドで16進数で1バイトずつ表示する方法

$ cat abc.txt aabbccdd eeffgghh $ od -Ax -tx1 abc.txt 000000 61 61 62 62 63 63 64 64 0a 65 65 66 66 67 67 68 000010 68 0a 000012「-tx1」が16進数で1バイトずつ表示するオプション 「-Ax」が各行左に表示されるアドレス表示を16進数にするオプション