跪求 用Shell 脚本 实现 显示test目录的各文件和目录
目录 folder1 下面 有三个文件a.txt b.txt c.txt 有一个子目录 subfolder 和两个文件 d.txt e.txt
要求遍历folder1的全部目录输出结果
folder1 Directory File a.txt, File b.txt,File c.txt
subfolder Directory File d.txt, File e.txt
实验结果:
[root@localhost sh]# ./dir_file /tmp/python/
python_2 Directory : File 1.log File 2.log
python_3 Directory : File 3.log
/tmp/python/ Directory : File p File t.py File y.py
这样应该可以吧,试试看
Shell脚本遍历目录并批量修改文件并保存,有两种实现代码;
编写脚本文件实现:使用函数循环调用
#!/bin/bash不使用函数循环调用:
#/bin/bash1. tree command
2.
fun_call_back()实验了一下,是不是递归调用函数方法呀?可是最核心的那段算法呢?
追答cd $i中间这段让度娘给吃了?
追问可是输出格式不对呀,我自己实验了尝试字符串累加等,都没有成功按格式输出
追答其实重点是这样的
echo -n让echo不显示回车,然后
另外函数入口要输入tab缩进,这个就当留给你的乐趣了