Linux shell编程学习笔记36:read命令

这篇具有很好参考价值的文章主要介绍了Linux shell编程学习笔记36:read命令。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

 *更新日志 

*2023-12-18 1.根据[美] 威廉·肖特斯 (Willian shotts)所著《Linux命令行大全(第2版)》
                        更新了-e、-i、-r选项的说明

                      2.更新了 2.8 的实例,增加了gif动图

                      3.补充了-i的应用实例 2.12

目录

  1. 目录
  2. 0 前言
  3. 1 read命令的功能、格式、返回值和注意
    1. 1.1 命令功能
    2. 1.2 命令格式
    3. 1.3 返回值
    4. 1.4 注意事项
  4. 2 命令应用实例
    1. 2.1 一次读入多个变量值
    2. 2.2 不指定变量名
    3. 2.3 测试read命令的返回值
    4. 2.3 指定输入时限并进行相应处理
    5. 2.4 -t 指定结束符
    6. 2.5 -n 指定输入字符个数
    7. 2.6 -N 指定输入字符个数
    8. 2.7 -s不回显来自终端的输入
    9. 2.8 -e使用命令补全功能
    10. 2.9 -r 允许输入的值中包含的反斜杠\也作为值输出
    11. 2.10 -a 读取数组值
    12. 2.11 -u指定文件说明符
    13. 2.12 -i 使用初始值

 

0 前言

在交互式编程中,有时我们需要用户先通过键盘来输入数据,然后程序根据用户输入的数据来做相应的处理。

在之前的学习中,我们已经使用read命令来读取用户通过键盘输入的数据,但对read命令没有做进一步的说明。

现在我们来研究一下read命令的详细用法。

1 read命令的功能、格式、返回值和注意

我们可以使用命令 help read  来查看seq命令的帮助信息:

purleEndurer @ bash ~ $ help read
read: read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
    Read a line from the standard input and split it into fields.
    
    Reads a single line from the standard input, or from file descriptor FD
    if the -u option is supplied.  The line is split into fields as with word
    splitting, and the first word is assigned to the first NAME, the second
    word to the second NAME, and so on, with any leftover words assigned to
    the last NAME.  Only the characters found in $IFS are recognized as word
    delimiters.
    
    If no NAMEs are supplied, the line read is stored in the REPLY variable.
    
    Options:
      -a array  assign the words read to sequential indices of the array
                variable ARRAY, starting at zero
      -d delim  continue until the first character of DELIM is read, rather
                than newline
      -e                use Readline to obtain the line in an interactive shell
      -i text   Use TEXT as the initial text for Readline
      -n nchars return after reading NCHARS characters rather than waiting
                for a newline, but honor a delimiter if fewer than NCHARS
                characters are read before the delimiter
      -N nchars return only after reading exactly NCHARS characters, unless
                EOF is encountered or read times out, ignoring any delimiter
      -p prompt output the string PROMPT without a trailing newline before
                attempting to read
      -r                do not allow backslashes to escape any characters
      -s                do not echo input coming from a terminal
      -t timeout        time out and return failure if a complete line of input is
                not read withint TIMEOUT seconds.  The value of the TMOUT
                variable is the default timeout.  TIMEOUT may be a
                fractional number.  If TIMEOUT is 0, read returns success only
                if input is available on the specified file descriptor.  The
                exit status is greater than 128 if the timeout is exceeded
      -u fd             read from file descriptor FD instead of the standard input
    
    Exit Status:
    The return code is zero, unless end-of-file is encountered, read times out,
    or an invalid file descriptor is supplied as the argument to -u.
readarray: readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
    Read lines from a file into an array variable.
    
    A synonym for `mapfile'.
readonly: readonly [-aAf] [name[=value] ...] or readonly -p
    Mark shell variables as unchangeable.
    
    Mark each NAME as read-only; the values of these NAMEs may not be
    changed by subsequent assignment.  If VALUE is supplied, assign VALUE
    before marking as read-only.
    
    Options:
      -a        refer to indexed array variables
      -A        refer to associative array variables
      -f        refer to shell functions
      -p        display a list of all readonly variables and functions
    
    An argument of `--' disables further option processing.
    
    Exit Status:
    Returns success unless an invalid option is given or NAME is invalid.
purleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

 1.1 命令功能

从标准输入或-u 选项指定的文件描述符读取一行。该行被拆分为多个字段,就像单词拆分一样,第一个单词分配给第一个 变量,第二个单词分配给第二个 变量,依此类推,任何剩余的单词都分配给最后一个 变量。如果未提供 变量名,则读取的行存储在 REPLY 变量中。

只有在 $IFS 中找到的字符才会被识别为单词分隔符。

1.2 命令格式

 read [-ers] [-a 索引数组名] [-d 结束符] [-i 初始字符串] [-n 字符数] [-N 字符数] [-p 提示字符串] [-t 超时秒数] [-u 文件描述符] [变量名 ...]

  • 选项说明 
选项 说明 备注
-a 索引数组名 将读取的单词从下标零开始分配给数组名指定的 索引数组,默认是以空格为分割符 array
-d 结束符 读取数据,直至结束符,而不是换行符 delimiter
-e 使用 在交互式 shell 中获取用户输入行,在输入的时候可以使用命令补全功能
-i 初始字符串

使用初始字符串作为 用户输入行 的初始值

需要与-e选项一起使用

initialize
-n 字符数 在读取指定的字符数后返回,除非遇到定界符、换行符或读取超时,定界符包括\t(tab键)。 number
-N 字符数

在读取指定的字符数后返回,除非遇到 EOF 或读取超时

与 -n 不同的是,-N 会忽略任何定界符。

number
-p 提示字符串 先输出提示字符串,再读取数据 prompt
-r 不允许反斜杠转义任何字符 raw mode
-s 不回显来自终端的输入 silence
-t 超时秒数

指定输入字符的等待时间。

如果在 超时秒数 内未读取完整的输入行,则超时并返回失败。
TMOUT变量的值是默认超时秒数。

超时秒数 可以是小数。
如果 超时秒数 为 0,则仅当指定的文件描述符上有可用的输入时,读取才会返回成功。
如果超过超时,则退出状态大于 128

timeout
-u 文件描述符 从指定的文件描述符读入数据 use

1.3 返回值

命令正常执行时返回值为零,

如果遇到文件末尾、读取超时或提供无效文件描述符作为 -u 的参数时,返回值不为零。

如果读取超时,返回值 将 大于 128。

1.4 注意事项

  • 变量名列表 应该放在 命令的最后。
  • 变量名之间以空格分隔。
  • -i选项需要与-e选项一起使用才有用

2 命令应用实例

2.1 一次读入多个变量值

例:提示用户输入3个整数,作为a、c、c 三个变量的值

purpleEndurer @ bash ~ $ read -p "Enter there integers:" a  b c
Enter there integers:1 2 3
purpleEndurer @ bash ~ $ echo a=$a b=$b c=$c
a=1 b=2 c=3
purpleEndurer @ bash ~ $ read -p "Enter there integers:" a  b c
Enter there integers:1 2 3 4 5 6
purpleEndurer @ bash ~ $ echo a=$a b=$b c=$c
a=1 b=2 c=3 4 5 6
purpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

当我们输入1 2 3 这三个整数后,变量a的值为1,变量b的值为2,变量c的值为3。

当我们输入1 2 3 4 5 6 这六个整数后,由于我们只给了a、b、c三个变理名,所以变量a的值为1,变量b的值为2,而变量c的值为:3 4 5 6。

2.2 不指定变量名

例:提示用户输入3个整数,但没指定变量名

purpleEndurer @ bash ~ $ echo $REPLY

purpleEndurer @ bash ~ $ read -p "Enter there integers:"
Enter there integers:1 2 3
purpleEndurer @ bash ~ $ echo $REPLY 
1 2 3
purpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

由于我们没有指定变量名,所以输入的值1 2 3保存在变量REPLY中。

2.3 测试read命令的返回值

例:提示用户输入名字,输入时间限定为10秒钟

purpleEndurer @ bash ~ $ read -t 10 -p "Enter your name:"
Enter your name:pe
purpleEndurer @ bash ~ $ echo $?
0
purpleEndurer @ bash ~ $ read -t 10 -p "Enter your name:"
Enter your name:purpleEndurer @ bash ~ $ echo $?
142
purpleEndurer @ bash ~ $ read -t 10 -p "Enter your name:"
Enter your name:purpleEndurer @ bash ~ $ echo $?
1
purpleEndurer @ bash ~ $ read -t 10 -p "Enter your name:"
Enter your name:^C
purpleEndurer @ bash ~ $ echo $?
130
purpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

当我们在10秒钟内输入用户名pe并回车,read命令正常执行,返回值为0

当我们未在10秒钟内输入用户名,read命令返回值为142,大于128

当我们输入^D时,read命令返回值为1

当我们输入^C时,read命令返回值为130

2.3 指定输入时限并进行相应处理

例:编写一个脚本,提示用户在5秒钟内输入名字,如果用户输入名字,则对用户进行问候,否则提示用户没有输入名字。

脚本内容如下:

read  -t 5 -p "Enter you name in 5 seconds:" name # 提示用户在5秒钟内输入名字并保存在变量name中
if [ $? == 0 ]; then                              # 如果用户在5秒钟内输入了名字,那么read命令返回值为0
   echo Hello, $name.                             # 对用户进行问候
else
   echo -e "\nYou do not enter your name."        # 提示用户没有输入名字
fi

purpleEndurer @ bash ~ $ cp /dev/stdin a.sh
read  -t 5 -p "Enter you name in 5 seconds:" name
if [ $? == 0 ]; then
   echo Hello, $name.
else
   echo -e "\nYou do not enter your name."
fi

purpleEndurer @ bash ~ $ cat a.sh
read  -t 5 -p "Enter you name in 5 seconds:" name
if [ $? == 0 ]; then
   echo Hello, $name.
else
   echo -e "\nYou do not enter your name."
fi
purpleEndurer @ bash ~ $ . a.sh
Enter you name in 5 seconds:pe
Hello, pe.
purpleEndurer @ bash ~ $ . a.sh
Enter you name in 5 seconds:
You do not enter your name.
purpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

2.4 -t 指定结束符

例 读取用户输入值存入变量a,指定#作为结束符

purpleEndurer @ bash ~ $ read -d '#' a
ab#purpleEndurer @ bash ~ $ echo $a
ab
purpleEndurer @ bash ~ $ 

 linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

当我们输入ab#时,读取结束。变量a的值为ab。

2.5 -n 指定输入字符个数

例 读取5个字符,分别保存到变量a和b

purpleEndurer @ bash ~ $ read -n 5 a b
12345purpleEndurer @ bash ~ $ echo a=$a b=$b
a=12345 b=
purpleEndurer @ bash ~ $ read -n 5 a b
12 34purpleEndurer @ bash ~ $ echo a=$a b=$b
a=12 b=34
purpleEndurer @ bash ~ $ read -n 5 a b
1       234purpleEndurer @ bash ~ $ echo a=$a b=$b
a=1 b=234
purpleEndurer @ bash ~ $ read -n 5 a b
12
purpleEndurer @ bash ~ $ echo a=$a b=$b
a=12 b=
purpleEndurer @ bash ~ $ read -n 5 a b
123^C
purpleEndurer @ bash ~ $ echo a=$a b=$b
a=12 b=
purpleEndurer @ bash ~ $ 

当我们输入12345时,变量a的值为12345,变量b值为空

当我们输入12空格34时,变量a的值为12,变量b值为34

当我们输入1[Tab]234时,变量a的值为1,变量b值为234

当我们输入12回车时,变量a的值为12,变量b值为空

当我们输入123^C时,read命令被终止了,所以变量a的值没有变化,仍为12,变量b值没有变化,仍为空

2.6 -N 指定输入字符个数

例 读取5个字符,分别保存到变量a和b

purpleEndurer @ bash ~ $ read -N 5 a b
12      34purpleEndurer @ bash ~ $ echo a=$a b=$b
a=12 34 b=
purpleEndurer @ bash ~ $ read -N 5 a b
12 34purpleEndurer @ bash ~ $ echo a=$a b=$b
a=12 34 b=
purpleEndurer @ bash ~ $ read -d '#' -N 5 a b
12#34purpleEndurer @ bash ~ $ echo a=$a b=$b
a=12#34 b=
purpleEndurer @ bash ~ $ 

 linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

 当我们输入12[Tab]34时,变量a的值为12    34,变量b值为空

当我们输入12空格34时,变量a的值为12 34,变量b值为空

即使我们用-t '#' 选项指定#作为结束符,输入12#34,结果变量a的值为12#34,变量b值为空 

  • 看来使用-N选项后,空格或[Tab]不再作为字符串值的分隔符,-t选项也不起作用,这样只能将读取值存到第1个变量中了。

2.7 -s不回显来自终端的输入

例:提示用户输入密码,输入时不回显,输入完成后再显示用户输入的密码。

purpleEndurer @ bash ~ $ read -s -p "Enter your password:" p
Enter your password:purpleEndurer @ bash ~ $ echo Your password is $p
Your password is abcd
purpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

当用户输入密码abcd时并不回显,按回车键后,才显示用户输入的密码是abcd。

2.8 -e使用命令补全功能

PurpleEndurer @ bash ~ $ ls
Code
PurpleEndurer @ bash ~ $ read -e a
Code/
PurpleEndurer @ bash ~ $ echo $a
Code/
PurpleEndurer @ bash ~ $ read -e a
cde
PurpleEndurer @ bash ~ $ echo $a
cde
PurpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

我们先用ls命令查看当前目录内容,存在一个名Code的文件或文件夹

然后我们用命令 read -e a 来读取输入存到变量a

在我们输入大写字符C后按Tab键启用命令补全功能,输入行的内容就变为Code/,按下回车键。

再用echo $a 查看变量a的值为Code/

在我们输入大写字符C后按Tab键启用命令补全功能,输入行的内容就变为Code/,我们用删除键Backspace删除Code/,输入cde回车,再用echo $a 查看变量a的值为cde

2.9 -r 允许输入的值中包含的反斜杠\也作为值输出

purpleEndurer @ bash ~/Code $ read a
//\c
purpleEndurer @ bash ~/Code $ echo $a
//c
purpleEndurer @ bash ~/Code $ read -r a
//\c
purpleEndurer @ bash ~/Code $ echo $a
//\c
purpleEndurer @ bash ~/Code $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

对于命令 read a,输入   //\c,存储到变量a的值为 //C,不包含反斜杠\。

对于命令 rread -r a,输入   //\c,存储到变量a的值为 //\C,包含反斜杠\。

2.10 -a 读取数组值

数组是最常用的一种数据结构,在之前的

Linux shell编程学习笔记15:定义数组、获取数组元素值和长度、数组拼接或合并_linux获取数组长度-CSDN博客https://blog.csdn.net/Purpleendurer/article/details/134009982

Linux shell编程学习笔记16:bash中的关联数组-CSDN博客https://blog.csdn.net/Purpleendurer/article/details/134053506中我们学习了Lininux Shell编程中的数组的定义和赋值的方法,其中对数组元素的赋值方法 ,我们主要介绍了在定义数组时同时进行初始化和定义数组后用赋值语句来赋值两种方法。

现在我们也可以用read命令来将用户输入的值存储到数组

例:从键盘读取输入存入数组a

purpleEndurer @ bash ~/Code $ read -a a
1 2 3
purpleEndurer @ bash ~/Code $ echo ${a[*]}
1 2 3
purpleEndurer @ bash ~/Code $ echo ${a[0]}
1
purpleEndurer @ bash ~/Code $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

