vi does not open file properly....


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers vi does not open file properly....
# 1  
Old 11-18-2010
vi does not open file properly....

Hello all,

I am trying to edit a file using VI on hp-ux....but when i try to open the file using vi <filename> it dose not let me open up the right way...it just messes up the whole file....i cant even read that file...so for example...here is a file i created test1.txt...when i cat it...it give me the below, which is right...but when i try to vi test1.txt....it just messes up my format....do i have some env variable set wrong ???
Code:
/home/oracle >cat test1.txt
hello this is a new file
doing a test
but cannot eddit it
/home/oracle >
/home/oracle >
/home/oracle >
/home/oracle >
/home/oracle >vi test1.txt
~0y0C51y0C"test1.txt" 4 lines, 59 characters0y0Cllo this is a new file

/home/oracle >echo $SHELL
/usr/bin/ksh
/home/oracle >
/home/oracle >uname -a
HP-UX servername B.11.11 U 9000/800 1059436171 unlimited-user license
/home/oracle >


Last edited by Scott; 11-18-2010 at 04:33 PM.. Reason: Please use code tags
# 2  
Old 11-18-2010
You have some non-printing characters in the file. They can confuse vi.

Code:
cat -v test1.txt

will show them to you.
# 3  
Old 11-18-2010
dose not seem like it....
Code:
/home/oracle >cat -V test1.txt
cat: illegal option -- V
Usage: cat [-benrstuv] [-|File ...]
/home/oracle >
/home/oracle >
/home/oracle >cat -v test1.txt
hello this is a new file
doing a test
but cannot eddit it
/home/oracle >


Last edited by Scott; 11-18-2010 at 04:33 PM.. Reason: Code tags
# 4  
Old 11-18-2010
Code:
vi test1.txt

After pressing <enter> you will be in command mode
then you can use
:set listto enable the display of invisible character
:set nolistto disable the display of invisible character
So you can identify and delete the character that are corrupting the file.
Note that to move, you should not use the arrow button but instead :

hmove left
jmove down
kmove up
lmove right
# 5  
Old 11-19-2010
What type of terminal (or terminal emulator) are you using and what it the value of $TERM ?
# 6  
Old 11-19-2010
cat -v == LOWERCASE v
# 7  
Old 11-19-2010
Code:
strings test1.txt >test2.txt
vi test2.txt

===> if you can edit test2.txt correctly with vi then
Code:
cat test2.txt >test1.txt
rm test2.txt

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File count script not working properly

Hi Experts, I have this script to count the number of files based on prefix and suffix values. #!/bin/ksh file_date=$1 prefix=$2 suffix=$3 file_count=$(ls -l /db/day_file/{$prefix}*${file_date}*{$suffix}) The files in the directory /db/day_file are as below. 20170501 20170501... (7 Replies)
Discussion started by: nalu
7 Replies

2. UNIX for Dummies Questions & Answers

How to check if my log file is growing properly?

Hi All, I want to check if one my log file is updating properly, how can I achieve it. The approach I am trying is to get the file size at two different interval and than comparing it eg : $ ls -ltr | tail -1 | awk '{print $5}' 20480 (7 Replies)
Discussion started by: mukulverma2408
7 Replies

3. Shell Programming and Scripting

In Outlook spooled file data is not getting displayed properly

I am fetching a database table in spool file and send that details as a email. The Spooled file content is properly being displayed in UNIX. See Example below : ID|FILENAME |ABCDEF_DT |PROCESSED_DT |STATUS... (4 Replies)
Discussion started by: Ravi_007
4 Replies

4. Shell Programming and Scripting

Newbie.. Find if a file exists and open, if not create the desired file..

Hey all, I'm brand new to script writing, I'm wanting to make a script that will ask for a file and then retrieve that file if it exists, and if it doesn't exist, create the file with the desired name, and I'm completely stuck.. so far.. #! bin/bash echo "Enter desired file" read "$file" if ... (5 Replies)
Discussion started by: Byrang
5 Replies

5. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

6. Red Hat

cannot set user id: Resource temporarily unavailable (not open file/open process related)

First post, sorry to be a bother but this one has been dogging me. I have a process user (java application server) that trips a resource limit every couple weeks and need help finding what limit we're hitting. First, this is what's running: This is the error when jobs are run or the... (0 Replies)
Discussion started by: Katahdin
0 Replies

7. Programming

Some how the open(file,flag, acc) returns 0 and write to the screen, instead of the file ???

I am out of idea what to do to resolve the problem! I need to use the open(file, for.., access) function to write a file. Never have the situation like that: it is return 0 - zero. As a result all write(..) going to the screen! What the problem it could be? I do not even know... (2 Replies)
Discussion started by: alex_5161
2 Replies

8. UNIX for Dummies Questions & Answers

Issue with shell script: not detecting file properly

The following script is meant to check the presence of a file - called filename0.94.tar.gz - and uncompress it: #!/bin/sh # check presence of file VERSION=0.94 if ; then # file not present: abort echo "Files cannot be found." #exit 1 (commented out this line, so we can see how the... (2 Replies)
Discussion started by: figaro
2 Replies

9. UNIX for Dummies Questions & Answers

how to open a text file by double clicking on the file name in gtk+

how to open a text file by double clicking on the file name shown in a label widget in gtk+. thanks (0 Replies)
Discussion started by: cy163
0 Replies

10. UNIX for Dummies Questions & Answers

file activity (open/closed) file descriptor info using KORN shell scripting

I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Discussion started by: Gary Dunn
3 Replies
Login or Register to Ask a Question