linux shell学习笔记(一)shell简介
1、shell是核心程序(kernel)之外的指令解析器,是一个程序,同时是一种命令语言和程序设计语言。2、shell的类型ash、bash、ksh、csh、tcsh(/etc/shells 查看系统中有的shell)(echo $SHELL查看当前系统运行的shell)(linux默认的shell为/bin/bash)
3、所有的linux命令程序都是在shell中运行
4、shell中可运行子shell
5、文件权限chmod operator filename
who (u,g,o,a)
operator (+,-,=)
permission (r,w,x,s,t)
6、使用shell脚本的原因(功能强大、节约时间)
7、shell脚本基本元素#!/bin/bash(第一行)
#(表示注释)
变量
流程控制结构
8、shell脚本运行方式
例子:helloworld.sh
#!/bin/bash
#这是一个打印"hello world"的shell脚本
printchar="hello world"
echo $printchar
(1)chomd u+x helloworld.sh
(2)./helloworld.sh
9、shell特性:别名、管道、命令替换、重定向、后台处理、模式匹配、变量、特殊字符
10、别名:alias
alias ll='ls -alh'
11、命令替换
myfile的内容:
parm
findfile
ls `cat myfile` -al
12、后台处理
什么是后台?
一个终端可以同时运行多个程序
nohup command &
13、变量 变量用来存储数据
14、管道(|)
把一个命令的输出连接到另一个目录的输入
ls | sort
15、重定向(< >)
与管道相关,可以改变程序运行的输入来源和输出地点
sort &:表示重定向
*[]!:表示匹配模式
$:变量名的开头
#:表示注释(第一行除外)
页:
[1]