• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives
  • Sources
  • Search

Search

Bash Sort Files

April 10, 2023

How to sort files in Bash.

Display contents

$ cat file.txt
bbb
aaa
ccc
kkk
uuu
ppp

Sort

$ sort file.txt
aaa
bbb
ccc
kkk
ppp
uuu

Sort in place

$ sort -o file.txt file.txt
$ cat file.txt
aaa
bbb
ccc
kkk
ppp
uuu

Filed Under: Linux Tagged With: bash, file, sort

  • Home
  • About
  • Archives
  • Sources
  • Search

Copyright © 2023