shell 初步

ps -ef | grep redis
du -sh 查看文件夹大小
ls -hl 查看文件夹大小
#This is my first shell
#####改变权限
#chmod a+x fileName ###改变 所有用户有执行权限
#chmod g+w fileName ###改变 本组人有写权限
#chmod g+r fileName ###本组有读权限

#echo 打印
echo "first shell"
#$符号用于引用一个变量的内容,linux中所有的变量都是字符串
#read 会等待用户输入内容,用户输入内容赋值给 variable2
#$ read variable2
#variable1=${variable2}
#echo variable1
#export 命令指出是全局变量,任何用户都可以用的变量
#HOME,PATH,PS1,PS2,LOGNAME,SHLVL,及SHELL 等环境变量就是全局变量
#每个用户都有一个相关的称作HOME的目录,当一个用户登录,进入相应的HOME目录
#$ echo HOME
#PATH 变量 包含一列用冒号定界的目录的路径名,便于可执行程序的搜索
#PS1(Prompt String 1)变量包含了shell提示符,$符号
#$ PS1="HELLO>" <Enter>
#PS2是第一个提示符设置的环境变量
#LOGNAME 包含用户的注册名字
#SHLVL变量 该笔啊娘包含你当前工作的shell level
#SHELL变量 环境变量存储了用户的缺省shell

#命令替换
#单个命令使用多个命令的另一种方法(非Pipes)是通过命令替换
#echo "The date is `date`" # 会找date这个命令的结果来替换此处

# expr命令 是运行运算
#$ expr 4 + 5 # 注意有空格

#Example
#echo "Please enter the total number of queries reported today."
#read totalqueries
#echo "please enter the number of queries unanswered."
#read unswered
#pending=$((totalqueries+unswered))
#echo "Number of calls pending=$pending"
#EndExample


#test 和]命令 求值表达式,并返回true(0)或false
#if构造 文件测试,串测试,数值测试
#exit 终止shell 脚本的执行

#test -eq 等于则为真 -ne 不等于真 -gt 大于真 -ge 大于等于真 -lt小于真 -le 小于等于真
#字符串测试 = 等于 !=不等于 -z 字符串长度等于0 -n 长度不等于0
#文件测试 -e 存在真 -r 存在可读 -w 存在可写 -x 存在可执行 -s 存在至少一个字符
#-d 文件存在且为目录 -f存在并为普通文件 -c存在并为字符型特殊文件 -存在并块特殊文件
#-a 并且 -o 或者 !非
#


#########if Example ###########
####!/bin/bash
#echo "Enter the percentage of calls answered same day."
#read actual
#if test $actual -le 80 #= if [ $actual -le 80 ]
#then
# echo "Your Grade is Average."
#elif $actual -gt 80 -a $actual -le 90 ]
#then
# echo "Your Grade is Good."
#else
# echo "Your Grade is Outstanding."
#fi
#########End Example


#####case example########
####!/bin/bash
#echo "my offered"
#echo "1:Global roam"
#echo "2:V-mail"
#echo "3:Mail and Move"
#echo "4:Caller-ID"
#echo "5:Mzzn"
####echo -n 换行
#echo -n "select the offered:"
#read choice
#case $choice in
#1) echo "1";;
#2) echo "2";;
#3) echo "3";;
#4) echo "4";;
#5) echo "5";;
#*) echo "invaild option.";;
#esac
#####end example


#####while Example######
##!/bin/bash
#ecode=1000
#while [ $ecode -le 1003 ]
#do
# echo "Enter data for the employee with Employee Code =$ecode"
# echo -n "Employee Name"
# read name
# echo -n "Email Address"
# read email
# echo "$ecode : $name : $email" >> employee
# ((ecode=$ecode+1))
#done
#####end example######


######后台处理#####
##用于请求后台进程的符号是(&)
##$ wc tempfile & ###查看某文件的字符数 放到后台

####检查后台进程
##Ps(进程状态)命令为每个当前活动的每个进程产生一行入口
###终止后台进程
#kill 278 ####进程代码

###查看一个命令花费时间
##time 来
#time find /etc -name "passwd" 2>/dev/null
###查看 查找/etc 下面 名称为 "passwd"的命令 花费的时间 并且2(错误)重新定向到 dev/null 下?########也就是忽略错误


####垂直条(|)是管道符 它指示shell: '|'前面的命令的输出作为'|' 之后的命令的输入发送
#ls -l | more ###分页显示查看文件

###算数
#expr 4 + 5
#echo $((4+5))


######关机
shdo shutdown -h +60 #####六十分钟之后关机

###########发送email
mail -s "标题" xxx@xxx.com < firstsh.sh -- -f yyy@yyy.com


远程拷贝scp
scp root@192.168.1.222:/opt/IBM/WebSphere/AppServer/lib/ext/optedb-jdbc14.jar root@192.168.1.111:/opt/IBM/WebSphere/AppServer/lib/ext


curl www.baidu.com
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值