随笔分类 - CLI
摘要:Compse commands with pipe # List all folders and files in current dir % ls -l total 56 -rw-r--r-- 1 zwt staff 51 May 16 22:35 data.txt -rwxr-xr-x 1 zw
阅读全文
摘要:Write to a file >, >> Append content at the beginning of the file. echo whatever > hello.txt echo Hello world >> hello.txt cat hello.txt # whatever #
阅读全文
摘要:While The while loop executes a block of code as long as a specified condition is true. while [ condition ]; do commands done Example: #!/bin/zsh coun
阅读全文
摘要:If The if statement is used to execute commands based on a condition. if [ condition ]; then commands fi Example: vim example.sh #!/bin/zsh echo "Ente
阅读全文
摘要:Commands: export: Set environment variables. env: View environment variables. echo: Display environment variables. Common Environment Variables: PATH:
阅读全文
摘要:Understanding File Permissions: File permissions in Unix-like systems determine who can read, write, or execute a file. They are represented as a comb
阅读全文
摘要:The sed command is a stream editor used for filtering and transforming text. sed 'command' file Create and view the initial content of sample.txt: ech
阅读全文
摘要:The awk command is a powerful text processing tool used for pattern scanning and processing. // exammple.txt Hello World This is a sample file Bash sc
阅读全文
摘要:The grep command searches for patterns within files and prints matching lines. grep [options] [content] [file] Search for a pattern in a file: grep "p
阅读全文
摘要:Head The head command is used to display the beginning of a file or the first few lines of input. It's a useful command for quickly viewing the start
阅读全文
摘要:The read command is used to take input from the user. Reading a single input value: echo "Enter your name:" read NAME echo "Hello, $NAME!" Output afte
阅读全文
摘要:The echo command is used to display a line of text or string that is passed as an argument. It's one of the most basic and frequently used commands in
阅读全文
摘要:The wc command computes the numbers of lines, words, and bytes in a file: wc notes.txt # > 3 7 35 /home/substack/notes.txt Count words wc -w notes.txt
阅读全文
摘要:For example I want to override and rename file.txt_ with file.txt mv file.txt{_,} You can also check the full command with echo echo mv file.txt{_,} #
阅读全文
摘要:mkdir To make a new directory, just execute the mkdir command with a list of new directory names to make as arguments: mkdir hooray and now a new dire
阅读全文
摘要:mv The mv command is used to rename and overwrite files and directories. To rename a file, set the first argument to the original file name and the se
阅读全文
摘要:cp Copy file content from beep.txt to message.txt, create message.txt if not exists. cp beep.txt message.txt Copy file to a different directory cp bee
阅读全文
摘要:https://github.com/sharkdp/hyperfine hyperfine --runs 5 "CMD_1" "CMD_2" So it will run 5 times and compare CMD_1 vs CMD_2with a nice result summary
阅读全文
摘要:#!/bin/bash # url will be a param been passed in url=$1 curl -X POST http://localhost:3000/endpoint -d "{\"payload\":\"$url\"}" -H "content-type: appl
阅读全文
摘要:Command Line 1. Navigate to your home directory cd ~ 2. Make a directory call "temp" mkdir temp 3. Move into temp cd temp 4. List the idrectory conten
阅读全文