linux shell学习笔记(一)——光标移动、输出、函数、循环
2016-01-13 18:36
651 查看
一些基本的操作,光标移动、彩色字符输出、自定义函数(含参数)、循环的写法。代码如下:
#!/bin/bash #-------------------- # Author: Peizhong Ju # Date: Jan. 13, 2016 # GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) #-------------------- function drawStar() { # para1: y # para2: x # para3: color # para4: character(s) # description: print colorful character(s) on the screen declare -A color_name color_name=([red]=31 [blue]=34 [green]=32) tput cup $1 $2 echo -e "\e[1;"${color_name[$3]}"m"$4"\e[0m" } clear for i in {1..20} do for((j=1;j<$i;++j)) do drawStar $j $i 'blue' '\\' done done显示效果如下:
相关文章推荐
- jmeter beanshell内容
- &&在shell
- Centos6笔记 -- Bash
- bash大括号参数扩展(Parameter Expansion)
- shell-echo
- shell 循环
- sed使用实例
- Shell脚本运行hive语句 | hive以日期建立分区表 | linux schedule程序 | sed替换文件字符串 | shell推断hdfs文件文件夹是否存在
- Powershell 提权框架-Powerup
- XCode集成shell脚本
- shell 数字运算
- shell命令批量杀死MySQL连接进程
- shell 引号
- pg常用自制shell脚本-tina
- 解决 Linux/Ubuntu: adb shell insufficient permissions for device 的问题
- powershell
- Fix for PowerShell Script Not Digitally Signed
- Linux Shell 编程点滴
- shell脚本编程之运算
- shell脚本编程之变量