Script program to count only alphabetical characters

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Script program to count only alphabetical characters
# 1  
Old 04-04-2013
Script program to count only alphabetical characters

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Write a shell script program to count the ONLY the number of alphabetic characters stored in the shell variable call count. Use count='The answer (12345) you should get is 24' as you variable and value. Use the sed command as part of your solution. Put you tested program in the space below. The logic of this program is the same as the last program, but you use sed to remove the characters you don't want to count and to leave and count only the alphabetic characters that are left.


2. Relevant commands, code, scripts, algorithms:
wc -m count, must use sed.


3. The attempts at a solution (include all code and scripts):
count | sed wc


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Calvin College, Grand Rapids MI, USA, Mr. Johnson, CO 142.

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 04-04-2013
You pipe commands into other commands, you don't pipe variables.

Variables don't work just by typing their name, you have to put a $ in front of them.

'sed wc' makes no sense at all.

It'd look something like echo $count | sed '...' | wc

You will need to figure out what regular expression will remove non-alphabetic characters, and how to use wc to count characters(see man wc)
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 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 ...sequence.... >ENSMUSG00000006638|ENSMUST00000006814 GGGAAATGGAATACCCCTACACAACCAAGATGCTGAGTTCCTCCCTGAGCCCGCAAAACG... (2 Replies)
Discussion started by: giuliangiuseppe
2 Replies

3. Shell Programming and Scripting

awk script to count characters in file 1 in file 2

I need a scripting AWK to compare 2 files. file 1 and 2 are list of keywords 1 is a b c d 2 is aa aaa b bb ccc d I want the AWK script to give us the number of times every keyword in file 1 occurs in file 2. output should be a 2 (7 Replies)
Discussion started by: anhtt
7 Replies

4. UNIX for Dummies Questions & Answers

Script to list applications in alphabetical order

I've looking over a script for work and I've had a problem with the script not listing the files in alphabetical order. To look up PIDs for apps, it would be beneficial to have them listed in that order. Here is what I've been reviewing. #!/usr/bin/perl $str = sprintf "%4s %-40s", "PID",... (7 Replies)
Discussion started by: whysolucky
7 Replies

5. Shell Programming and Scripting

count number of entries perl program or Unix script

Hi I have a file with number of entries name 1 123 name 1 345 name 1 65346 name2 3243 name2 24234 name 2 234234 so on ......... how to count total number of entries for name 1 and name2...and so on Please guide. (1 Reply)
Discussion started by: manigrover
1 Replies

6. 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...,,,,..gg..Cc.c,,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

7. 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

8. UNIX for Dummies Questions & Answers

How can I list the file under a directory both in alphabetical and in reverse alphabetical order?

How can I list the file under current directory both in alphabetical and in reverse alphabetical order? (1 Reply)
Discussion started by: g.ashok
1 Replies

9. 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

10. Shell Programming and Scripting

shell program for sorting strings in an alphabetical order

Hi, I trying to find the solution for writing the programming in unix by shell programming for sorting thr string in alphabetical order. I getting diffculty in that ,, so i want to find out the solution for that Please do needful Thanks Bhagyesh (1 Reply)
Discussion started by: bp_vanarse
1 Replies
Login or Register to Ask a Question