i当我们输入 1 2 3,那么 a[0]=1,a[1]=2,a[2]=3

可惜的是,read命令不能将用户输入存储到关联数组

purpleEndurer @ bash ~/Code $ declare -A A
purpleEndurer @ bash ~/Code $ read -a A
a b c
bash: read: A: cannot convert associative to indexed array
purpleEndurer @ bash ~/Code $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

我们先用命令 声明一个关联数组A

然后用命令 来读取用户输入存储到关联数组A,但是出错了:bash: read: A: cannot convert associative to indexed array

2.11 -u指定文件说明符

例:将文件a.txt和b.txt的内容逐行拼接显示。

purpleEndurer @ bash ~ $ cp /dev/stdin a.txt
111
222
333
444
purpleEndurer @ bash ~ $ cp /dev/stdin b.txt
aaa
bbb
ccc
ddd
eee
purpleEndurer @ bash ~ $ while read -u3 i && read -u4 j;do echo $i $j; done 3<a.txt 4<b.txt
111 aaa
222 bbb
333 ccc
444 ddd
purpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

如果我们希望在每一行前显示行号,那么我们可以增加一个变量n用来记录当前行数:

purpleEndurer @ bash ~ $ n=1;while read -u3 i && read -u4 j;do echo Line $n:  $i $j;n=$[ $n + 1 ];  done 3<a.txt 4<b.txt
Line 1: 111 aaa
Line 2: 222 bbb
Line 3: 333 ccc
Line 4: 444 ddd
purpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

2.12 -i 使用初始值

例 提示用户输入用户名 存储到变量a中,用户名初始值为 Anonymous

PurpleEndurer @ bash ~ $ read -p 'Enter your name:' -i 'Anonymous' a 
Enter your name:
PurpleEndurer @ bash ~ $ echo $a

PurpleEndurer @ bash ~ $ read -p 'Enter your name:' -i 'Anonymous' -e a 
Enter your name:Anonymous
PurpleEndurer @ bash ~ $ echo $a
Anonymous
PurpleEndurer @ bash ~ $ read -p 'Enter your name:' -i 'Anonymous' -e a 
Enter your name:abc
PurpleEndurer @ bash ~ $ echo $a
abc
PurpleEndurer @ bash ~ $ 

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

linux shell bash read,Linux世界,编程资料,麒麟操作系统,linux,脚本编程,linux脚本,学习笔记,read命令,数组,文件说明符

在执行 命令  read -p 'Enter your name:' -i 'Anonymous' a  时,虽然我们使用 -i  'Anonymous'选项,但执行时并没有显示初始值 Anonymous,我们直接回车,变量a的值为空

在执行 命令  read -p 'Enter your name:' -i 'Anonymous' -e a   时,我们在上面的命令中增加了 -e选项,在执行时就显示出初始值 Anonymous,我们直接回车,变量a的值为就为 Anonymous

在执行 命令  read -p 'Enter your name:' -i 'Anonymous' -e a   时,我们在上面的命令中增加了 -e选项,在执行时就显示出初始值 Anonymous,我们按删除键Backspace删除 Anonymous,输入abc回车,变量a的值为abc文章来源地址https://www.toymoban.com/news/detail-760771.html

