- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- line or word count in a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 06:12 PM
тАО08-01-2007 06:12 PM
line or word count in a file
Can any one help me in finding out the line or words count in the file ,if possible even the character count with spaces or without spaces as i need to cross-check the files in VMS and the same file downloaded into windows.Any kind of script or command is required.Am in great need.Pls send in your solutions asap.
DV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 06:18 PM
тАО08-01-2007 06:18 PM
Re: line or word count in a file
welcome to the OpenVMS ITRC forum.
$ SEARCH file/STATIS any-string
will at least report:
Records searched: xxx
Characters searched: xxx
Volker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 06:20 PM
тАО08-01-2007 06:20 PM
Re: line or word count in a file
To get that kind of information from a file, you'll need to read it. VMS does NOT have a standard tool (like a Unix wc) to do this.
So you'll have to create a DCL script, an editor script, or program.
Personally I would use PERL.
For example, the following one-liner will print the number of Characters, Words and Lines for a file.
perl -ne "$w+=split; $c+=length; END {print qq($c $w $.)}" file.txt
The number of whitespace characters could be counted by adding $x++=s/\s//g
Untested. Left as an excercise.
Cheers,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 06:44 PM
тАО08-01-2007 06:44 PM
Re: line or word count in a file
$ search file ""/noooutput/stat
That will display only the statistics, and is marginally more efficient than specifying a search string.
If you want to know if the files are the same, have you considered using something like md5sum?
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 07:13 PM
тАО08-01-2007 07:13 PM
Re: line or word count in a file
Characters, whiteSpace, Words and Lines.
$ perl -ne "$w+=split; $c+=length; $s+=s/\s//g}{print qq($c $s $w $.)" file.txt
the -n generates an implied loop:
while ($_ =
[program]
}
the -e indicated the program is in the next argument
split is normally used as @words=split(/\s+/,$_) but here all defaults are accepted and the output is used as a scalar, not an array in which case it returns the numer of elements for the array)
similar for s/\s\//g which indicates to replace each whitespace (\s) in default variable $_ by nothing, counting as it goes.
$. is the current line.
}{ closes the main [program] in the loop and starts a new, end block which is then closed by the } provided through -n
Enjoy!
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 09:25 PM
тАО08-01-2007 09:25 PM
Re: line or word count in a file
Really am happy to see the solutions. But apparently i am sorry heuvel i cant use any of those perl commands.I just need them in VMS command or even DCL script to find the total count of words and lines in a file.Thanks volker and jon for your prompt reply :-).Its exactly what i want. Just with curiosity am asking this - is it possible to get the total word count in a file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 09:35 PM
тАО08-01-2007 09:35 PM
Re: line or word count in a file
there is no native OpenVMS command to get the word count of a file.
On recent versions of OpenVMS, you could install GNV. This provide the wc command:
AXPVMS $ bash
bash$ wc login.com
94 358 3213 login.com
bash$ exit
exit
AXPVMS $
You can download GNV from:
http://h71000.www7.hp.com/opensource/opensource.html#gnv
GNV (GNU's Not VMS) is an open source, GNU-based UNIX environment for OpenVMS that provides UNIX application developers, system managers, and users a UNIX-style environment on OpenVMS
Volker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 09:50 PM
тАО08-01-2007 09:50 PM
Re: line or word count in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 09:51 PM
тАО08-01-2007 09:51 PM