awk to start with symbol and print next


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk to start with symbol and print next
# 1  
Old 07-24-2010
Java awk to start with symbol and print next

File A


>answer is the predicted other than >bigger than two
>whatever isthere >out of mind
CGAHHAWWASSASS
SASAWEDSASSDDD
SSDDDEDEUJUYYS

>hello you are there other is what is that>you are not
serious>leave it
SSSAAAAAASS
ASWWQQDDD
WESEEWWWW
WEEEEEWSS
SJUJSGKKSSS
SWBVHJJWUW

>hi i am coming to that place >if you are not
there >something interesting
ASJSUWGJNDGSDBSSKKS
SSGWBSGGSJSKKLLSSJS
SHHHSYWJJKJKKSSK
KAIJWGBSKJJSJJJJJJSOWB


And the output should be
>answer is the predicted other than
CGAHHAWWASSASS
SASAWEDSASSDDD
SSDDDEDEUJUYYS

>hello you are there other is what is that
SSSAAAAAASS
ASWWQQDDD
WESEEWWWW
WEEEEEWSS
SJUJSGKKSSS
SWBVHJJWUW

>hi i am coming to that place
ASJSUWGJNDGSDBSSKKS
SSGWBSGGSJSKKLLSSJS
SHHHSYWJJKJKKSSK
KAIJWGBSKJJSJJJJJJSOWB


So If the first line in each red clor start with symbol > then another same symbol (>)came then it should not print but the next blue line (blue colour)

how can the awk or anything else command can work out..
# 2  
Old 07-24-2010
try this "untested" :


Code:
awk '/^>/{print;getline};!/>/' file

# 3  
Old 07-24-2010
actually same output will print
while running this awk code but second line have been removed but not still
>answer is the predicted other than >bigger than two
CGAHHAWWASSASS
SASAWEDSASSDDD
SSDDDEDEUJUYYS
>hello you are there other is what is that>you are not
SSSAAAAAASS
ASWWQQDDD
WESEEWWWW
WEEEEEWSS
SJUJSGKKSSS
SWBVHJJWUW
>hi i am coming to that place >if you are not
ASJSUWGJNDGSDBSSKKS
SSGWBSGGSJSKKLLSSJS
SHHHSYWJJKJKKSSK
KAIJWGBSKJJSJJJJJJSOWB

Last edited by cdfd123; 07-24-2010 at 04:39 PM.. Reason: output result
# 4  
Old 07-25-2010
Hi,

try:

Code:
awk 'f==0 && /^>/{sub(/>[^>]*$/,"",$0);print $0;f=1}!/.*>.*/{print $0;f=0}' file

It gives me:

Code:
>answer is the predicted other than 
CGAHHAWWASSASS
SASAWEDSASSDDD
SSDDDEDEUJUYYS
>hello you are there other is what is that
SSSAAAAAASS
ASWWQQDDD
WESEEWWWW
WEEEEEWSS
SJUJSGKKSSS
SWBVHJJWUW
>hi i am coming to that place 
ASJSUWGJNDGSDBSSKKS
SSGWBSGGSJSKKLLSSJS
SHHHSYWJJKJKKSSK
KAIJWGBSKJJSJJJJJJSOWB

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to add lines with symbol to output file

In the awk below which does execute I get output that is close, except for all the lines that start with a # are removed. Some lines have one others two or three and after the script adds the ID= to the fields below the pattern in the awk, I can not seem to add the # lines back to the output. ... (5 Replies)
Discussion started by: cmccabe
5 Replies

2. Shell Programming and Scripting

Context for use of [.symbol.] awk notation

Hi Just wondering ... do you have an example of context that would demonstrates how usefull the awk notation can efficiently be used ? Thx :rolleyes: (6 Replies)
Discussion started by: ctsgnb
6 Replies

3. Shell Programming and Scripting

awk to add symbol to specific field

Trying to use awk to add a . to $4. The input and output is tab-delimeted, but the awk seems to add a . in front of $5 and is space-delimeted. It seems close, but I am not able to produce the desired output. Thank you :). file chr1 948895 949015 chr1:948895-949015 ISG15 chr1 ... (1 Reply)
Discussion started by: cmccabe
1 Replies

4. Shell Programming and Scripting

awk Merging multiple files with symbol representing new file

I just tried following ls *.dat|sort -t"_" -k2n,2|while read f1 && read f2; do awk '{print}' $f1 awk FNR==1'{print $1,$2,$3,$4,$5,"*","*","*" }' OFS="\t" $f2 awk '{print}' $f2 donegot following result 18-Dec-1983 11:45:00 AM 18.692 84.672 0 25.4 24 18-Dec-1983 ... (3 Replies)
Discussion started by: Akshay Hegde
3 Replies

5. UNIX for Dummies Questions & Answers

Append symbol at the start of each line

hi, i have some values in excel sheet as in below format: 122 144 222 555 666 etc.... i need to get the output in the below manner.. £122 £144 £222 £555 £666 (1 Reply)
Discussion started by: arunmanas
1 Replies

6. Shell Programming and Scripting

start to print when a specified word is matched

Hello everybody, How can I start to print an output when a word hits the pattern space. for example: file.txt : first line second line third line fourth line ... cat file.txt > function "second" should print second line third line fourth line ... thanks for the replies now... (3 Replies)
Discussion started by: Oddant
3 Replies

7. Shell Programming and Scripting

Print new item in file with symbol

Dear all, I have encountered some problem here. I prompt the user for input and store it into a data file, eg. key in name and marks so the data file will look like this andrew 80 ben 75 and the next input is carine 90. So the problem here is i want to print... (2 Replies)
Discussion started by: branred
2 Replies

8. Solaris

/usr/lib/passwdutil.so.1: symbol __nsl_fgetspent_r: referenced symbol not found

deleteing post (0 Replies)
Discussion started by: dshakey
0 Replies

9. Shell Programming and Scripting

Awk symbol for last column

Hi , I have a bunch of files with different # of columns but I want to write a single awk script. What is the awk symbol for last column? say '{print $lastcol}' or something (3 Replies)
Discussion started by: grossgermany
3 Replies

10. Shell Programming and Scripting

[AWK] read lines with \x00 symbol

I want to read a large (~1-4Gb) txt file with fields separated by "," and line separator "\n". Unfortunately, file contains \x00 (zero ASCII) symbols AWK treats them as end of line + it ignores reminder of the line after the \x00. As a simple example: echo "\0060\0061\000\0060\0063" | nawk... (6 Replies)
Discussion started by: Murfury
6 Replies
Login or Register to Ask a Question