都搞忘记了.....记录.........
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: countloop.sh
# USAGE: ./countloop.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
for i in 1 2 3 4 5 6 #循环1~6
doecho "Thre for loop is run $i times."
done
echo "==============================================================================================================="for linux in Debian Redhat Suse Fedora Centos7 Ubunto
do
echo "current out system is ${linux}....."
done
echo "================================================================================================================"
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: countloop.sh
# USAGE: ./forcmdssub.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
echo "Printing file list in /etc directory........"
for file in `ls /etc/*`
doecho "current print file is: $file"
done
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: countloop.sh
# USAGE: ./forcmdssub.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
echo "Printing file list in /etc directory........"
for file in `ls /etc/*`
doecho "current print file is: $file"
done
[root@www shelldic]# cat forvarscoutents.sh
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: countloop.sh
# USAGE: ./forvarscoutents.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================filenames="/etc/my.cnf /etc/vconsole.conf /etc/rsyncd.conf /etc/sestatus.conf /usr/local/rs.conf"
# 上面的文件名以空格分割for file in $filenames
do
[ -f $file ] && echo "The file $file was found.." || echo "***** ERROR: The file $file was missing.....*******"
# 如果是文件,则打印文件存在,如果不存在则打印丢失
done
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: countloop.sh
# USAGE: ./simplenestedfor.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
for (( i = 0; i < 30; i++ )) #外循环do
for (( j=0; j<160; j++ )) # 内循环
do
echo -n "* " #
doneecho "" #
done
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: whichreadfile.sh
# USAGE: ./whichreadfile.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================file=$1 # 将位置参数1的值赋值给变量file
if [ $# -lt 1 ];then # 如果脚本未指定参数,则打印使用方法并退出运行
echo "Usage: $0 FILEPATH"
exitfi
while read -r line # 使用read命令从标准输入读取文件的一行,并赋值给变量line
do
echo $line # 打印读取的行
done < "$file"