本文旨在通过不同预言实现linux shell下的ls命令功能。
1、python 源码实现
import os
def ls(path):
'ls funciton'
for root,dirs,files in os.walk(path):
for dir_name in dirs:
print os.path.join(root,dir_name)
for file_name in files:
print os.path.join(root,file_name)
return 0
(1)os.walk()函数介绍及使用说明:
https://www.runoob.com/python/os-walk.html
(2)os.path.join()函数介绍及使用说明
https://www.runoob.com/python/os-file-methods.html
2、linux c源码实现
待提交源码。