美文网首页
Linux Shell

Linux Shell

作者: 蜗牛会跑步 | 来源:发表于2019-09-26 10:19 被阅读0次

1. Shell

shell script 是利用 shell 的功能所写的一个程序 (program),这个程序是使用纯文本文件,将一些 shell 的语法与指令(含外部指令)写在里面, 搭配正规表示法、管线命令与数据流重导向等功能,以达到我们所想要的处理目的。

执行方式

切换到相对应的目录,使用: ./+sh文件。eg:./helloworld.sh

2.Shell 指令

1.1 test指令

1.1.1 对文件的操作
指令 含义
test -e 测试文件或者文件夹是否存在
test -f 测试文是否存在且为文件
test -d 测试文件是否存在且为文件目录

eg:test -e

zhujian@Pigzhu:~/Desktop/python$ ls
hellopython
zhujian@Pigzhu:~/Desktop/python$ echo test -e
test -e
zhujian@Pigzhu:~/Desktop/python$ test -e hellopython && echo existed || echo not existed
existed
zhujian@Pigzhu:~/Desktop/python$ 

eg:test -f

zhujian@Pigzhu:~/Desktop/python$ ls
hellopython
zhujian@Pigzhu:~/Desktop/python$ echo -e test -f
test -f
zhujian@Pigzhu:~/Desktop/python$ test -f hellopython && echo  is file || echo is not file
is not file
zhujian@Pigzhu:~/Desktop/python$ 
1.1.2 对文件读、写、执行权限的操作
指令 含义
test -r 测试该文件或者文件夹是否具有可读权限
test -w 测试该文件或者文件夹是否具有可写权限
test -x 测试该文件或者文件夹是否具有可执行权限

eg:test -r

zhujian@Pigzhu:~/Desktop/python$ cd hellopython/
zhujian@Pigzhu:~/Desktop/python/hellopython$ ls
hellopython.py
zhujian@Pigzhu:~/Desktop/python/hellopython$ echo test -r
test -r
zhujian@Pigzhu:~/Desktop/python/hellopython$ test -r hellopython.py && echo the file can read || the file can not read
the file can read
zhujian@Pigzhu:~/Desktop/python/hellopython$ ls -lh
total 4.0K
-rw-r--r-- 1 zhujian zhujian 43 7月   9 20:29 hellopython.py

相关文章

  • Shell入门笔记

    Shell脚本:Linux Shell脚本学习指南菜鸟教程 - Shell教程Linux入门 - Shell脚本是...

  • shell基础

    Linux学习 一、shell介绍 Linux shell基础 什么是shell shell是一个命令解释器,提供...

  • Linux下的shell

    Shell 和 Linux shell程序是包含若干行shell或linux命令的文件。linux命令语句只能一行...

  • linux shell脚本攻略笔记

    LINUX SHELL脚本攻略笔记[速查] linux shell脚本攻略笔记

  • Shell学习

    Linux Shell基础教程 (一) (二) Linux Shell简明教程(推荐) (一) (二) Linux...

  • Shell 脚本编程简介

    Shell菜鸟教程[https://www.runoob.com/linux/linux-shell.html] ...

  • shell 教程学习推荐地址

    [shell 教程学习推荐地址:] http://www.runoob.com/linux/linux-shell...

  • bash shell学习

    Shell 传递参数 参考链接:https://www.runoob.com/linux/linux-shell-...

  • shell脚本基础应用

    Shell 教程[https://www.runoob.com/linux/linux-shell.html]li...

  • Shell-基础教程-变量

    参考教程链接 http://www.runoob.com/linux/linux-shell.html Shell...

网友评论

      本文标题:Linux Shell

      本文链接:https://www.haomeiwen.com/subject/ezuguctx.html