English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hye guys
I have two problems in unix.

1. The first problem is that I wanna search for a word in a text file and then print it's count i.e how many times it occurs in that file.Now I tried this

grep "searchword" filename | wc -l

it works well but it counts the lines where the search word appears.If the word appears twice in a line,it still counts it as one.So pls help.I want the word count,not the number of lines matching the pattern.

2.Second problem is that I need to count number of symbols (* % $ etc) in a file.How can I do that??

Thanks in advance.

2006-10-26 20:41:21 · 2 answers · asked by helpingspirits1 2 in Computers & Internet Programming & Design

2 answers

for the first one you can use
grep -o "searchword" filename| wc -l (or) wc -w

for the second one also you can use the same command with wc -c
if you have to count special characters like \ you have to use \\.i.e use a \ before a special character.

2006-10-27 01:47:18 · answer #1 · answered by Y Raghavendra Reddy 2 · 0 0

It sounds like the scheduler is starting up, yet then failing quicker or later after the 'scheduler is operating' message. Your suitable wager for a more effective perfect mistakes message and an answer is completely one of the log archives (in /var/lp/logs or /var/log/cups i imagine).

2016-12-05 06:54:43 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers