OS 환경 : Oracle Linux 8.7 (64bit)
방법 : 리눅스 쉘로 크리스마스 트리 만들기
본문에서는 리눅스 쉘스크립트를 이용해 컬러풀한 크리스마스 트리를 만드는 방법을 설명함
xmas_tree.sh 쉘파일 생성
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
$ cat xmas_tree.sh
#!/usr/bin/env bash
HEIGHT=26
SLEEP_SEC=0.5
# ANSI colors (256-color)
C_RESET=$'\033[0m'
C_STAR=$'\033[38;5;220m' # gold
C_GARL=$'\033[38;5;228m' # light gold
C_TRUNK=$'\033[38;5;94m' # brown
C_SHADOW=$'\033[38;5;22m' # dark green
C_GREEN1=$'\033[38;5;28m' # green
C_GREEN2=$'\033[38;5;34m' # bright green
C_LIGHT=$'\033[38;5;154m' # highlight green
# ornaments
ORN_COLORS=(
$'\033[38;5;196m' # red
$'\033[38;5;33m' # blue
$'\033[38;5;201m' # magenta
$'\033[38;5;208m' # orange
$'\033[38;5;46m' # green neon
$'\033[38;5;226m' # yellow
)
# hide cursor
printf '\033[?25l'
frame=0
while true; do
frame=$((frame+1))
# clear screen + cursor home
printf '\033[2J\033[H'
# top star
pad=$((HEIGHT+1))
printf "%*s%s%s%s\n" "$pad" "" "${C_STAR}" "✶" "${C_RESET}"
for ((lvl=1; lvl<=HEIGHT; lvl++)); do
# visible width
width=$((lvl*2+1))
left=$((HEIGHT - lvl + 2))
line=""
# gold garland positions (diagonal waves)
g1=$(( (lvl*3 + frame) % (width-2) + 2 ))
g2=$(( (lvl*5 + frame*2) % (width-2) + 2 ))
for ((pos=1; pos<=width; pos++)); do
# choose foliage density for "real tree" texture
# edges: sparse, inside: dense, add highlight speckles
if (( pos<=2 || pos>=width-1 )); then
base="${C_SHADOW}·${C_RESET}"
else
r=$(( (pos*17 + lvl*13 + frame) % 23 ))
if (( r < 2 )); then
base="${C_LIGHT}*${C_RESET}" # highlight sparkle
elif (( r < 10 )); then
base="${C_GREEN2}▒${C_RESET}" # mid dense
else
base="${C_GREEN1}▓${C_RESET}" # dense
fi
fi
# ornaments (twinkle)
otest=$(( (pos*29 + lvl*31 + frame*7) % 41 ))
if (( otest == 0 || otest == 1 )); then
cidx=$(( (pos + lvl + frame) % ${#ORN_COLORS[@]} ))
# two-state twinkle: solid circle / small dot
if (( (frame + pos) % 3 == 0 )); then
base="${ORN_COLORS[$cidx]}●${C_RESET}"
else
base="${ORN_COLORS[$cidx]}•${C_RESET}"
fi
fi
# garland (gold)
if (( pos == g1 || pos == g2 )); then
base="${C_GARL}~${C_RESET}"
fi
line+="$base"
done
printf "%*s%s\n" "$left" "" "$line"
done
# trunk (ASCII, centered)
TRUNK_W=5
center=$((HEIGHT + 2))
trunk_left=$((center - (TRUNK_W/2)))
printf "%*s%s%s%s\n" "$trunk_left" "" "${C_TRUNK}" "|||||" "${C_RESET}"
printf "%*s%s%s%s\n" "$trunk_left" "" "${C_TRUNK}" "|||||" "${C_RESET}"
printf "%*s%s%s%s\n" "$trunk_left" "" "${C_TRUNK}" "|||||" "${C_RESET}"
printf "%*s%s%s%s\n" "$trunk_left" "" "${C_TRUNK}" "=====" "${C_RESET}"
sleep "$SLEEP_SEC"
done
|
실행 권한 부여
|
1
|
$ chmod +x xmas_tree.sh
|
수행
|
1
|
$ ./xmas_tree.sh
|
결과
아래 결과가 반복됨
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
✶
·~·
··▒~·
·~▓▓▒~·
··▒▒▓~▒··
··▓~▒▒▓▓▒~·
··▓▒▓~~▒▓●▒··
··*~▓▒*▓▓▒▓~▓··
··▓▒•▓~▒*▓▓▒*▓▓~·
·~▒▓▓▒▒▓▓▒•▓▓▒~▓▓··
··▓▓▒▓▓▓▒▓▓▒▒~▓~•▓▓··
··▒*▓▓▒*▓▓▒▓~▓▒▓▓▒▒▓▓·•
··▓▓•▒▓▓▒~▓~▒*▓▓▒▓▓▓▒▓▓··
··▓▒▓▓~▒▓▓~▒▓▓▒*▓▓▒*▓▓▒▓▓··
··*~▓▒▓▓▓~▓▓▒▒▓▓•▒▓▓▒*▓▓▒*▓··
··▓▒*•▓▒~▓▓▒▓▓▓▒▓▓▒▒▓▓•▒▓▓▒*▓~·
··▒▓▓▒▒~▓▒*•▓▒*▓▓▒▓▓▓▒▓▓▒▒▓▓~▒▓··
··▓▓▒▓~▒▒▓▓▒▒▓▓▒*•▓▒*▓▓▒▓▓▓~▓▓▒▒▓·•
··▒*▓~▒▓▓▓▒▓▓▒▒▓▓▒▒▓▓▒*•▓▒~▓▓▒▓▓▓▒▓··
··▓▓~•▓▓▒*▓▓▒▓▓▓▒▓▓▒▒▓▓▒▒~▓▒*•▓▒*▓▓▒▓··
··▒~▓▓▒▒▓▓▒•▓▓▒*▓▓▒▓▓▓▒▓~▒▒▓▓▒▒▓▓▒*•▓▒*··
●·~▓▓▒▓▓▒▒▓▓▒▒▓▓▒•▓▓▒*▓~▒▓▓▓▒▓▓▒▒▓▓▒▒▓▓▒*•·
·~▓▒*▓●▒▓▓▓▒▓▓▒▒▓▓▒▒▓▓~•▓▓▒*▓▓▒▓▓▓▒▓▓▒▒▓▓▒▒··
··▒▓▓▒*▓▓▒*▓●▒▓▓▓▒▓▓▒~▓▓▒▒▓▓▒•▓▓▒*▓▓▒▓▓▓▒▓▓▒▒~·
··▓▒▒▓▓▒▒▓▓▒*▓▓▒*▓●▒~▓▓▒▓▓▒▒▓▓▒▒▓▓▒•▓▓▒*▓▓▒▓▓▓~··
●·▒▓▓▓▒▓▓▒▒▓▓▒▒▓▓▒*~▓▒*▓●▒▓▓▓▒▓▓▒▒▓▓▒▒▓▓▒•▓▓▒*▓~▒··
··▓▓▒*●▓▒▓▓▓▒▓▓▒▒▓~▒▒▓▓▒*▓▓▒*▓●▒▓▓▓▒▓▓▒▒▓▓▒▒▓▓▒•~▓▒··
|||||
|||||
|||||
=====
|
영상

크리스마스 트리가 완성됨
수행후 커서위치가 안보이면 아래 명령 수행
|
1
|
$ printf '\033[?25h'
|
결론 :
메리크리스마스
참조 :
https://connor-mcdonald.com/2025/12/12/an-ai-generated-sql-for-christmas/
'Linux, Unix > Tip' 카테고리의 다른 글
| Oracle Linux 9 oracle asmlib v3 구성 가이드 (0) | 2026.01.09 |
|---|---|
| IBM AIX 7.2 gui xclock 사용 (0) | 2025.11.09 |
| 오라클 리눅스 8 tmux(Terminal Multiplexer) 사용 가이드 (0) | 2025.10.24 |
| Oracle Linux 8 디스크 파티션 나누기 (0) | 2025.10.18 |
| 리눅스 8 tar 사용시 진행률 확인(pv 패키지 사용) (0) | 2025.07.22 |