到了这里,关于Linux shell编程学习笔记36:read命令的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Linux shell编程学习笔记39:df命令

    0 前言 1  df命令的功能、格式和选项说明 1.1 df命令的功能 1.2 df命令的格式 1.3 df命令选项说明  2 df命令使用实例  2.1  df:显示主要文件系统信息 2.2 df -a:显示所有文件系统信息 2.3 df -t[=]TYPE或--type[=]TYPE:显示TYPE指定类型的文件系统信息 2.4 df --total:追加显示统计信息 2

    2024年01月16日
    浏览(44)
  • Linux shell编程学习笔记45:uname命令-获取Linux系统信息

    linux 有多个发行版本,不同的版本都有自己的版本号。 如何知道自己使用的Linux的系统信息呢? 使用uname命令、hostnamectl命令,或者通过查看/proc/version文件来了解这些信息。 我们先看看uname命令。 我们可以使用命令 uname --help命令 查看它的用法: purpleEndurer @  bash ~ $ uname --

    2024年04月10日
    浏览(48)
  • Linux shell编程学习笔记37:readarray命令和mapfile命令

      目录   0 前言 1  readarray命令的格式和功能 1.1 命令格式 1.2 命令功能 1.3 注意事项 2 命令应用实例 2.1 从标准输入读取数据时不指定数组名,则数据会保存到MAPFILE数组中 2.2 从标准输入读取数据并存储到指定的数组 2.3 使用 -O 选项指定起始下标 2.4 用-n指定有效行数 2.5 

    2024年02月03日
    浏览(39)
  • Linux和Shell笔记-2基本的bash shell命令

    与windows前面标明盘符不同,Linux采用了将文件存储在单个目录结构中,这个目录被称为 虚拟目录 。 Linux使用正斜线( / )而不是反斜线( ) 在文件路径中划分目录。Linux中反斜线用来标识转义字符,因此不能用在文件路径里,这一点和windows不同。 常用的目录名称以及功能介绍

    2024年02月16日
    浏览(37)
  • Linux shell编程学习笔记6:查看和设置变量的常用命令

    上节我们介绍了变量的变量命名规则、变量类型、使用变量时要注意的事项,今天我们学习一下查看和设置变量的一些常用命令,包括变量的提升,有些命令在之前的实例中已经使用过了。 语法格式:echo [参数] [输出内容] 常用参数: -e:支持反斜线控制的字符转换(具体参

    2024年02月07日
    浏览(34)
  • Linux shell编程学习笔记31:alias 和 unalias 操作 命令别名

    目录 0 前言 1 定义别名 2 查看别名 2.1 查看所有别名 2.2 查看某个别名 2.2.1  alias 别名 2.2.2 alias | grep 别名字符串 2.2.3 使用 Ctrl+Alt+E 组合键 3 unalias:删除别名 4 如何执行命令本身而非别名 4.1 方法1:使用 Ctrl+Alt+E 组合键  unalias 4.2 方法2:在命令前加上命令文件的绝对路径

    2024年02月05日
    浏览(31)
  • Linux shell编程学习笔记46:awk命令的由来、功能、格式、选项说明、版权、版本

    在编写Linux Shell脚本的过程中,我们经常要对Linux命令执行的结果进行分析和提取,Linux也在文本分析和提取这方面提供了不少的命令。比如我们之前研究过的cut命令。 Linux shell编程学习笔记43:cut命令 https://blog.csdn.net/Purpleendurer/article/details/135730679?spm=1001.2014.3001.5501 除了cut命

    2024年04月24日
    浏览(57)
  • Linux之shell编程(BASH)

    Kernel Linux内核主要是为了和硬件打交道 Shell 命令解释器(command interperter) Shell是一个用C语言编写的程序,他是用户使用Linux的桥梁。Shell既是一种命令语言,又是一种程序设计语言。 Shell是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核

    2024年01月18日
    浏览(26)
  • 【Linux | Shell】bash shell 基础命令

    很多 Linux 发行版的默认 shell 是 GNU bash shell。本文将介绍 bash shell 的基本特性,比如 bash 手册、命令行补全以及如何显示文件内容等。 GNU bash shell 是一个程序,提供了对 Linux 系统的交互式访问。它是作为普通程序运行的,通常是在用户登录终端时启动。系统启动的 shell 程序

    2024年02月11日
    浏览(45)
  • 【Linux | Shell命令】bash shell 进程、磁盘、文件处理命令

    上篇文章 bash shell 基础命令 中,介绍了一些与目录、文件相关的 shell 命令,本文继续介绍其他与进程、磁盘、排序、归档相关的命令,读者可以在自己的Linux系统下,实操这些命令,进而收悉并掌握这些命令。本文是一篇学习笔记,很多内容是参考了《Linux命令行与shell脚本

    2024年02月11日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包