宇宙主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

欧基零壹微头条IP归属甄别会员请立即修改密码
查看: 693|回复: 7

MJJ们,圣诞快乐!

[复制链接]
发表于 2023-12-19 17:17:56 | 显示全部楼层 |阅读模式
本帖最后由 jacklondon 于 2023-12-19 18:52 编辑
  1. #!/bin/bash

  2. draw_christmas_tree() {
  3.     echo "        *        "
  4.     echo "       / \\       "
  5.     echo "      /   \\      "
  6.     echo "     /_____\\     "
  7.     echo "    /   |   \\    "
  8.     echo "   /    |    \\   "
  9.     echo "  /_____|______\\  "
  10.     echo "       | |       "
  11.     echo "       | |       "
  12. }

  13. # 调用函数
  14. draw_christmas_tree
复制代码



将上述代码保存到一个文件(比如christmas_tree.sh),然后在终端中运行:

  1. chmod +x christmas_tree.sh
  2. ./christmas_tree.sh
复制代码


这将在终端上输出一个圣诞树图像,希望大家喜欢。
发表于 2023-12-19 17:19:57 | 显示全部楼层




小尾巴~~~~~

看签名>>>
发表于 2023-12-19 17:22:14 | 显示全部楼层
雕虫小技竟敢班门弄斧~大威天龙!~咚呲咚咚,咚咚呲咚咚
发表于 2023-12-19 17:23:12 | 显示全部楼层

  1. #!/bin/bash

  2. draw_christmas_tree() {
  3.     echo "        *        "
  4.     echo "       / \\       "
  5.     echo "      /   \\      "
  6.     echo "     /_____\\     "
  7.     echo "    /   |   \\    "
  8.     echo "   /    |    \\   "
  9.     echo "  /_____|______\\  "
  10.     echo "       | |       "
  11.     echo "       | |       "
  12. }

  13. # 调用函数
  14. draw_christmas_tree
复制代码

------
发表于 2023-12-19 17:29:55 | 显示全部楼层
要不搞一个炫酷一点的
发表于 2023-12-19 17:34:52 | 显示全部楼层
  1. # The following line tells the shell what program to interpret the script with
  2. #!/bin/bash
  3. # tput is a command to manipulate the terminal, it can be used to change the color of text, apply effects, and generally brighten things up.
  4. trap "tput reset; tput cnorm; exit" 2
  5. clear
  6. tput civis
  7. lin=2
  8. col=$(($(tput cols) / 2))
  9. c=$((col-1))
  10. est=$((c-2))
  11. color=0
  12. # Set the text color to green to write the tree
  13. tput setaf 2; tput bold
  14. # Write the tree
  15. for ((i=1; i<40; i+=2))
  16. {
  17.     tput cup $lin $col
  18.     for ((j=1; j<=i; j++))
  19.     {
  20.         echo -n \*
  21.     }
  22.     let lin++
  23.     let col--
  24. }
  25. ## Set the color to brown for the trunk
  26. tput sgr0; tput setaf 130
  27. # Write the Trunk in three lines
  28. for ((i=1; i<=3; i++))
  29. {
  30.     tput cup $((lin++)) $c
  31.     echo 'mWm'
  32. }
  33. # Write a greeting
  34. tput setaf 93; tput bold
  35. tput cup $lin $((c - 15)); echo SCALEWAY wishes you Merry Christmas
  36. tput cup $((lin + 1)) $((c - 11)); echo And a Happy New Year 2024
  37. let c++
  38. k=1
  39. # Configure lights and decorations
  40. while true; do
  41.     for ((i=1; i<=35; i++)) {
  42.         # Turn off the lights
  43.         [ $k -gt 1 ] && {
  44.             tput setaf 2; tput bold
  45.             tput cup ${line[$[k-1]$i]} ${column[$[k-1]$i]}; echo \*
  46.             unset line[$[k-1]$i]; unset column[$[k-1]$i]  # Array cleanup
  47.         }
  48.         li=$((RANDOM % 9 + 10))
  49.         start=$((c-li+2))
  50.         co=$((RANDOM % (li-2) * 2 + 1 + start))
  51.         tput setaf $color; tput bold   # Switch colors
  52.         tput cup $li $co
  53.         echo o
  54.         line[$k$i]=$li
  55.         column[$k$i]=$co
  56.         color=$(((color+1)%8))
  57.     }
  58.     k=$((k % 2 + 1))
  59. done
复制代码


网上找的,效果还可以
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|FastFib VPS论坛

GMT+8, 2024-9-20 14:56 , Processed in 0.062016 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表