aspose file tools*
The moose likes General Computing and the fly likes How To Edit a File in the Unix? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "How To Edit a File in the Unix?" Watch "How To Edit a File in the Unix?" New topic
Author

How To Edit a File in the Unix?

Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
I am not familiar with the Unix. It so happens that I have to edit a file in the Unix.

The file is .kshre and all I have to do are

1. append a string to my path
2. add four lines to the .kshre file

I use the Putty to logon to my account. I think I should type

vi -r

in the command window. And I do not know what to do next. Could anybody guide me? Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Despite being a unix dweeb from way back (and being told on multiple occasions that I "look" like a unix hacker -- whatever that means) I've never come to terms with vi.

You might find pico a more user-friendly alternative.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18825
    
  40

I use the Putty to logon to my account. I think I should type

vi -r

in the command window. And I do not know what to do next. Could anybody guide me? Thanks.



Well, I'll give this one a shot...

First, just use... "vi filename.ext" instead of the "-r" option to open the file that you want.

Second, cursor controls may not work -- older version of "vi" did not really support it. Just try to move the cursor. If you get junk, just disconnect and try again.

If cursor control doesn't work, use the letters "h", "j", "k", and "l", to move the cursor around. I believe the leftmost key moves the cursor left, and the rightmost key move the cursor right. Don't remember which of the two remaining keys are for up and down.

Third, when you are over a letter, pressing "x" will delete the letter.

Fourth, when you want to insert something, pressing "i" will put you in insert mode. At this point, just type what you want to insert. Pressing the "esc" key should take you out of insert mode.

Fifth, pressing "a" will put you into append mode. This is the same as insert mode, except you will insert after the current letter. This is good for adding stuff at the end of the line.

And finally, when you are done... make sure you are not in insert or append mode.

Pressing ":" will make a prompt appear on the bottom. Entering a "w" followed by a return will save the file back.

Pressing ":q" followed by a return will exit vi.

Henry
[ May 13, 2006: Message edited by: Henry Wong ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Peter Rooke
Ranch Hand

Joined: Oct 21, 2004
Posts: 803

This Graphical vi/vim Cheat Sheet and Tutorial may help.

This vi basic editing should be a good start.


Regards Pete
Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
Thanks for overwhelming responses. I think that I am able to do some editing on my own now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To Edit a File in the Unix?