Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们如何将命令附加到文件的第一行?例如显示日期的命令?提前感谢您的回答
在不覆盖文件的情况下,不可能直接添加到文件中。
这可能对您有用。
mv file1.txt file1.txt.tmp # Move file temporarily date > file1.txt # Add your command cat file1.txt.tmp >> file1.txt # Append original content rm file1.txt.tmp # Remove temporary file