linux 中列出所有文件名的前缀
1、
root@PC1:/home/test2# ls a.txt dir.1 test.csv test.ped root@PC1:/home/test2# ls -l total 8 -rw-r--r-- 1 root root 64 1月 21 23:14 a.txt drwxr-xr-x 2 root root 4096 1月 21 23:35 dir.1 -rw-r--r-- 1 root root 0 1月 21 23:35 test.csv -rw-r--r-- 1 root root 0 1月 21 23:35 test.ped root@PC1:/home/test2# ls -l | awk '{n=index($9,".")} {if($1!~/^[dt]/) print substr($9,1,n-1)}' ## 列出所有文件的前缀 a test test