The pipe to sort | uniq -c | sort -rn is a standard idiom for counting things. The final sort puts the occurrence counts in rank order; you can take that out if you want them sorted alphabetically (which is what the first sort does, not because it's neat, but because uniq needs identical lines to be adjacent, and sorting them is a good way to do that).
Next week, the spelling bee will include "occurrence".
I am writing my first shell script to do the following:
Find all occurrences of a directory from the pwd
Delete the directory (which is a hidden directory)
Provide feedback w/ the number of directories deleted
The problems I am having are two-fold:
The user may not have the appropriate... (2 Replies)
Hi
Could anybody tell me how to count the number of occurances of a character within a LINE.
actually i have a single line with words seperated with '+' chracter e.g.
abc+def+ghj+jkl+asd
i want to separte the words above.
Please provide the necessary logic in the form of a SHELL... (6 Replies)
I want to find the number of occurences of a character in a file.
How do i do it.
Eg:
$cat file1.txt
Welcome to World of Unix.
$
If i want to find the occurences of 'o' then I should be getting 3.
Thanks. (6 Replies)
I've written a script to count the total size of SAN storage LUNs, and also display the LUN sizes.
From server to server, the LUNs sizes differ.
What I want to do is count the occurances as they occur and change.
These are the LUN sizes:
49.95
49.95
49.95
49.95
49.95
49.95
49.95
49.95... (2 Replies)
Hi. I need to count multiple occurrences of X Y Z in a file in 1 go. At the moment I have the following scripts:
ssh readonly@$ServerIP 'YEAR=xx;DAY=xx;MONTH=xx;LMONTH=xx;for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 \
16 17 18 19 20 21 22 23; do cat... (13 Replies)
Gurus,
Need little guidance.
I have A.txt and B.txt file. B.txt file contains Unique strings.
Sample content of B.txt file for which i cut the fourth column uniquely and output directed to B.txt file
And A.txt file contains the above string as a fourth column which is last column.
So A.txt... (7 Replies)
I have a file as shown below. I need to count the unique occurrences of numbers in the first and second column only if the third column is <= 10. Otherwise print the corresponding numbers as zero.
Thanks in advance!:)
58 80 40.74
76 80 9.78
76 80 8
12 6 9
30 28 8.23
45 12 ... (13 Replies)
I have some text files as shown below. I would like to add the values of each string. Your help would be appreciated!!
file1.txt
SUS 2
PRS 2
ALI 1
PRS 1
GLK 2
file2.txt
PRS 3
GLK 6
SUS 18
Desired output
SUS 20
PRS 6 (2 Replies)
Guys
I am trying grep to read from pattern file and count occurances of each word.
input is
firstplace
secondplace
secondpot
patternfile is
place
first
second
i want the following.
1-count number of times keywords in patternfile occurs in begining of each line in input file.
so... (12 Replies)
Discussion started by: ahfze
12 Replies
LEARN ABOUT HPUX
fold
fold(1) General Commands Manual fold(1)NAME
fold - fold long lines for finite width output device
SYNOPSIS
width] [file ...]
Obsolete form:
width] [file ...]
DESCRIPTION
The command is a filter that folds the contents of the specified files, breaking the lines to have a maximum of width column positions (or
bytes, if the option is specified). The command breaks lines by inserting a newline character so that each output line is the maximum
width possible that does not exceed the specified number of column positions (or bytes). A line cannot be broken in the middle of a char-
acter. If no files are specified or if a file name of is specified, the standard input is used.
The command is often used to send text files to line printers that truncate, rather than fold, lines wider than the printer is able to
print.
If the backspace, tab, or carriage-return characters are encountered in the input, and the option is not specified, they are treated spe-
cially as follows:
Backspace The current count of line width is decremented by one, although the count never becomes negative. Thus, the char-
acter sequence character-backspace-character counts as using one column position, assuming both characters each
occupy a single column position. does not insert a newline character immediately before or after any backspace
character.
Tab Each tab character encountered advances the column position pointer to the next tab stop. Tab stops are set 8 col-
umns apart at column positions 1, 9, 17, 25, 33, etc.
Carriage-return The current count of line width is set to zero. does not insert a newline character immediately before or after
any carriage-return character.
Note that may affect any underlining that is present.
Options
The command recognizes the following options and command-line arguments:
Count width in bytes rather than in column positions.
Break the line on the last blank character found
before the specified number of column positions (or bytes). If none are found, break the line at the specified
line length.
Specify the maximum line length, in column positions (or bytes if
is specified). The default value is 80. width should be a multiple of 8 if tabs are present, or the tabs should
be expanded using before processing by (see expand(1)). The option is obsolescent and may be removed in a future
release.
EXTERNAL INFLUENCES
Environment Variables
determines the interpretation of text as single- and/or multi-byte characters.
determines the language in which messages are displayed.
If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty
variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of
If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See
environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
SEE ALSO expand(1).
STANDARDS CONFORMANCE fold(1)