[root@rocky8 bin]# vim for_triangle.sh#!/bin/bash##**********************************************************************************************#Author: Raymond#QQ: 88563128#Date: 2021-10-10#FileName: for_triangle.sh#URL: raymond.blog.csdn.net#Description: The test script#Copyright (C): 2021 All rights reserved#*********************************************************************************************read -p "请输入三角形的行数:" line
for((i=1;i<=line;i++));dofor((k=0;k<=line-i;k++));doecho -e ' \c'donefor((j=1;j<=2*i-1;j++));doecho -e '*\c'doneechodone[root@rocky8 bin]# bash for_triangle.sh
请输入三角形的行数:10****************************************************************************************************
22.判断/var/目录下所有文件的类型
[root@rocky8 bin]# vim for_var.sh#!/bin/bash##**********************************************************************************************#Author: Raymond#QQ: 88563128#Date: 2021-10-10#FileName: for_var.sh#URL: raymond.blog.csdn.net#Description: The test script#Copyright (C): 2021 All rights reserved#**********************************************************************************************read -p "Please input directory: " DIR
forFILEin`ls $DIR`;doTY=`file $DIR/$FILE |egrep -o "link|text|block|directory"`case$TYintext)echo"file $DIR/$FILE is file";;link)echo"file $DIR/$FILE is Link";;block)echo"file $DIR/$FILE is Block";;directory)echo"file $DIR/$FILE is Directory";;*)echo"file $DIR/$FILE is Others"esac;done[root@rocky8 bin]# bash for_var.sh
Please input directory: /var/
file /var//account is Directory
file /var//adm is Directory
file /var//cache is Directory
file /var//crash is Directory
file /var//db is Directory
file /var//empty is Directory
file /var//ftp is Directory
file /var//games is Directory
file /var//gopher is Directory
file /var//kerberos is Directory
file /var//lib is Directory
file /var//local is Directory
file /var//lock is Link
file /var//log is Directory
file /var//mail is Link
file /var//nis is Directory
file /var//opt is Directory
file /var//preserve is Directory
file /var//run is Link
file /var//spool is Directory
file /var//tmp is Directory
file /var//yp is Directory