当我执行
echo `man ls` > tem.txt
我在文本文件中得到了未格式化的输出,我的意思是输出没有任何新行,只是继续句子。如何获取格式化的输出?
例如,未格式化的输出如下所示:
LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls
[OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the
current directory by default). Sort entries alphabetically if none of -
cftuvSUX nor --sort is speci‐ fied. Mandatory arguments to long options are
mandatory for short options too. -a.................
您无需man
通过流程替换来强制的输出。重定向可以正常工作:
man ls > tem.txt
即使您使用进程替换,也请记住使用引号,否则输出将经历来自shell的split + globing:
echo "$(man ls)" > tem.txt
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句