shell基础

●umask   --查看当前用户创建文件或文件夹时的默认权限

eg:

[test@szbirdora 1]$umask

0002

[test@szbirdora 1]$ls -lh

-rw-rw-r--     test test   myfile   

drwxrwxr-x     test test 1

上面的例子中我们看到由test默认创建的文件myfile和文件夹1的权限分别为664,775.而通过umask查到的默认权限为002.所以可以推断出umask的计算算法为:

umask        file          directory

0              6              7

1            5              6

2            4              5

3            3              4

4            2              3

5          1            2

6          0             1 

7          0             0

 

●连接ln

硬连接 ln sourcefile targetfile   连接后的target文件大小和source文件一样

软连接 ln -s sourcefile targetfile  类似于windows的快捷方式

 

●shell script 基本结构

#!/bin/bash     --------bash shell开头必须部分

# description     --------注释部分(可有可无,为了阅读方便最好加以说明)

variable name=value ---------变量部分,声明变量,赋值

control segment   ---------流程控制结构,如判断、循环、顺序

eg.

helloworld.sh

#! /bin/bash

# This is a helloworld shell script

printchar = "hello world"

echo $printchar

 

[test@szbirdora 1]$sh helloworld.sh

hello world

 

●shell 特性

①别名  alias eg. alias ll = “ls -l”

②管道  a |b 将a命令的输出作为b命令的输入 eg. ls |sort   将ls列举的项排序

③命令替换   a`b`  将b命令的输出作为a命令的输入 eg. ls `cat myfile` 列举出cat myfile的输出项

④后台运行  nohup command&    可通过jobs -l查看后台运行的脚本

⑤重定向   >,<  可以改变程序运行的输出来源和输入来源

⑥变量  可以用$varname 来调用变量

⑦特殊字符  `用来替换命令 \用来使shell无法认出其后的特殊字符,使其失去特殊含义;允许一行放多个命令 () 创建成组的命令?? {} 创建命令块       ??    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

涂作权的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值