使用猫输出垃圾输出
我有一个包含文件路径的文件,我想将所有路径和文件的内容写入新文件。
我的脚本:(
rm -f answer.txt
touch answer.txt
while IFS= read -r path; do
echo $path >>answer.txt # path
cat $path >>answer.txt # content
printf '\n--------\n' >> answer.txt
done < ./files_paths.txt #the file that contains the paths
路径文件看起来像这样)
/atc/ld.so.cache
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
... more paths
(我希望答案.txt看起来像)
/atc/ld.so.cache #path
1HAajfj # content
------
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
asd5446
------
...
我的问题是,在TXT文件的开头,我有大量的垃圾行。 所有垃圾之后,我得到了我想要的。
I have a file that contains paths to files, and I want to write to a new file all the paths and the content of the files they lead to.
my script:
rm -f answer.txt
touch answer.txt
while IFS= read -r path; do
echo $path >>answer.txt # path
cat $path >>answer.txt # content
printf '\n--------\n' >> answer.txt
done < ./files_paths.txt #the file that contains the paths
(the paths file looks like this)
/atc/ld.so.cache
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
... more paths
(I want the answer.txt to look like)
/atc/ld.so.cache #path
1HAajfj # content
------
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
asd5446
------
...
My problem is that in the beginning of the txt file, I have tons of lines of garbage.
After all the garbage, I get what I want.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论