docs: add articles

This commit is contained in:
Ubuntu
2026-09-22 16:11:58 +02:00
parent a865ce0d0c
commit 2e70932cf0
10 changed files with 516 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
# catコマンド
`cat`(concatenate)は、ファイルや標準入力から読み込んだデータを標準出力に書き出すコマンド
## 使用例
### 最も基本的な使い方
```
cat test.txt
```
### 複数ファイルの内容を標準出力に書き出す
```
cat file1.txt file2.txt
```
### 標準入力からデータを読み込む
標準入力をキーボードから読み込む:
```
tsubanyan@localhost:~$ cat
hello
hello
world
world
tsubanyan@localhost:~$
```
- ファイルを指定せずに実行すると、標準入力からデータを読み込む
- 端末は通常カノニカルモードなので、改行文字が入力され初めて`cat`に渡る
標準入力をファイルから読み込む:
```
cat < test.txt
```
- `<` ... 指定したファイルをコマンドの標準入力に接続するリダイレクト演算子
- `cat`は標準入力から`test.txt`の内容を読み込み、標準出力に書き出す
@@ -0,0 +1,51 @@
# echoコマンド
`echo`は、指定した文字列や変数の値を標準出力に書き出すコマンド
## 使用例
### 最も基本的な使い方
文字列を標準出力に書き出す:
```
echo "Hello, world!"
```
変数の値を標準出力に書き出す:
```
echo $HOME
```
例:
```
tsubanyan@localhost:~$ echo "Hello, world!"
Hello, world!
tsubanyan@localhost:~$ echo $HOME
/home/tsubanyan
tsubanyan@localhost:~$
```
### 標準出力をファイルに書き込む
ファイルを新規作成・上書き:
```
echo "Hello" > test.txt
```
- `>`は標準出力を指定したファイルにリダイレクトする演算子
- ファイルが存在しない場合は新規作成し、存在する場合は上書き
ファイルに追記:
```
echo "World" >> test.txt
```
- `>>`は標準出力を指定したファイルの末尾に追記する演算子
例:
```
tsubanyan@localhost:~$ echo "Hello" > test.txt
tsubanyan@localhost:~$ echo "World" >> test.txt
tsubanyan@localhost:~$ cat test.txt
Hello
World
tsubanyan@localhost:~$
```