Display all the words whose length is equal to the longest word in the text
Hi Guys,
I was going some trial and error to see if I can find the longest word in a text.
I was using Pipes because they are easier to use in this case.
I was stuck on this for a while so I thought I'll get some help with it.
I tried this code to separate all the words in a text in lines and this would give me the LENGTH of the longest word.
But suppose if I want to display the longest word/s according to length (for example, longest word is 15 characters long and I want to display all words with the length of 15 characters).
Dear All,
To find the length of the longest line from a file i have used wc -L which is giving the proper output...
But the problem is AIX os does not support wc -L command.
so is there any other way 2 to find out the length of the longest line using awk or sed ?
Regards,
Pankaj (1 Reply)
I need Display the most top 10 occurring words along with the number of occurences of those words in the given text.
Sample text as below:
"The Travails of Single South Indian men of conservative upbringing" or "Why we don't get any..."
Yet another action packed weekend in Mumbai, full of... (2 Replies)
Using sed or awk, I need to display text between two words/characters. Below are two example inputs and the desired output. In a nutshell, I need the date-range value between the quotes (but only the first occurance of date-range as there can be more than one).
Example One Input:
xml-report... (1 Reply)
I would be grateful if someone could help me. I am trying to write a .sh script in UNIX.
I have the following code;
User=john
User=james
User=ian
User=martin
for x in ${User}
do
print ${#x}
done
This produces the following output;
4
5
3
6 (12 Replies)
I am trying to write a command on just one line, i.e seperated by ';' and '|' etc, that finds the number of characters in the longest word of a file, preferably using the 'tr' and 'wc' commands.
i no that wc shows the number of lines words and characters in a file but im not sure how to use it... (5 Replies)
Hello Everyone,
I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table.
Input Data-
------ ------------------------ ---- -----------------
WFI001 Xxxxxx Control Work Item A Number of Records
------ ------------------------... (5 Replies)
Hi,
I am trying to figure out how to get the length of the longest column in the entire file (because the length varies from one row to the other)
I was doing this at first to check how many fields I have for the first row:
awk '{print NF; exit}' file
Now, I can do this:
awk '{ if... (4 Replies)
Running below line gives 3957 as length of longest line in file 20121119_SRMNotes_init.dat
awk ' { if ( length > 3950 ) { x = length } }END{ print x }' 20121119_SRMNotes_init.dat
While wc -L 20121119_SRMNotes_init.dat gives output as 4329. Why is there a difference between these two commands.... (2 Replies)
Hi
Can someone tell me which script will work best (in terms of speed and simplicity to write and run) for a large text file to filter all the lines with a minimum specified length of words ? A sample script with be definitely of great help !!! Thanks in advance. :) (4 Replies)
Discussion started by: my_Perl
4 Replies
LEARN ABOUT OPENSOLARIS
wc
wc(1) User Commands wc(1)NAME
wc - display a count of lines, words and characters in a file
SYNOPSIS
/usr/bin/wc
wc [-c | -m | -C] [-lw] [file]...
ksh93
wc [-c | -m | -C] [-lLqw] [file]...
DESCRIPTION
/usr/bin/wc
wc reads one or more input files and, by default, writes the number of NEWLINE characters, words and bytes contained in each input file to
the standard output.
wc also writes a total count for all named files, if more than one input file is specified.
wc considers a word to be a non-zero-length string of characters delimited by white space (for example, SPACE, TAB). See iswspace(3C) or
isspace(3C).
ksh93
The wc built-in in ksh93 is associated with the /bin and /usr/bin paths. It is invoked when wc is executed without a pathname prefix and
the pathname search finds a /bin/wc or /usr/bin/wc executable.
wc reads one or more input files and, by default, for each file writes a line containing the number of NEWLINEs, words, and bytes contained
in each file followed by the file name to standard output in that order. A word is defined to be a non-zero length string delimited by iss-
pace(3C) characters.
If more than one file is specified, wc writes a total count for all of the named files with total written instead of the file name.
By default, wc writes all three counts. Options can specified so that only certain counts are written. The -c, -C, and -m options are mutu-
ally exclusive.
If no file is specified, or if the file is -, wc reads from standard input and no filename is written to standard output. The start of the
file is defined as the current offset.
-c
--bytes | chars
List the byte counts.
-l
--lines
List the line counts.
-L
--longest-line | max-line-length
List the longest line length.
-m | C
--multibyte-chars
List the character counts.
-q
--quiet
Suppress invalid multi-byte character warnings.
-w
--words
List the word counts.
OPTIONS
The following options are supported:
-c Counts bytes.
-C Same as -m.
-l Counts lines.
-m Counts characters.
-w Counts words delimited by white space characters or new line characters. Delimiting characters are Extended Unix Code (EUC) charac-
ters from any code set defined by iswspace().
If no option is specified, the default is -lwc (counts lines, words, and bytes.)
OPERANDS
The following operand is supported:
file A path name of an input file. If no file operands are specified, the standard input is used.
USAGE
See largefile(5) for the description of the behavior of wc when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of wc: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
/usr/bin/wc
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|Standard |See standards(5). |
+-----------------------------+-----------------------------+
ksh93
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|Interface Stability |See below. |
+-----------------------------+-----------------------------+
The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-in interfaces are Uncommitted.
SEE ALSO cksum(1), ksh93(1), isspace(3C), iswalpha(3C), iswspace(3C), setlocale(3C), attributes(5), environ(5), largefile(5), standards(5)SunOS 5.11 13 Mar 2008 wc(1)