17
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UNIXコマンドで、sortでファイルを上書きする

Posted at

最初は

sort -u hoge > hoge

sort hoge | uniq > hoge

とかでトライしたのですが、だめです。sortコマンドより先に、'> hoge'でファイルが上書きされてしまうようで、結果、hogeは空になってしまいます。

以下の方法で、上手くいきました。

sort -u hoge -o hoge

# -o, --output=FILE         write result to FILE instead of standard output
17
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?