LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-07-2005, 11:50 AM   #1
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-19-live-usb/ aix
Posts: 3,840

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
trim a line


hi lq,

i have a line of text like:
Code:
hello my name is simon. and i like to do drawings.
i always want to trim out byte position 9 - 13 (name) and 17 - 22 (simon).

how do i do it in 'c' or bash or awk.

thanks,
 
Old 10-07-2005, 12:16 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Ok, you want to trim "byte" positions... Is that an absolute requirement statement, or just extra description? I mean, will you want to remove byte positions 9-13 and 17-22 everytime, or were they just used to reinforce the location of "name" and "simon"?

If you want to trim those positions everytime, then you can use cut:
Code:
$ echo "hello my name is simon. and i like to do drawings." | cut -c 0-8,14-16,23-
hello my is. and i like to do drawings.
If it's word position you're after:
Code:
$ echo "hello my name is simon. and i like to do drawings." | cut -f 1,2,4,6- -d' '
hello my is. and i like to do drawings.

Last edited by Dark_Helmet; 10-07-2005 at 12:18 PM.
 
Old 10-07-2005, 06:47 PM   #3
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-19-live-usb/ aix
Posts: 3,840

Original Poster
Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
'cut', bonne idée

thanks helmet
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Problem on trim command k1ll3r_x Programming 2 09-12-2005 03:49 PM
I want to trim Linux distribution qadria Linux - Software 7 08-08-2005 07:45 AM
vim: mark end-of-line? trim blank lines? prell Linux - Software 3 09-20-2004 11:04 PM
How to Trim mpeg video's ? qwijibow Linux - Software 1 01-06-2004 08:28 PM
How can I safely trim down /dev ? tigermusti Linux - General 9 12-12-2002 04:33 PM


All times are GMT -5. The time now is 09:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration