shell总结(1)

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