Count characters after a line

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Count characters after a line
# 1  
Old 02-03-2014
Count characters after a line

Hi All!
I would like to solve a problem but I have no clue of how do it!I will be grateful if someone could help me!
I have a file like this:
> genes | transcript

I would like to obtain a file like this, that reports the IDs and the numbers of letters:


Do you have any suggestion?



Last edited by Don Cragun; 02-03-2014 at 06:13 AM.. Reason: Use CODE tags, not HTML tags for sample input and output.
# 2  
Old 02-03-2014
awk ' /^>/{ if(len) print len; print;len=0;next } {len+=length} END { print len } ' file

# 3  
Old 02-03-2014
It works!!

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count consecutive characters

Need to count consecutive characters in a string and give the output as below i/p=aaaabbcaa o/p=a4b2c1a2 (10 Replies)
Discussion started by: prasanna2166
10 Replies

2. Shell Programming and Scripting

Count the pipes "|" in line and delete line if count greter then number.

Hello, I have been working on Awk/sed one liner which counts the number of occurrences of '|' in pipe separated lines of file and delete the line from files if count exceeds "17". i.e need to get records having exact 17 pipe separated fields(no more or less) currently i have below : awk... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. Shell Programming and Scripting

How to count number of characters of wc -l output?

I want count number of characters / find the length of the 'wc -l' output This is the command bash-3.2$ gzcat /home/sid/file1.dat |wc -l 830752 So final out I want is 6 i.e lenght of 830752 I tried with awk bash-3.2$ gzcat /home/sid/file1.dat |wc -l | awk '{print length ($0)... (3 Replies)
Discussion started by: sidnow
3 Replies

4. Shell Programming and Scripting

Compare file1 header count with file2 line count

What I'm trying to accomplish. I receive a Header and Detail file for daily processing. The detail file comes first which holds data, the header is a receipt of the detail file and has the detail files record count. Before processing the detail file I would like to put a wrapper around another... (4 Replies)
Discussion started by: pone2332
4 Replies

5. UNIX for Dummies Questions & Answers

count different characters from one column

Hi everyone, and thanks after all I'm a biologist and i have to extract information from one text. The text is something like this 1023 A A 56 0 cc...,,,,,,c..CC..,, 1024 T T 86 0 ..,,,..aaAA..,,aAA,,a,,A,,a 1025 G G 125 0 ... (5 Replies)
Discussion started by: beajorrin
5 Replies

6. Shell Programming and Scripting

Count number of characters in particular column

Hi i have data like abchd 124 ldskc aattggcc each separated by tab space i want to count number of characters in 4th column and print it in new column with tabspace for every line can anyone help me how to do it. Thanks. (3 Replies)
Discussion started by: bhargavpbk88
3 Replies

7. UNIX for Dummies Questions & Answers

deletion of duplicate characters and count

to delete the duplicate characters in a file I used this code cat file.txt|tr -s "" tell the other ways using sed command to count of duplicate characters thanks:) (0 Replies)
Discussion started by: tsurendra
0 Replies

8. UNIX for Dummies Questions & Answers

Count the characters in a string

Hi all, I like to know how to get the count of each character in a given word. Using the commands i can easily get the output. How do it without using the commands ( in shell programming or any programming) if you give outline of the program ( pseudo code ) i used the following commands ... (3 Replies)
Discussion started by: itkamaraj
3 Replies

9. Shell Programming and Scripting

Grep command to count characters

I have a file that I need to count the number of "Y"s in the file, but just the "Y"s that fall between certain columns. Like: file1: 1234567890123456789012345 BBBBBBYBBBBYBBYBBYBBYBBB I want to count the 'Y's between 17 and 21 = 2 "Y"s Thanks (12 Replies)
Discussion started by: jbt828
12 Replies

10. Shell Programming and Scripting

how to count characters by line of file ?

Hello, Member or professional need help how to count characters by line of file Example of the file is here cdr20080817164322811681txt cdr20080817164322811txt cdr20080817164322811683txt cdr20080817164322811684txt I want to count the characters by line of file . The output that I... (4 Replies)
Discussion started by: ooilinlove
4 Replies
Login or Register to Ask a Question