进入想要查看的目录
root@ubuntu20:/# ls
bin boot cdrom dev etc home lib lib32 lib64 libx32 lost+found media mmkv.default mmkv.default.crc mnt opt path proc root run sbin snap srv swapfile sys tmp usr var
执行命令
ls -d */ | tr -d '/' > dir.txt
查看结果
root@ubuntu20:/# cat dir.txt
bin
boot
cdrom
dev
etc
home
lib
lib32
lib64
libx32
lost+found
media
mnt
opt
path
proc
root
run
sbin
snap
srv
sys
tmp
usr
var