Find the answer to your Linux question:
Results 1 to 6 of 6
I need to edit a word in a file in the terminal.What do you type so you can read the text?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! elfshadow14's Avatar
    Join Date
    Jul 2006
    Posts
    38

    What the command?


    I need to edit a word in a file in the terminal.What do you type so you can read the text?

  2. #2
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    There are lots of commands you can use. You said you wanted to be able to edit a file, so you'll probably find these available on your system:

    Code:
    nano somefile.txt
    pico somefile.txt
    emacs somefile.txt
    vi somefile.txt
    Just a warning: emacs and vi are not very easy programs to just jump into. They require some work to understand. If you ever need to just view a file from the command line you can use cat. The problem you'll more than likely run into with cat is that it spews out the whole file without letting you pause and look at a particular line, so most of the time I use cat along with another utility, less, which allows me to scroll up and down through the file and only displays one page of information at a time.

    Code:
    cat somefile.txt | less
    Registered Linux user #270181
    TechieMoe's Tech Rants

  3. #3
    Just Joined! Forsinain's Avatar
    Join Date
    Jul 2006
    Location
    Sweden
    Posts
    21
    Code:
    # cat filename.txt
    If you want to read the text.

    To edit it you will need an editor. Common console based editors are 'nano', 'vi', 'vim' and 'emacs'. To run these you use:
    Code:
    # programname filename.txt
    If you don't have an editor at all on the computer (even though this is very rare and you are more likely to have another editor than those mentioned above) there you can use the following commands on many systems to edit a file:
    Code:
    # cat <<EOF> filename.txt
    And then enter all the lines of the file again with the changes you would like to make. When you are done you only have to add a line that onlu conatains 'EOF' to end the editing of the file. If you only want to add lines to the end of the file you can use
    Code:
    # cat <<EOF>> filename.txt
    and only enter those lines you want at the end of the file end then stop the editing with a 'EOF' line.

    EDIT: I was too late....

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Pennsylvania
    Posts
    102
    you can also use gedit (if you have gnome desktop)

    sudo gedit <enter filename here>

    ***note*** sudo is only required if you need root access to edit the file (such as grub)

  6. #5
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    Also, if cat isn't feasible because the file's too big, less would probably be a better choice.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  7. #6
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    Here's that whole fish/fishing thing - a great command is apropos. If you run that it's like a search engine for commands. It will return man entries for commands that may be relevant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •