printf
???? Linux ????????????,??????????
- ????:
printf
??????????,????????????????:
printf "Hello, World!\n"
- ???????:
printf
???????????????????:
name="Alice" age=30 printf "My name is %s and I am %d years old.\n" "$name" "$age"
- ?????:
printf
?????????,????????????:
pi=3.14159 printf "The value of pi is approximately %.2f.\n" "$pi"
- ????:
printf
????????,???????????????:
printf "%-10s %-10s %-10s\n" "Name" "Age" "City" printf "%-10s %-10s %-10s\n" "Alice" "30" "New York" printf "%-10s %-10s %-10s\n" "Bob" "25" "San Francisco"
- ???????:
printf
???????????????????:
printf "\033[31mThis text is red.\n\033[0m"
- ?????:
printf
?????????,???????????????:
for i in {1..100}; do printf "\rProgress: =%%" "$i" sleep 0.1 done echo
- ???????:
printf
?????????????,?????????????:
printf "Current date and time: %s\n" "$(date)"
??,printf
??? Linux ????????????,???????????????????