2

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.

SomeBloke
  • 286
  • 2
  • 4
  • 11
  • 2
    not cat, beware of cat abuse - http://www.dslreports.com/forum/r21664624-Do-You-Abuse-the-cat . For editing use sed http://www.grymoire.com/Unix/Sed.html . You might also like awk, perl, more, and less – Panther Jan 03 '18 at 05: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 03 '18 at 05:06
  • 1
    The question "What is 'cat' used for?" didn't say anything about editing and I was wondering if its possible. – SomeBloke Jan 03 '18 at 23:10
  • 1
    Hi, SomeBloke, `cat` can't be used for editing. – pa4080 Jan 04 '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 04 '18 at 23:17
  • @SomeBloke, here is another way for file creation with `cat` and shell redirection: https://askubuntu.com/a/992533/566421 – pa4080 Jan 05 '18 at 08:43
  • Geany is also an excellent editor. – fixit7 Mar 28 '19 at 20:07

1 Answers1

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.

sudodus
  • 45,126
  • 5
  • 87
  • 151