实验楼学习笔记--linux

##  基础命令2

#echo "input a text" | tr '[a-z]' '[A-Z]'              #标准输入小写转换为大写输出

#col 命令可以将Tab换成对等数量的空格键,或反转这个操作。

# 查看 /etc/protocols 中的不可见字符,可以看到很多 ^I ,这其实就是 Tab 转义成可见字符的符号

$ cat -A /etc/protocols # 使用 col -x 将 /etc/protocols 中的 Tab 转换为空格,然后再使用 cat 查看,你发现 ^I 不见了

$ cat /etc/protocols | col -x | cat -A

$ cd /home/shiyanlou # 创建两个文件

$ echo '1 hello' > file1

$ echo '1 shiyanlou' > file2

$ join file1 file2 # 将/etc/passwd与/etc/shadow两个文件合并,指定以':'作为分隔符

$ sudo join -t':' /etc/passwd /etc/shadow# 将/etc/passwd与/etc/group两个文件合并,指定以':'作为分隔符, 分别比对第4和第3个字段

$ sudo join -t':' -1 4 /etc/passwd -2 3 /etc/group

paste这个命令与join 命令类似,它是在不对比数据的情况下,简单地将多个文件合并一起,以Tab隔开。

$ echo hello > file1

$ echo shiyanlou > file2

$ echo www.shiyanlou.com > file3

$ paste -d ':' file1 file2 file3

$ paste -s file1 file2 file3

猜你喜欢

转载自www.cnblogs.com/gzhm/p/12175432.html