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
誰かがより効率的な実装を教えてください。読み取り、書き込み、コピーを使用してタスクを実行できます。1回の読み取り操作と1回の書き込み操作のみを使用してこれを行うことは可能ですか?
2 つのコマンドを使用する必要はありません。sedのインプレース編集を使用します。
sed
sed -i '$d' 1