Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google site



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-28-2001
Registered User
 

Join Date: Oct 2001
Location: Phoenix, AZ
Posts: 15
Question Quick VI question

This "SHOULD" be a simple question,
but looking through several books has turned up nothing,
so I turn once again to the experts!!

How do you vi a file so that you can see special characters.

I believe my /etc/passwd file is being corrupted during an upgrade process, however the files "look" the same. I need to
vi /etc/passwd to see if there are any special characters being
thrown in.

Thanks
Recon
Sponsored Links
  #2 (permalink)  
Old 11-28-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,150
Sorry, vi can't do that. It's a text editor only.

od, xd, cat -b, vis may be utilities on your system that can do this.

If you think /etc/passwd might get stepped on, save a copy! Any updates to any file always change the times in the inode. Look at the times to see if any changes occurred. Also use cmp on /etc/passwd and your copy. It will report any differences and works well with any binary values. Also you can use cksum to detect changes.
  #3 (permalink)  
Old 11-28-2001
Registered User
 

Join Date: Nov 2001
Posts: 60
In command mode, go to the command prompt (the and type
set list

This should show non-printable characters in vi.
  #4 (permalink)  
Old 11-29-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,150
Quote:
Originally posted by wizard
In command mode, go to the command prompt (the :) and type
set list

This should show non-printable characters in vi.
Actually, with most versions of unix, ":set list" only affects white space. It causes tabs to show up as ^I and newlines to be marked with $.

The real problem is that some bytes could have values in the range of 128 to 255 and you may not have an 8 bit data path to your terminal. Depending on the stty settings, the MSB may be a parity bit rather than a data bit. Also not all terminals will display something for non-ascii characters. And a final problem is that, I think, vi balks at attempting to display nulls, although it will count them and display a count at startup time.
  #5 (permalink)  
Old 11-29-2001
Registered User
 

Join Date: Nov 2001
Posts: 60
I stand corrected. Perderabo is absolutely correct. I didn't have a UNIX box handy when I answered, so no man pages. I faintly remembered set list showed some type of control characters.
Sorry.
  #6 (permalink)  
Old 12-01-2001
Neo's Avatar
Neo Neo is online now Forum Staff  
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 7,405
VI REFERENCE ....

Click here for a printable VI on-line reference.


BTW: Not sure, but perhaps you can use diff to compare the two files. I don't think (but not sure) you will get an exact match with diff if special or hidden chars are present.... perhaps someone could comment?

Also, you might consider playing round with stty and the flags for raw and cooked modes. I recall a few years ago using stty in raw mode to help find/print special chars.... not sure if we used vi or just cat to display.... somehow I recall playing with both stty and vi to find hidden chars in a file, but it has been many years ago....

stty man page here ...
  #7 (permalink)  
Old 02-20-2004
Registered User
 

Join Date: Apr 2003
Location: Sydney Australia
Posts: 1
Try emacs. It will display nulls as ^@

It will even let you delete it with Ctrl-d (Control and letter d) to delete 1 character.

I'm not an emacs user but it comes in handy sometimes.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with AWK -- quick question Probos Shell Programming and Scripting 5 07-18-2007 05:26 PM
quick question keith.m AIX 5 12-21-2006 09:27 AM
quick sed question vbm Shell Programming and Scripting 2 11-09-2006 10:44 PM
quick question pkolishetty UNIX for Dummies Questions & Answers 2 09-02-2006 12:56 PM
Ok quick question Corrail Shell Programming and Scripting 1 11-11-2005 01:49 PM



All times are GMT -4. The time now is 08:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0