2

This question already has an answer here:

I am trying to learn all I can about the cat command. I am going to be using it for its light weight performance and its ability to work in nothing but a command line.

I know it can create a text file and read it with quite a few perks but I cant figure out how to edit an already existing one.

There is a similar question to this (What is 'cat' used for?) but it doesn't say were the limits are for the cat command.

If anyone has any advice or know some good sources to learn this stuff from I would greatly appreciate it.

Thank you.

marked as duplicate by muru command-line Jan 3 '18 at 8:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    not cat, beware of cat abuse - dslreports.com/forum/r21664624-Do-You-Abuse-the-cat . For editing use sed grymoire.com/Unix/Sed.html . You might also like awk, perl, more, and less – Panther Jan 3 '18 at 5:02
  • 1
    For editing, you probably want to use something like nano to begin with. If you want to be non-interactive, use ed. – fkraiem Jan 3 '18 at 5:06
  • 1
    The question "What is 'cat' used for?" didn't say anything about editing and I was wondering if its possible. – SomeBloke Jan 3 '18 at 23:10
  • 1
    Hi, SomeBloke, cat can't be used for editing. – pa4080 Jan 4 '18 at 22:31
  • 2
    The answers to the linked question are exhaustive as to the capabilities of cat, as far as I can tell. Since "editing" is not listed, you can conclude that it's impossible to edit a file with cat (alone). I'm voting to keep this question closed. – David Foerster Jan 4 '18 at 23:17
3

If you want to edit interactively, use for example nano, otherwise you can use the stream editor sed.

You can find several good tutorials via the internet (with examples how to use them). When you have more experience you will find the man pages useful:

man nano

and

man sed

but in the beginning the tutorials are better.

I find several good tutorials with the following search strings

  • nano tutorial

  • sed tutorial

I suggest that you start working with a tutorial that fits what you need.

Not the answer you're looking for? Browse other questions tagged or ask your own question.