- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Show character column or how many characters in a ...
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
Forums
Discussions
Discussions
Discussions
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
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
09-11-2006 08:14 AM
09-11-2006 08:14 AM
How do I figure this out?
Also, how do I show where the cursor is, what character it is at.
example, I open a file in vi.
hit the l button a dozen times maybe even 100 times, how do I know where my cursor in in the line.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 08:21 AM
09-11-2006 08:21 AM
Re: Show character column or how many characters in a line on a file
cat file | wc -c
wc can also be used to count lines, words, etc.
see the manpage for the options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 08:24 AM
09-11-2006 08:24 AM
Re: Show character column or how many characters in a line on a file
And also to show the carridge returns in the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 08:24 AM
09-11-2006 08:24 AM
Re: Show character column or how many characters in a line on a file
I need to find out how many characters are on a line.
And also to show the carridge returns in the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 08:30 AM
09-11-2006 08:30 AM
Re: Show character column or how many characters in a line on a file
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 08:33 AM
09-11-2006 08:33 AM
Re: Show character column or how many characters in a line on a file
open(FILE, "C:\\filename.txt");
while (
{
$line++;
chomp $_;
$len = length($_);
print "line: $line, length: $len\n";
}
close(FILE);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 08:39 AM
09-11-2006 08:39 AM
Solutionwhile read X < myfile |
do
echo "X = \"${X}\""
LEN=$(expr length "${X}")
echo "Length = ${LEN}"
done
Man expr for details.
To determine exact character offsets you do not want to use vi but rather a tool like od or xd:
od -Ad -v -tc -toC myfile
This will display the ASCII character and octal value for each byte is my file as well as the offsets into the file.
od -Ad -v -tc -toC myfile > myfile.od
You can then view myfile.od with a text editor if the file is large and still see exactly the offsets. Control characters are printed as well so your LF's and CR's will be obvious.
od and xd are tools you should really be familiar with. Man od for details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 09:01 AM
09-11-2006 09:01 AM
Re: Show character column or how many characters in a line on a file
awk '{print NR, length()}' testfile
Within vi, I'm not sure how to do any of what you ask. A quick glance through the vi and ex man pages didn't show anything promising. I think these may only be available in one of the enhanced vi clones like vim or elvis.
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 02:10 PM
09-11-2006 02:10 PM
Re: Show character column or how many characters in a line on a file
To check the whole file you could use 'wc' and compare the bytes reported with the lines reported times 773
But as is clear from several of your other questions around this magic 773 byte file, you should not be trying an interactive editting session on this file at all.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 07:20 PM
09-11-2006 07:20 PM
Re: Show character column or how many characters in a line on a file
vi does not have the facility to show current row:column on screen.
There are clones (vim,vile,elvis,nvi) that do this.
You can create a file files with 773 nulls by:
prealloc filename 773
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 06:20 AM
02-08-2007 06:20 AM