Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2766464
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2012-12-22 19:16:14

1:Unix-like的操作系统中,文件分为几种
一般文件: -
目录:d
设备文件:字符文件:c 、磁盘文件:b
内部进程通信文件:有socket文件:s、连接文件:p
2:文件的权限:
s:特殊权限set user id(s)、set group id(s)及sticky bit(t),简称为sst
3:!的理解
[!0-9]:非数字
[!a-z]:非英文小写字母
[!A-Z]:非英文大写字母
注意:若!不放在集合的开头,就失去“非”的含义!
例如:[0-9!]代表数字或感叹号
例如:[\!0-9]代表感叹号或数字

4:不同的脚本方式
例如: source /root/test.sh 或. /root/test.sh
     和sh /root/test.sh区别

5:执行script(使用#!/bin/bash),不调用.bash_profile和.bashrc,但会检查BASH_ENV的内容,如果不为空,则执行它指定的文件
  执行script(使用#!/bin/sh),不调用任何启动文件,没有其他检查环境变量的操作

6:echo
如果不想让它换行,echo -n "hello world”
选项-e可让字符串中的特殊字符有作用,例如:echo -e "I am the king\nof the world"  输出如下:
I am the king
of the world
\n会被解释为换行字符
见附件!

7:当子shell产生时,它会继承父shell的环境变量等条件,因此只要使变量成为环境变量,就能为子shell使用。变成环境变量的方法为export和declare -x 
例如:
[root@qht2 test]# export var="hello"
[root@qht2 test]# declare -x var1="hello1"
[root@qht2 test]# export -p    | grep var
declare -x MAIL="/var/spool/mail/root"
declare -x var="hello"
declare -x var1="hello1"
[root@qht2 test]# bash ##执行完之后就到一个子shell中了!
[root@qht2 test]# echo $var
hello
[root@qht2 test]# echo $var1
hello1
[root@qht2 test]# 


8:$1----$n位置参数
$0代表执行程序的名称
$*和$@是不同的!
$*代表所有的位置参数,而且视为一个字符串

例如:./test.sh abc 123 xyz ,则$*表示"abc 123 xyz"

$@代表所有的位置参数
例如:./test.sh abc 123 xyz ,则$@表示"abc","123","xyz"三个字符串
$#代表位置参数的个数
$?代表上一个命令行执行结束后的传回值,0代表执行成功,非0代表执行失败

9:declare -i 定义一个整型变量
root@qht2 test]# declare -i a=60
[root@qht2 test]# echo $a
60
[root@qht2 test]# a="hello"
[root@qht2 test]# echo $a
0
[root@qht2 test]# 


10:[ -f /etc/profile ] && . /etc/profile 

 
阅读(908) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~