Sorting and outputting in another file

332

To sort Names.txt in a reverse sort order and output it into SortedNames.txt:

sort -r Names.txt > SortedNames.txt

The file SortedNames.txt does not have to exist. If it does exist and you have write-permission to that file, the command above will overwrite its contents.

The sort command has many more options.

Share:
332

Related videos on Youtube

drbernardi
Author by

drbernardi

Updated on September 18, 2022

Comments

  • drbernardi
    drbernardi over 1 year

    I'm a novice at regex and can't find a way to do this easily. I'd like to delete every word that isn't starting with # and put a comma between them, so for example if I have:

    Cookie Recipe for n00bs
    #cookie #recipe #chocolate To do this you have to etc...
    Bla bla bla mumbo jumbo
    

    I'd like to get as a result:

    cookie, recipe, chocolate
    

    If you could help me it'd be great, thanks and have a good day!

    • Casimir et Hippolyte
      Casimir et Hippolyte over 9 years
      instead of deleting all the words not preceded with a #, why you don't try to match words preceded with a #?
    • Casimir et Hippolyte
      Casimir et Hippolyte over 9 years
      What language/tool do you use?
    • drbernardi
      drbernardi over 9 years
      I'm trying to use this in a Find and Replace context.I'm creating a Keyboard Maestro Macro which filters the clipboard following this Find and Replace rule. I don't know of a way to only copy the matched Find.