1.运算器、控制器、存储器、输入输出(IO)
地址总线:内存寻址
数据总线:传输数据
控制总线:控制指令
寄存器:cpu暂时存储器
2.系统设定
默认输出设备:标准输出,STDOUT,1(描述符)(显示器)
默认输入设备:标准输入,STDIN ,0 (通常是键盘)
标准错误输出:STDERR ,2 (显示器)
I/O重定向:
linux 输出重定向 >
linux 输入重定向 <
[[email protected] eric ~]# ls /etc > /tmp/list.out (覆盖输出) ls /etc >> /tmp/list.out (追加输出) [[email protected] eric ~]# cat /tmp/list.out abrt acpi adjtime aliases aliases.db
set -C 禁止对已经存在文件使用覆盖重定向,,,强制覆盖输出,则使用>|
set + 关闭上述功能
2> 重定向错误输出
2>> 追加错误输出
$>: 重定向标准输出或错误输出至同一个文件
输入重定向
tr - translate or delete characters [[email protected] eric ~]# tr ‘a-z‘ ‘A-Z‘ abc ABC ^C [[email protected] eric ~]# tr ‘a-z‘ ‘A-Z‘ < /etc/fstab # # /ETC/FSTAB # CREATED BY ANACONDA ON FRI MAY 5 10:01:37 2017 # # ACCESSIBLE FILESYSTEMS, BY REFERENCE, ARE MAINTAINED UNDER ‘/DEV/DISK‘ # SEE MAN PAGES FSTAB(5), FINDFS(8), MOUNT(8) AND/OR BLKID(8) FOR MORE INFO # UUID=91097F07-DAE0-4891-A853-8D0526E0A12B / EXT4 DEFAULTS 1 1 UUID=0B9CD9FC-D21E-44D3-B755-DF2DD4C9A9F9 /BOOT EXT4 DEFAULTS 1 2 UUID=225B2FF3-A0F2-4CFE-B23F-C3314610E775 SWAP SWAP DEFAULTS 0 0 TMPFS /DEV/SHM TMPFS DEFAULTS 0 0 DEVPTS /DEV/PTS DEVPTS GID=5,MODE=620 0 0 SYSFS /SYS SYSFS DEFAULTS 0 0 PROC /PROC PROC DEFAULTS 0 0 [[email protected] eric ~]#
[[email protected] eric ~]# cat <<END(结束符) > The first line > The Second line > END The first line The Second line [[email protected] eric ~]# cat >> /tmp/myfile.txt <<EOF(End of Line) > hello > my dear > EOF [[email protected] eric ~]# cat /tmp/myfile.txt hello my dear [[email protected] eric ~]#
管道:(从一端输入东西,从另一端出来)命令也可以使用管道
命令1 | 命令2 | 命令3 |...前一个命令的输出作为后一个命令的输入
[[email protected] eric ~]# echo ‘hello‘ | tr ‘a-z‘ ‘A-Z‘ HELLO [[email protected] eric ~]# echo ‘redhat‘|passwd --stdin hive passwd: Unknown user name ‘hive‘. [[email protected] eric ~]# echo ‘redhat‘|passwd --stdin cjy Changing password for user cjy. passwd: all authentication tokens updated successfully. [[email protected] eric ~]# cut -d: f1 /etc/passwd |sort cut: you must specify a list of bytes, characters, or fields Try `cut --help‘ for more information. [[email protected] eric ~]# cut -d: -f1 /etc/passwd |sort abrt adm apache avahi-autoipd bin cjy daemon
[[email protected] eric ~]# wc -l /etc/passwd 36 /etc/passwd [[email protected] eric ~]# wc -l /etc/passwd | cut -d‘ ‘ -f1 36 [[email protected] eric ~]#
tee: - read from standard input and write to
standard output and files
时间: 2024-10-24 21:25:51