shell小结(1)

-------------------------------------------------------------------------------------------
samba服务器:

 

-------------------------------------------------------------------------------------------
samba服务器:

//连接对方共享的共享,这个用户名是对方提供的,效果相当于ftp,如果对方机器开启了guest用户,则
//不用输入用户名
smbclient   //机器名/共享目录   -U   用户名

//将window上的磁盘挂载到本机linux上的某一个目录下
//这里的uid,gid是linux用户的uid,gid,必须指定,否则这里的y:会访问不了
mount -t smbfs -o username=gkf14930,uid=9909,gid=100,iocharset=gbk 
		//100.168.40.55/share /home/rbttest/dc0sp29_613/bin/y:

//启动samba服务
/etc/init.d/smb restart

//smb.conf配置
[global]
        workgroup = group245
        security = share
        netbios name = linu245
        usershare allow guests = Yes  //指定以guest用户登录
[rbt]
         path = /home/rbttest/dc0sp29_613/bin/y:
         writable = Yes
         read only = no
         guest   ok   =   yes
         share   modes   =   yes
-------------------------------------------------------------------------------------------
linux默认的三个IO通道是:
0:stdin
1:stout
2:sterr

-------------------------------------------------------------------------------------------
break与continue

#!/bin/bash

for ((i=0;i<3;i++))
do
	echo $i
	for((j=0;j<3;j++))
	do
		if ((j==2))
		then
			break 2 #这里的2代表跳出两层循环,即跳出整个循环
		fi
	done
done
-------------------------------------------------------------------------------------------

从文件中读取内容:
#!/bin/bash

while read line
do
	echo $line
done < text.txt

当然也可以用{}将while语句包装起来
-------------------------------------------------------------------------------------------

read命令:

#!/bin/bash

read -p "input your name please: " name

if [ $name = "xuxu"] ;then
	echo 'ok'

fi

如果用户直接回车时,则会报错,这时的常用的处理方式如下:
“加一个额外的字符,从而保证比较的两个字符串都不为空”

read -p "input your name please: " name

if [ X$name = X"xuxu"] ;then
	echo 'ok'

fi

-------------------------------------------------------------------------------------------
printf命令:
 printf 'name is %s\n' $name	

-------------------------------------------------------------------------------------------
什么是shell脚本?
	命令与函数的集合

-------------------------------------------------------------------------------------------

登录环境:shell的初始化脚本与执行顺序
/etc/profile
~/.bash_profile
~/.bash_login
~/.bashrc
~/.profile
-------------------------------------------------------------------------------------------

 
#!/bin/bash

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值