linux常用命令(MIT: Shell Tools and Scripting)

2023-12-13 10:08:15

(1)命令:? ? ? ? ?

1.?全选命令 *? ? ? ? ?eg.????????rm *(删除全部文件)

2. cat合并打印? ? ? eg.????????cat <(ls) <(ls ..)? ? ? ? (注意<前要有空格)

3.ls命令? ? ? ? ????????eg.? ? ? ??

ls -lhat?--color=auto(每个参数只能有一个空格,两个空格无法识别)
(详细作用见man ls)

(2)扩展:

1. 创建多个文件? ? ? ?

touch test{,1,2}? ??????==? test1 test2

touch test{1..9}? ? ? ? ==? test1 .. test9

(3)变量

(注意打印变量时用"",原样打印''):

1.打印命令结果??
? echo "$(ls)"

test
test1
test1..9
test2
test3
test4
test5
test6
test7
test8
test9

2.$_

(4)脚本函数:

1.eg.marco.sh

#!/bin/bash
marco(){

     echo "$(pwd)">/home/usr/Documents/path.txt

}
lms

使用source marco.sh? ? ? ? 使全局均可以使用marco函数

./marco.sh? ? ? ? ? ? ? ? ? ? ? ? ?加载marco函数定义

要调用函数直接输入函数名(如果有参数,跟在函数名后面)

文章来源:https://blog.csdn.net/2301_79140115/article/details/134954944
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。