LoginSignup
16
7

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
16
7
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
16
7