索引节点inode表
- inode表中包含有关文件的诸多信息,如,文件类型,权限,链接数,文件大小等。
- inode表结构主要包括:Mode,Owner info,Size,Timestamps,直接块指针,间接块指针,双重间接块指针,三重间接块指针
liuyan@liuyan-virtual-machine:~$ ls
Desktop Downloads Pictures PycharmProjects Videos
Documents Music Public Templates
liuyan@liuyan-virtual-machine:~$ stat Desktop/
File: Desktop/
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 801h/2049d Inode: 1051918 Links: 4
Access: (0755/drwxr-xr-x) Uid: ( 1000/ liuyan) Gid: ( 1000/ liuyan)
Access: 2020-02-26 13:15:43.825957546 +0800
Modify: 2020-02-25 10:10:27.458940289 +0800
Change: 2020-02-25 10:10:27.458940289 +0800
Birth: -
硬链接与软链接
创建硬链接一般只需要“ln 文件名 链接名”即可。
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ls
fiile2 fiile3 fiile4 fiile5 practice yasuo ys.tar.zip
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ln fiile2 link
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ls
fiile2 fiile3 fiile4 fiile5 link practice yasuo ys.tar.zip
liuyan@liuyan-virtual-machine:~/Desktop/Text$ stat link fiile2
File: link
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 801h/2049d Inode: 1185223 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 1000/ liuyan) Gid: ( 1000/ liuyan)
Access: 2020-02-25 15:23:03.279428996 +0800
Modify: 2020-02-25 15:23:03.279428996 +0800
Change: 2020-02-26 17:56:40.673034239 +0800
Birth: -
File: fiile2
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 801h/2049d Inode: 1185223 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 1000/ liuyan) Gid: ( 1000/ liuyan)
Access: 2020-02-25 15:23:03.279428996 +0800
Modify: 2020-02-25 15:23:03.279428996 +0800
Change: 2020-02-26 17:56:40.673034239 +0800
Birth: -
但是硬链接仅仅是一个链接,几乎它的所有文件信息都是源于主文件,包括inode号;而软链接则不同,软链接有属于自己的Inode号,block大小。简单来说软链接较硬链接来说软链接更像是一个独立的个体。
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ln -s fiile2 slink
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ls
fiile2 fiile3 fiile4 fiile5 link practice slink yasuo ys.tar.zip
liuyan@liuyan-virtual-machine:~/Desktop/Text$ stat slink
File: slink -> fiile2
Size: 6 Blocks: 0 IO Block: 4096 symbolic link
Device: 801h/2049d Inode: 1185797 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ liuyan) Gid: ( 1000/ liuyan)
Access: 2020-02-26 18:03:26.655364106 +0800
Modify: 2020-02-26 18:03:25.219381515 +0800
Change: 2020-02-26 18:03:25.219381515 +0800
Birth: -
输入和输出
Linux系统给程序提供了三种I/O设备
标准输入 默认接受来自键盘的输入
标准输出 默认输出到终端
标准错误 默认输出到终端窗口
用户可根据自身需求利用符号“>"和”>>"来对文件进行重定向
“>" 可以把输出内容重定向到文件
”>>" 可以在原有内容基础上追加新内容
“&>” 覆盖重定向
“&>>” 追加重定向
liuyan@liuyan-virtual-machine:~/Desktop/Text$ la
fiile2 fiile3 fiile4 fiile5 link practice slink yasuo ys.tar.zip
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo "hello world" >file
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ls
fiile2 fiile3 fiile4 fiile5 file link practice slink yasuo ys.tar.zip
liuyan@liuyan-virtual-machine:~/Desktop/Text$ cat file
hello world
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo "世界那么大,我想去看看" >>file
liuyan@liuyan-virtual-machine:~/Desktop/Text$ cat file
hello world
世界那么大,我想去看看
tr命令
-c 取字符集补集
-d 删除所有符合条件的字符
-s 把所有重复字符以单独一个字符表示
-t 把所有符合条件的字符转换为要求字符
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo "aaaaabbbbbcccccdddddeeeee"|tr -s "abcde"
abcde
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo "afhjdhfjalk0524053065312"|tr "0-9" "a-j"
afhjdhfjalkafceafdagfdbc
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo "afhjdhfjalk0524053065312"|tr -d "0-9"
afhjdhfjalk
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo "afhjdhfjalk0524053065312"|tr -dc "0-9"
0524053065312liuyan@liuyan-virtual-machine:~/Desktop/Text$
除此之外,tr命令还可配合配合其他指令执行
liuyan@liuyan-virtual-machine:~/Desktop/Text$ cat file
qewrtyuio
hello world
世界那么大。我想去了看看
000005245645268545
SAFDFTHDUWISYHDJUWISK
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ls
fiile2 fiile3 fiile4 fiile5 file link practice slink yasuo ys.tar.zip
liuyan@liuyan-virtual-machine:~/Desktop/Text$ cat file|tr "0-9" "m" >file001
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ls
fiile2 fiile4 file link slink ys.tar.zip
fiile3 fiile5 file001 practice yasuo
liuyan@liuyan-virtual-machine:~/Desktop/Text$ cat file001
qewrtyuio
hello world
世界那么大。我想去了看看
mmmmmmmmmmmmmmmmmm
SAFDFTHDUWISYHDJUWISK
liuyan@liuyan-virtual-machine:~/Desktop/Text$
liuyan@liuyan-virtual-machine:~/Desktop/Text$ ls |tr -s " "
fiile2
fiile3
fiile4
fiile5
file
file001
link
practice
slink
yasuo
ys.tar.zip
liuyan@liuyan-virtual-machine:~/Desktop/Text$
管道
管道用符号“|”来表示,用来连接命令
命令1|命令2|命令3
例如,用Linux命令来求1到100的和
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo {1..100}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo {1..100}|tr " " "+"
1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100
liuyan@liuyan-virtual-machine:~/Desktop/Text$ echo {1..100}|tr " " "+"|bc
5050
liuyan@liuyan-virtual-machine:~/Desktop/Text$
转载:https://blog.csdn.net/qq_42452450/article/details/104521410
查看评论