The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract specific content from a file patrick87 Shell Programming and Scripting 22 4 Weeks Ago 12:08 AM
Shell script or command help to extract specific contents from a long list of content patrick87 Shell Programming and Scripting 2 10-07-2009 10:11 PM
Extract data into file with specific field specs criddel Shell Programming and Scripting 5 09-28-2009 02:54 PM
Extract data from log file from or after the specific date chiru_h Shell Programming and Scripting 5 04-21-2009 10:43 AM
extract specific data from xml format file. 60doses Shell Programming and Scripting 7 01-16-2008 03:26 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2009
patrick87 patrick87 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 110
Extract all the content after a specific data

My input:
>seq_1
DSASSTRRARRRRTPRTPSLRSRRSDVTCS
>seq_3
RMRLRRWRKSCSERS*RRSN
>seq_8
RTTGLSERPRLPTTASRSISSRWTR
>seq_10
NELPLEKGSLDSISIE
>seq_9
PNQGDAREPQAHLPRRQGPRDRPLQAYA+
QVQHRRHDHSRTQH*LCRRRQREDCDRLHR
>seq_4
DRGKGQAGCRRPQEGEALVRRCS>seq_6
FA*GLAAQDGEA*SGRG

My output: Extract all the data after seq_3:
>seq_8
RTTGLSERPRLPTTASRSISSRWTR
>seq_10
NELPLEKGSLDSISIE
>seq_9
PNQGDAREPQAHLPRRQGPRDRPLQAYA+
QVQHRRHDHSRTQH*LCRRRQREDCDRLHR
>seq_4
DRGKGQAGCRRPQEGEALVRRCS>seq_6
FA*GLAAQDGEA*SGRG

Does anybody got the idea to get my desired output?
It seems like awk and sed able to do it.
But I not very sure how to solve it out.
Thanks a lot for all of your advice
  #2 (permalink)  
Old 11-02-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,560
you had previous posts similar to this. so i expect you to already have some code. show it.
  #3 (permalink)  
Old 11-02-2009
ahmad.diab's Avatar
ahmad.diab ahmad.diab is offline
Registered User
  
 

Join Date: May 2008
Location: Amman Jordan in MEA
Posts: 250
code


Code:
sed -n '/seq_8/,$ {
p
} 'file.txt > out_file


Last edited by ahmad.diab; 11-02-2009 at 05:16 AM..
  #4 (permalink)  
Old 11-02-2009
patrick87 patrick87 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 110
Thanks a lot, it is worked perfectly
  #5 (permalink)  
Old 4 Weeks Ago
patrick87 patrick87 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 110
Hi,
I just found out that the code that you suggested also will print out the content of seq_81,seq_800,etc
Do you have any idea just only specific and only print out the content that matched with seq_8?
Thanks a lot ^^
  #6 (permalink)  
Old 4 Weeks Ago
ahmad.diab's Avatar
ahmad.diab ahmad.diab is offline
Registered User
  
 

Join Date: May 2008
Location: Amman Jordan in MEA
Posts: 250
Quote:
Originally Posted by patrick87 View Post
Hi,
I just found out that the code that you suggested also will print out the content of seq_81,seq_800,etc
Do you have any idea just only specific and only print out the content that matched with seq_8?
Thanks a lot ^^

easily you can put ur string inside this "\<\>" and you will get the exact pattern you want.



Code:
sed -n '/\<seq_8\>/,$ {
p
} ' file.txt > out_file

above you will get seq_8 only if you want seq_80 do this:
sed -n '/\<seq_80\>/,$ {
p
} ' file.txt > out_file

and so on.


Last edited by ahmad.diab; 4 Weeks Ago at 04:37 AM..
  #7 (permalink)  
Old 4 Weeks Ago
patrick87 patrick87 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 110
hi,
I just try both of the code that you suggested, it print out all the content of the file
I not sure what is the wrong that I had did
Do you know what is the reason?
Thanks again, ahmad
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0