如何编号UNIX中的LS输出? [英] How to number the ls output in unix?
本文介绍了如何编号UNIX中的LS输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写与格式的文件 - ID file_absolute_path这基本上递归列出了所有的文件夹中,并给予一个标识符1,2,3,4列出的每个文件。
I am trying to write a file with format - "id file_absolute_path" which basically lists down all the files recursively in a folder and give an identifier to each file listed like 1,2,3,4.
我可以递归使用以下命令获取文件的绝对路径:
I can get the absolute path of the files recursively using the following command:
ls -d -1 $PWD/**/*/*
不过,我无法给从ls命令的输出的标识符。我相信这可以用awk来完成,但似乎无法来解决这个问题。
However, I am unable to give an identifier from the output of the ls command. I am sure this can be done using awk, but can't seem to solve it.
推荐答案
通过管道猫输出-n
。
这篇关于如何编号UNIX中的LS输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文