码迷,mamicode.com
首页 >  
搜索关键字:linux-shell    ( 1936个结果
linux shell脚本中流程控制语句 if 、for、while、case
linux shell脚本中流程控制语句 if、for、while、case 1、if语句 [root@centos7 test2]# ls test.sh [root@centos7 test2]# pwd /home/test2 [root@centos7 test2]# cat test.sh ...
分类:系统相关   时间:2021-04-22 16:20:40    阅读次数:0
LINUX-shell&find 指令
1、编写脚本 createuser.sh,实现如下功能:使用一个用户名作为参数,如果 指定参数的用户存在,就显示其存在,否则添加之;显示添加的用户的id号等信息 read -p " input the user: " USER if id $USER &> /dev/null ; then echo ...
分类:系统相关   时间:2021-04-20 14:31:15    阅读次数:0
linux shell 命令之trap之捕捉DEBUG信号
linux 使用trap命令进行调试 Shell脚本在搪行时,会产生三个所谓的伪信号。三种伪信号如下:信号名称 产生条件EXIT 从函数中退出,或者整个脚本执行完毕ERR 当一条命令返回非零状态码,即命令执行不成功DEBUG 脚本中的每一条命令执行之前 vi trapdebug.sh #!/bin/ ...
分类:系统相关   时间:2021-04-14 12:02:07    阅读次数:0
Linux shell脚本之判断进程是否在运行
vi proc1.sh #!/bin/bash #此脚本期望的参数个数argno=1 if [ $# -ne $argno ]then echo "Usage: 'basename $0' PID-number" >&2fi if [ ! -f "/proc/$1" ]then echo "Proc ...
分类:系统相关   时间:2021-04-14 11:51:22    阅读次数:0
linux shell命令之脚本要有足够的提示
一个有参数但无提示说明的脚本#login1.sh: 用户登录,判断用户输入的用户名和密码是否错误 vi login1.sh #!/bin/bash for ((i=0; i < 3; i++))do read username read password if test "$username" = ...
分类:系统相关   时间:2021-04-14 11:41:38    阅读次数:0
linux shell 之脚本优化
vi file_can_execute_or_not1.sh #!/bin/bash #判断输入的参数个数是否为两个 if [ $# -lt 2 ]then echo "The num of parameter is not right! " exit 0fi #判断用户输入的第一个文件是否可以读i ...
分类:系统相关   时间:2021-04-13 12:56:38    阅读次数:0
linux shell命令之非交互式Shell脚本
vi no_interaction_script1.sh #!/bin/bash #提示用户该脚本3秒后退出echo "This script will quit after 3 seconds. " #计时3s sleep 1echo -n "."sleep 1echo -n "."sleep 1 ...
分类:系统相关   时间:2021-04-13 12:16:49    阅读次数:0
linux shell之数组的特殊用法
vi string_array.sh #!/bin/bash city=(Nanjing Atlanta Massachusetts Marseilles) #建立一个简单的数组echo "Extracting Substring" #演示抽取子串功能echo ${city[*]:0} #抽取整个数 ...
分类:编程语言   时间:2021-04-13 12:08:59    阅读次数:0
管道通信(上)
管道通信(上) (一)概述 Linux Shell 都允许重定向,而重定向使用的就是管道。例如,ps | grep vsftpd 。管道是单向的、先进先出的、无结构的、固定大小的字节流。管道是Linux由Unix那里继承过来的进程间的通信机制,它是Unix早期的一个重要通信机制。其思想是,在内存中创 ...
分类:其他好文   时间:2021-04-01 13:26:09    阅读次数:0
linux shell命令之REPLY
vi readreply.sh #!/bin/bash#第一部分 echo -n "What is your name?"readecho "Your name is $REPLY" #已将变量的值从标准输入读到REPLY #第二部分echo -n "What is the name of your ...
分类:系统相关   时间:2021-03-30 13:53:42    阅读次数:0
1936条   上一页 1 2 3 4 ... 194 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!