bash
Convert a file from one format to another using `pandoc`. The script requires an input file and an output file as arguments. This demonstrates file format conversion.
pandoc
bash
Convert a file from one format to another using `pandoc`. The script requires an input file and an output file as arguments. This demonstrates file format conversion.
pandoc
bash
This code uses `awk` to print the second word from each line of input. The input consists of two lines: "hello world" and "awk cheatsheet". The output will be "world" and "cheatsheet". This demonstrates basic `awk` usage for extracting specific fields from text.
awk
bash
Render Helm chart templates using the `helm template` command with a specified values file (`values.yaml`). The `--debug` flag enables debugging output, and the `--output-dir` flag saves the rendered templates to a specified directory (`../temp`). This demonstrates debugging Helm charts with custom values.
helm
bash
This code takes a URL string with spaces, reads it from standard input, and uses Python's `urllib.parse.quote` to URL-encode the string. The result is printed to the console. This demonstrates how to encode a URL string in a Bash environment using Python.
python3
bash
This code uses the `tee` command to write the string "Log this" to both the standard output and a file named `logfile.txt`. This demonstrates how to simultaneously display output and save it to a file using `tee`.
tee
bash
This code finds all `.txt` files in the current directory and its subdirectories using the `find` command, then deletes them using the `-exec` option with `rm`. This demonstrates how to use `find` and `-exec` to perform actions on matched files.
find rm
bash
This code demonstrates parallel execution by using `xargs` to run the `sleep` command in parallel for numbers 1 through 10. The `-P 4` flag allows up to 4 processes to run simultaneously. This is an example of parallel task execution in Bash.
echo xargs sleep
bash
Extract and print the second word (`world`) from the string `hello world` using `awk`. This demonstrates basic string manipulation and field extraction with `awk`.
awk
bash
This snippet uses `envsubst` to substitute environment variables in the `/nginx.conf.template` file and outputs the result to `/etc/nginx/nginx.conf`. This demonstrates how to dynamically generate configuration files using environment variables.
envsubst
bash
This code reads the `~/.bashrc` file, removes lines that are comments (starting with `#`) or empty lines, and prints the remaining content. It demonstrates using stream pipes (`|`) and `grep` for filtering and processing text.
cat grep
bash
Send a `HUP` signal to the `prometheus` process to restart it. This uses `pidof` to get the process ID of `prometheus` and sends the signal to it. This demonstrates how to restart a process using the `HUP` signal.
kill pidof
bash
List files and directories in the current directory with detailed information (`-l`), human-readable file sizes (`-h`), and sorted by modification time (`--sort=time`). This demonstrates how to display and sort directory contents in a user-friendly format.
ls
bash
Compare the contents of `dir1` and `dir2` using `diff` with process substitution. This demonstrates how to use process substitution to compare the output of two commands directly without intermediate files.
diff ls
bash
The input file `foo.txt` is redirected to standard input for the Python script `hello.py`. This demonstrates file redirection in a shell command.
python
bash
Extract the contents of `myArchive.zip` using the `unzip` command. This demonstrates how to decompress a ZIP archive in a Bash environment.
unzip
bash
Create a password-protected ZIP archive named `myArchive.zip` containing the contents of `FolderName`. This demonstrates how to encrypt and compress a folder using the `zip` command.
zip
bash
Download multiple files from a website using `curl` with a range pattern. The files are named sequentially from `file_0001.txt` to `file_0010.txt`, and the `#1` placeholder is replaced with the corresponding number from the range. This demonstrates downloading multiple files with a single command.
curl
bash
This snippet uses `curl` to measure and display the connection time, time to first byte, and total time for a request to `http://example.com/1/endpoint`. The `-w` flag specifies the output format, `-s` silences the progress meter, and `-o /dev/null` discards the response body. This demonstrates how to profile HTTP request timings using `curl`.
curl
bash
This snippet reads the contents of `myJSONFile.json` and pipes it to the `python -m json.tool` command, which formats the JSON data for better readability. This demonstrates how to pretty-print JSON files using Python's built-in JSON tool.
cat python
bash
Calculate the logarithm of 100 with base 10 using `bc` by evaluating the expression `l(100)/l(10)`. This demonstrates mathematical computation in Bash using the `bc` command.
bc