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.
我正在尝试删除文件中的最后一行。我可以使用
sed '$d' 1 > 2 && cp 2 1
有人可以告诉我一个更有效的实施。我能够使用读、写和复制来完成我的任务。是否可以仅使用一次读取和一次写入操作来执行此操作。
无需使用两个命令。使用sed的就地编辑:
sed
sed -i '$d' 1