我想在 Docker 映像中安装一个命令行工具,以便快速将 *html 文件转换为 *pdf 文件。
我很惊讶没有一个 Unix 工具来做这样的事情。
我正在通过子集设置文件名grep
,然后将生成的文件与cat
. 但是,对于如何使用 for 语句,我仍然有些困惑,例如for ((i=1;i<23;i+=1));
鉴于我的文件file1.txt
,我想 grepsample1
如下:
grep -w '^sample1' file1.txt > sample1_file.txt
grep -w '^sample2' file2.txt > sample2_file.txt
grep -w '^sample3' file3.txt > sample3_file.txt
....
grep -w '^sample22' file22.txt > sample22_file.txt
Run Code Online (Sandbox Code Playgroud)
然后连接这些:
cat sample1_file.txt sample2_file.txt sample3_file.txt ... sample22_file.txt > final_output.txt
Run Code Online (Sandbox Code Playgroud) 我的目标是测量 Linux 系统上每个文件的文件大小(以 MB 或 GB 为单位),递归地记录文件名和文件大小,并将输出通过管道传输到一个制表符分隔的文本文件中。
什么是合适的命令?
可以尝试这样的命令:
ls -lhR > outputfile.txt
Run Code Online (Sandbox Code Playgroud)
但我有理由认为这是非常低效的:
http://mywiki.wooledge.org/ParsingLs
使用 for 循环会更合适吗?
bash ×1
command-line ×1
conversion ×1
disk-usage ×1
html ×1
linux ×1
ls ×1
pdf ×1
shell-script ×1
size ×1
software-rec ×1