Find the answer to your Linux question:
Results 1 to 4 of 4
1) How to print section of file beginning from 63 character and ending 127 character? 2) How to delete section of file beginning from 63 character and ending 127 character? ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3

    Unhappy several questions of using "sed"...

    1) How to print section of file beginning from 63 character and ending 127 character?

    2) How to delete section of file beginning from 63 character and ending 127 character?

    3) How to print section of file beginning from 63 character and ending by character of "end of line"?

  2. #2
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3

    use head and tail, not sed

    look at the man pages for head and tail. you should be able to accomplish what you want with simple pipelines using those utilities.

    BB

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3
    Quote Originally Posted by bronxbuoy View Post
    look at the man pages for head and tail. you should be able to accomplish what you want with simple pipelines using those utilities.

    BB
    But i don't want to use those utilities - i need to solve this task using sed or awk only I think it's really close to find the way!
    p.s. i'v read man pages of head and tail and can say, that there is not possible to do my task with them.

  4. #4
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3

    no problem with awk

    Actually head and tail wouldn't help with #3 but you can do all three with awk. As you process lines get the number of bytes in each line with length($0). You should have no trouble identifing the bytes greater than the starting offset and less than the ending offset. You will need some other bookkeeping and you will need to use substr() to print or capture what you want.

    BB

Posting Permissions

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