View a file and count all words beginning with specificletter
I am trying to write a command and need to count all the words within the file which begin with the letter S
I have run this command
When I remove the wc -l I see the output as below:
As you can see in the output of point two it brings the whole line but also the word shown is included which should have picked up with the first command?
Hi,
how could you go about removing words that begin with a certain character.
assuming that this character is '-' I currently have
echo "-hello" | sed s/-/""/
which replaces the leading dash with nothing but I want to remove the whole word, even if there are multiple words beginning... (3 Replies)
Hi Pls help in solving my doubt.Iam having file like below
file1.txt
priya
jenny
jenny
priya
raj
radhika
priya
bharti
bharti
Output required:
I need a output like count of repeated words with name for ex:
priya 3
jenny 2 (4 Replies)
hello,
i 'd like your help about a bash script which:
1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel,
2.finds the link which leads to the download location of the Latest Stable Kernel version,
(the right link should lead to the file... (3 Replies)
Hello,
I have 50 text files in a directory called "AllFiles"
I want to make a program that will go inside of the "AllFiles" Directory and count the number of lines in each individual text file. Then, the program will calculate how many more lines there are over 400 in each text file and... (7 Replies)
I need to write a shell script "cmn" that, given an integer k, print the k most common words in descending order of frequency.
Example Usage:
user@ubuntu:/$ cmn 4 < example.txt :b: (3 Replies)
hi every one i have written this simple shell for counting number of word that user need to find from file
but i have get several error when run it. can someone tell me the problem ?
echo "Enter the file name"
read file
echo "enter word"
read word
for i in \`cat $file`
do
if
then... (1 Reply)
Hi ,
I need to count the number of errors associated with the two words occurring in the file. It's about counting the occurrences of the word "error" for where is the word "index.js". As such the command should look like. Please kindly help. I was trying: grep "error" log.txt | wc -l (1 Reply)
Hello,
i want built a log analyzer for nginx. Okay and i use it as training for the shell tools. The most what i want i could relize. But i has trouble with dynamic things. I have the IP address extracted and has set the geo localtion for the ip.
I would like to count the countries. With... (3 Replies)
My file has the entries like below...
/dev/sds
/dev/sdak
/dev/sdbc
/dev/sdbu
I want to make the file like below
echo 1 > /sys/block/sds/device/rescan
echo 1 > /sys/block/sdak/device/rescan
echo 1 > /sys/block/sdbc/device/rescan
echo 1 > /sys/block/sdbu/device/rescan (2 Replies)
hi all
how to count words from a text
aaa bbb ccc ddd
123 aaa 123 aaa
aaa ddd 123
i need to cout hoe many time the words "aaa" and "123" each appears
the output should be
4 3
or
4
3
or
aaa 4
123 3
thanks (10 Replies)
Discussion started by: sharong
10 Replies
LEARN ABOUT HPUX
wc
wc(1) General Commands Manual wc(1)NAME
wc - count words, lines, and bytes or characters in a file
SYNOPSIS
[file]...
DESCRIPTION
The command counts lines, words, and bytes or characters in the named files, or in the standard input if no file names are specified. It
also keeps a total count for all named files.
A word is a string of characters delimited by spaces, tabs, or newlines.
Options
recognizes the following options:
Report the number of bytes in each input file.
Report the number of newline characters in each input file.
Report the number of characters in each input file.
Report the number of words in each input file.
The and options are mutually exclusive. Otherwise, the and or options can be used in any combination to specify that a subset of lines,
words, and bytes or characters are to be reported.
When any option is specified, reports only the information requested. If no option is specified, the default output is
When a file is specified on the command line, its name is printed along with the counts.
Standard Output
By default, the standard output contains an entry for each input file in the form:
newlines words bytes file
If the option is specified, the number of characters replaces the bytes field in this format.
If any option is specified, the fields for the unspecified options are omitted.
If no file operand is specified, neither the file name nor the preceding blank character is written.
If more than one file operand is specified, an additional line is written at the end of the output, of the same format as the other lines,
except that the word (in the POSIX locale) is written instead of a file name and the total of each column is written as appropriate.
Under UNIX Standard environment, a word is a string of characters delimited by spaces, tabs, newline, carriage-return, vertical tab, or
form-feed.
RETURN VALUE
exits with one of the following values:
Successful completion.
An error occurred.
EXTERNAL INFLUENCES
For information about the UNIX Standard environment, see standards(5).
Environment Variables
determines the range of graphics and space characters, and the interpretation of text as single- and/or multibyte characters.
determines the language in which messages are displayed.
If or is not specified in the environment or is null, they default to the value of
If is not specified or is null, it defaults to (see lang(5)).
If any internationalization variable contains an invalid setting, they all default to See environ(5).
International Code Set Support
Single- and multibyte character code sets are supported. with a newline character, the count will be off by one.
WARNINGS
The command counts the number of newlines to determine the line count. If a text file has a final line that is not terminated with a new-
line character, the count will be off by one.
EXAMPLES
Print the number of words and characters in
The following is printed when the above command is executed:
where words is the number of words and chars is the number of characters in
SEE ALSO standards(5).
STANDARDS CONFORMANCE wc(1)