From 18d704e2d5f41a979715d7730e2c101046513eff Mon Sep 17 00:00:00 2001 From: root Date: Wed, 2 Jul 2025 01:09:17 +0330 Subject: [PATCH] update lpic: head,tail,wc doc --- Linux/LPIC1/14-head-tail.md | 77 +++++++++++++++++++++++++++++++++++++ Linux/LPIC1/15-wc.md | 52 +++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/Linux/LPIC1/14-head-tail.md b/Linux/LPIC1/14-head-tail.md index e69de29..764a709 100644 --- a/Linux/LPIC1/14-head-tail.md +++ b/Linux/LPIC1/14-head-tail.md @@ -0,0 +1,77 @@ +# πŸ“˜ **Using `head` and `tail` Commands in Linux/Unix** + +Both `head` and `tail` are essential commands for viewing specific portions of a file quickly, without opening the entire file. + +--- + +## πŸ” `head` β€” Show the Top of a File + +The `head` command displays the beginning part of a file. + +### Syntax + +```bash +head [options] file +``` + +### Examples + +```bash +head file1 +``` + +**Description**: +Displays the first 10 lines of `file1` (default behavior). + +```bash +head -n 5 file1 +``` + +**Description**: +Shows the first 5 lines of `file1`. + +--- + +## πŸ”š `tail` β€” Show the Bottom of a File + +The `tail` command displays the end part of a file. + +### Syntax + +```bash +tail [options] file +``` + +### Examples + +```bash +tail file1 +``` + +**Description**: +Displays the last 10 lines of `file1` (default behavior). + +```bash +tail -n 20 file1 +``` + +**Description**: +Shows the last 20 lines of `file1`. + +```bash +tail -f file1 +``` + +**Description**: +Follows the file as it grows β€” useful for watching logs in real-time. + +--- + +## βœ… Summary of Options + +| Command | Option | Description | +| ------- | ------------- | ------------------------------------------- | +| `head` | `-n ` | Show the first `` lines | +| `tail` | `-n ` | Show the last `` lines | +| `tail` | `-f` | Follow the file in real-time (live updates) | + diff --git a/Linux/LPIC1/15-wc.md b/Linux/LPIC1/15-wc.md index e69de29..283841d 100644 --- a/Linux/LPIC1/15-wc.md +++ b/Linux/LPIC1/15-wc.md @@ -0,0 +1,52 @@ +# πŸ“˜ **Using the `wc` Command in Linux/Unix** + +`wc` (word count) is a utility that counts lines, words, and bytes or characters in files. It’s useful for quickly getting file size details in text terms. + +--- + +## βš™οΈ Syntax + +```bash +wc [option] file +``` + +--- + +## πŸ”Ž Basic Usage + +```bash +wc file +``` + +**Example output:** + +``` + 5 6 43 file1 +``` + +This output means: + +| Number | Meaning | +| ------ | ------------------- | +| `5` | Number of **lines** | +| `6` | Number of **words** | +| `43` | Number of **bytes** | + +--- + +## πŸ“‹ Common Options + +| Option | Description | Example | +| ------ | ------------------------- | ------------ | +| `-l` | Count **lines** only | `wc -l file` | +| `-w` | Count **words** only | `wc -w file` | +| `-c` | Count **bytes** only | `wc -c file` | +| `-m` | Count **characters** only | `wc -m file` | + +--- + +## πŸ“Œ Notes + +* `bytes (-c)` counts raw bytes, which might differ from characters (`-m`) in multibyte encodings like UTF-8. +* Without options, `wc` outputs lines, words, and bytes by default. +