Sponsored Content
Top Forums UNIX for Beginners Questions & Answers View a file and count all words beginning with specificletter Post 303033136 by RudiC on Saturday 30th of March 2019 01:45:51 PM
Old 03-30-2019
How about, given your grep accepts "regular expression extensions" like \b that are not necessarily available in all systems / versions:

Code:
grep -o "\b[sS][^ ]*" <<< "String Filter increment. The most basic implementation that can be used for all data types is shown on the far left. Each version to the right of that adds more functionality."
String
shown

Replace the "here string" with your input file when applying / testing it on your system.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove words beginning with a certain character from a file

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)
Discussion started by: skinnygav
3 Replies

2. Shell Programming and Scripting

Help in counting the no of repeated words with count in a file

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)
Discussion started by: bha148
4 Replies

3. Shell Programming and Scripting

Shell script to find out words, replace them and count words

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)
Discussion started by: alex83
3 Replies

4. UNIX for Dummies Questions & Answers

Count Number Of lines in text files and append values to beginning of file

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)
Discussion started by: motoxeryz125
7 Replies

5. Shell Programming and Scripting

count frequency of words in a file

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)
Discussion started by: mohit_iitk
3 Replies

6. Shell Programming and Scripting

problem to count number of words from file

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)
Discussion started by: nimafire
1 Replies

7. Shell Programming and Scripting

How count the number of two words associated with the two words occurring in the file?

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)
Discussion started by: jmarx
1 Replies

8. UNIX for Dummies Questions & Answers

Count dynamic words in file

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)
Discussion started by: sisihagen
3 Replies

9. Shell Programming and Scripting

Add words in beginning , end after removing a word in a file

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)
Discussion started by: saravanapandi
2 Replies

10. Shell Programming and Scripting

Count words from file

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
DB_COMMAND(9)						   BSD Kernel Developer's Manual					     DB_COMMAND(9)

NAME
DB_COMMAND, DB_SHOW_COMMAND, DB_SHOW_ALL_COMMAND -- Extends the ddb command set. SYNOPSIS
#include <ddb/ddb.h> DB_COMMAND(command_name, command_function); DB_SHOW_COMMAND(command_name, command_function); DB_SHOW_ALL_COMMAND(command_name, command_function); DESCRIPTION
The DB_COMMAND() macro adds command_name to the list of top-level commands. Invoking command_name from ddb will call command_function. The DB_SHOW_COMMAND() and DB_SHOW_ALL_COMMAND() are roughly equivalent to DB_COMMAND() but in these cases, command_name is a sub-command of the ddb show command and show all command, respectively. The general command syntax: command[/modifier] address[,count], translates into the following parameters for command_function: addr The address passed to the command as an argument. have_addr A boolean value that is true if the addr field is valid. count The number of quad words starting at offset addr that the command must process. modif A pointer to the string of modifiers. That is, a series of symbols used to pass some options to the command. For example, the examine command will display words in decimal form if it is passed the modifier "d". EXAMPLE
In your module, the command is declared as: DB_COMMAND(mycmd, my_cmd_func) { if (have_addr) db_printf("Calling my command with address %p ", addr); } Then, when in ddb: db> mycmd 0x1000 Calling my command with address 0x1000 db> SEE ALSO
ddb(4) AUTHOR
This manual page was written by Guillaume Ballet <gballet@gmail.com>. BSD
August 27, 2008 BSD
All times are GMT -4. The time now is 04:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy