[20231207]ls f的显示问题.txt

[20231207]ls -f的显示问题.txt

--//在执行ls -f时遇到一些问题,不理解做一个记录。

$ cd /u01/testrm
$ touch 1.aud 2.aud 3.aud
$ ls -f
.  ..  1.aud  2.aud  3.aud

--//注意显示横着显示文件名。

$ ls -f|head
.
..
1.aud
2.aud
3.aud
--//为什么加入管道|后head显示变成竖着显示呢?
$ ls -f >| /tmp/zz1.txt
$ cat /tmp/zz1.txt
.
..
1.aud
2.aud
3.aud
--//也是竖着显示。

$ ls -f | head >| /tmp/zz2.txt
$ cat /tmp/zz2.txt
.
..
1.aud
2.aud
3.aud
--//似乎只要经过管道就变成竖着显示,不知道如何实现这个特性的。

--//查看man ls文档:
-f    do not sort, enable -aU, disable -lst

-a, --all
       do not ignore entries starting with .

-U     do not sort; list entries in directory order.  In combination with one_per_line format '-1', it will show files
       immediately and it has no memory limitations.

--//排除别名影响:
$ /bin/ls -f
.  ..  1.aud  2.aud  3.aud

$ /bin/ls -f | head
.
..
1.aud
2.aud
3.aud
--//还是一样。

--//实际上不排序单行显示,不包括. 和 ..,执行如下:
$ ls -1U
1.aud
2.aud
3.aud

--//不理解,做一个记录。