LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-11-2003, 04:47 AM   #1
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Rep: Reputation: 30
Removing a preceding pattern from each sentence


I have sentences in the form:

> hello world
> this sentence can be long as well

How can i remove the ">" symbols from the sentences, assuming that you do not know the pattern of the sentence nor how many words it has??

Using awk -F" " '{print $1 $2 .... $N}' doesn't seem to be the correct solution... Do you know of some fool-proof solution for this problem?


thanks, ganninu.
 
Old 12-11-2003, 07:49 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Hi ganninu!

use the full field, $0, and substr.

awk '{print substr($0,2,length($0))}'

I'd imagine you could use 'sed' as well, something like...

sed 's/^>//'

John
 
Old 12-11-2003, 08:15 AM   #3
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
cool
 
  


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
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 07:17 AM
What does this sentence mean? shadkong Slackware 9 04-07-2005 07:42 AM
Apache directory preceding domain in url MasterC Linux - Networking 9 03-14-2005 07:32 AM
Removing Text in a single line starting with one pattern ending on another mgwheeler Programming 13 08-03-2004 05:36 PM
I Think M$ has the order of this sentence Mixed up, don't you think! ;) shassouneh General 14 06-02-2002 08:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:42 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration