sh
Tạo vào: 3 tháng 3, 2026
Trả lời bằng GPT-5.2 Thinking bởi Chat01
Tạo vào: 3 tháng 3, 2026
Trả lời bằng GPT-5.2 Thinking bởi Chat01
sh
Did you mean sh as in the Unix shell (POSIX “Bourne shell” interface)?
If so, here’s the practical cheat sheet.
sh issh runs a POSIX-compatible shell (the “standard” shell language)./bin/sh is not Bash:
/bin/sh → dash (faster, more strictly POSIX).shshsh script.sh
sh#!/bin/sh echo "Hello"
shchmod +x script.sh ./script.sh
shset -eu # -e: exit on error # -u: error on unset variables
(“pipefail” isn’t POSIX, so it may not work in sh.)
If you use sh, avoid Bash-only features like:
[[ ... ]] (use [ ... ])arr=(a b)source file (use . file){1..5}Example POSIX test:
shif [ -f "$1" ]; then echo "file exists" fi
If you tell me what you meant by “sh” (run a .sh file? write a shell script? something else?), I’ll tailor it.