摘要: if [[ "$sel" -lt 1 || "$sel" -gt 5 ]] then echo "Error input! Please input again:" else break fi 语法 if(空格 表达式 空格)#如果没有空格报then未识别错误(格式错误) then 条件满足语句 e 阅读全文
posted @ 2021-10-14 11:19 困到很想醒 阅读(271) 评论(0) 推荐(0) 编辑
摘要: #for循环输入两个数计算两数的和x=0 #累加器变量清零 for y in $* #变量依次取位置参数值,然后执行循环体中的命令表,至位置参数取完为止。 do x=`expr $x + $y` #计算表达式x+y,并把计算结果赋给x。(累加器x=x+y) done echo "The sum is 阅读全文
posted @ 2021-10-14 11:06 困到很想醒 阅读(39) 评论(0) 推荐(0) 编辑
摘要: #编写脚本输入日期计算生日echo “Please input year:”#输出语句 read year #从键盘读入年份给year变量 echo “Please input month:”#输出 read month #从键盘读入月份给month变量 cal $month $year #日历函数 阅读全文
posted @ 2021-10-14 11:01 困到很想醒 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 脚本操作基础 1. vim 脚本名 #当前文件夹创建一个脚本文件并取名打开 bash 脚本名 #执行脚本第一种方法 gcc -o hello.out hello.c #编译c脚本hello.c输出文件hello.out ./hello.out #执行hello.out 2. vim编辑器基础操作 i 阅读全文
posted @ 2021-10-14 10:55 困到很想醒 阅读(344) 评论(0) 推荐(0) 编辑
摘要: pwd #显示当前路径 ls -l #长格式显示文件详细信息。注:是字母l,不是数字1 mkdir mydir #创建子目录mydir ls -l cd mydir #改变路径到mydir pwd cp /etc/manpath.config . #复制/etc/manpath.config到当前目 阅读全文
posted @ 2021-10-14 10:43 困到很想醒 阅读(107) 评论(0) 推荐(0) 编辑
摘要: cat file1 #打开文件 more file1 tail file1 head file1 wc file1 #统计文件file1中的行数、单词数和字符数 rm -r dir 删除目录 rm -i file1 #请求用户确认删除file1文件(慎用!一定是删除自己创建的文件) 实用程序 dat 阅读全文
posted @ 2021-10-14 10:42 困到很想醒 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 1.常用shell命令 创建文件夹 mkdir 文件夹名 改变/进入文件夹 cd 文件夹名 显示当前文件夹路径 pwd 列出当前文件夹内容 ls 当前文件夹长列表 ls -l 复制 cp /文件路径/文件名.后缀 /复制到路径 重命名 mv 文件名.后缀 新文件名.后缀 阅读全文
posted @ 2021-10-14 10:37 困到很想醒 阅读(27) 评论(0) 推荐(0) 编辑