首页 > 系统相关 >shell-练习

shell-练习

时间:2022-10-29 12:35:48浏览次数:48  
标签:bin shell 打印 练习 字符串 bash

1.打印字符串

#!/bin/bash
<<! 
	打印字符串
	知识点:echo、if、$、``、wc -c

!
for s in Bash also interprets a number of multi-character options.
do
	n=`echo $s | wc -c`	# wc -c统计字符串长度,``用于输出命令最后结果
	if [ $n -lt 6 ]		# if判断条件加[],里面的两边需要加空格
	then				# 这里有个then,相当关于花括号
		echo $s
	fi					# 注意控制语句的结尾,相当于花括号
done

标签:bin,shell,打印,练习,字符串,bash
From: https://www.cnblogs.com/starcos/p/16838479.html

相关文章