Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
Hi guys... noob here Can anyone help me with the following: using the command line i would like to edit a file containing text eg.. 1122334455667788 to 11 22 33 ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6

    help with editing text

    Hi guys... noob here

    Can anyone help me with the following:

    using the command line i would like to edit a file containing text eg.. 1122334455667788 to 11 22 33 44 55 66 77 88, and maybe insert text too.

    ive looked at vi, but im confused.

    thanks in advance,
    blades.

  2. #2
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,095
    Welcome to the forums, blades!

    You might take a look at using nano. It's easier to use for most folks that are new to the Linux command line.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6
    thanks ozar,
    I havent looked at nano.. because its not a command available to me to use.
    Im using a 'dreambox' linux satellite receiver.. and the commands installed on it are limited.

    attached are the commands i have at my disposal
    Attached Images Attached Images

  4. #4
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,095
    Sorry, but that image is too small to read on this end.

    If you want to use vi, just press the letter "i" after you've opened the file and that will put you into insert mode. You can edit your file, then when ready to exit, press ESC to exit insert mode, then :wq (all three characters) to write, quit, and save the file.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  5. #5
    Just Joined!
    Join Date
    Aug 2007
    Posts
    2
    Hi...

    Try this sed command:

    sed -i 's/\([0-9]\{2\}\)/&\ /g' file.txt

    This will group similar numbers together and separate other groups with a space. So, if your file.txt contains the following text
    1122334455667788
    After running the above command, it will replace the file contents to
    11 22 33 44 55 66 77 88

    check it out...

  6. #6
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,095
    blades, is this a homework/classwork question?
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  7. #7
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6
    Quote Originally Posted by ozar View Post
    Sorry, but that image is too small to read on this end.
    sorry.. the forum must have shrunk it


  8. #8
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6
    Quote Originally Posted by roshalways View Post
    Hi...

    Try this sed command:

    sed -i 's/\([0-9]\{2\}\)/&\ /g' file.txt

    This will group similar numbers together and separate other groups with a space. So, if your file.txt contains the following text
    1122334455667788
    After running the above command, it will replace the file contents to
    11 22 33 44 55 66 77 88

    check it out...
    thanks, but, the text file may not contain similar numbers... could be anything, but most probably hexidecimal

  9. #9
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6
    Quote Originally Posted by ozar View Post
    blades, is this a homework/classwork question?
    Neither.. im just playing.

  10. #10
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Well, we need to decide how you want to do this. Are you looking for a text editor, where you go in and manually make changes? Or are you looking for a programmatic solution, where you use some sort of command to do it for you?

    If the former, vi is a commandline editor that is available on every UNIX system. It also probably has the steepest learning curve of any program you will ever use in Linux. Try running the 'vimtutor' command from the terminal. If the command exists, this will put you into a tutorial for Vim (the version of vi that is pretty much universal these days). Alternatively, you can try some online tutorial. I found one that may work:
    paper
    (ignore 1.1)

    I don't know of any great vi tutorial (I learned the editor just by messing with it and using vimtutor), but maybe someone else will know.


    If you're looking for a programmatic solution, this is where the fun part comes in. It depends a great deal on what the data is, and how it is formatted. If you can explain the problem a bit more, it may be easier to solve.
    DISTRO=Arch
    Registered Linux User #388732

Page 1 of 2 1 2 LastLast

Posting Permissions

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