![Bash에서 전체 줄의 색상 반전](https://linux55.com/image/174253/Bash%EC%97%90%EC%84%9C%20%EC%A0%84%EC%B2%B4%20%EC%A4%84%EC%9D%98%20%EC%83%89%EC%83%81%20%EB%B0%98%EC%A0%84.png)
답변1
매우 간단합니다. 다음을 시도해 볼 수 있습니다.
# Reset
reset='\033[0m'
# White Background
BG='\033[47m'
# Black Foreground
FG='\033[0;30m'
# Usage
echo -e "$FG$BG This will print black text on white background $reset"
전체 행을 원하는 경우:
reset='\033[0m'
BG='\033[47m'
FG='\033[0;30m'
text="A black text on white"
cols=$(tput cols)
# Left Aligned
x=$((cols-${#text}))
printf "$FG$BG%s%*s$reset\n" "$text" $x
# Centered text
x_center=$(((${#text}+cols)/2))
x_rest=$((cols-x_center))
printf "$FG$BG%*s%*s$reset\n" $x_center "$text" $x_rest