LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-23-2006, 12:21 PM   #16
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61

Last gasp for me.
Code:
sed '/.* A/,/TER/{/HET/d}' file.txt

or

sed '/^HET*/d' file.txt
 
Old 06-23-2006, 12:37 PM   #17
vidyashankara
Member
 
Registered: May 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by homey
Last gasp for me.
Code:
sed '/.* A/,/TER/{/HET/d}' file.txt

or

sed '/^HET*/d' file.txt

I figured out what the problem is.

SED looks for the start string more then once. Is there a way to limit SED to start looking and stop look just once?
 
Old 06-23-2006, 12:59 PM   #18
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
How about beginning with the first line?
Code:
sed -n "0,/^TER/p" file.txt
 
Old 06-23-2006, 01:12 PM   #19
vidyashankara
Member
 
Registered: May 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by spirit receiver
How about beginning with the first line?
Code:
sed -n "0,/^TER/p" file.txt
I have some text before " HETATM...............A " that i dont want to select.

The problem is after TER, there is another line with " HETATM...............A ", I dont want anything before " HETATM...............A " and after "TER". SED reads the lines after TER too. How do i avoid that?

This is my command right now

sed -n "/^ATOM\|HETA.................A/, /^TER/p"

It should read if the line starts with ATOM or HETA followed by 16 characters and then A.

The 16 characters can be anything...
 
Old 06-23-2006, 01:13 PM   #20
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Threads merged because they are essentially the same.
 
Old 06-23-2006, 01:16 PM   #21
vidyashankara
Member
 
Registered: May 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by XavierP
Threads merged because they are essentially the same.

is there a way to read just the first thread?
 
Old 06-23-2006, 01:22 PM   #22
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Code:
sed -ne '0,/^TER/ !d' -e '/^.\{14\}A/,$ p' file.txt
 
Old 06-23-2006, 01:32 PM   #23
vidyashankara
Member
 
Registered: May 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by spirit receiver
Code:
sed -ne '0,/^TER/ !d' -e '/^.\{14\}A/,$ p' file.txt
There is a complication to that. I am calling the command from PHP.

The file is in the following format

ATOM[or HETA] [14 random charaters] A
100 lines like this
TER

ATOM[or HETA] [14 random charaters] B
100 lines like this
TER

ATOM[or HETA] [14 random charaters] C
100 lines like this
TER

HETA [14 random charaters] A
100 lines like this
TER
HETA [14 random charaters] B
100 lines like this
TER

So i need to get A, B and C[Starting with ATOM or HETA] into seperate files. but i dont want the lines if the whole string starts only with HETA.

So i want
ATOM[or HETA] [14 random charaters] A
100 lines like this
TER

into A.txt

and
ATOM[or HETA] [14 random charaters] B
100 lines like this
TER

into B.txt

so the command should not have '0,/^TER/ !d' as it will count only A and not B or C.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MSDOS version for cat command frankie_DJ General 9 07-22-2005 08:08 AM
cat command for text files minm Linux - Newbie 5 07-03-2005 12:32 AM
cat command juanb Linux - Newbie 4 08-19-2004 11:14 AM
what are the limits to the 'cat' command? Frybyte Linux - General 12 04-22-2004 04:32 PM
cat Command Moeses Linux - General 1 06-20-2002 03:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration