Which editor to use?


 
Thread Tools Search this Thread
# 1  
Which editor to use?

Good day, everyone!
I've started using/learning UNIX recently and the only problem i get, is that I can hardly edit a file from within the script (searching/replacing, extracting, ect.) I've tried vi, ex, ed all of them did only half of job, which means they opened out a file but did not perform any editing or any required operations. Hence, I've got a question:
which editor do i need to use, to be able to perform an editing of a file from the script?

Thank you very much for any suggestions and what's more important explanations
Smilie
# 4  
Quote:
Originally Posted by bhargav
What type of problem you have encountered with 'vi' ?
The main problem i'm having with vi is, that i understand how to open a file on specific line, the thing I don't get is how to save the changes. For example, I've been trying to do something like this.
Code:
vi +5n myfile
:i 
"Insert some text"
:w
:q

As I said, it only opened editor in Insert mode.
It's probably silly me Smilie
I've tried to use sed, and it helped, although that was the code I've found on Internet, but I don't understand completely the meaning of criterias yet.
p.s. I've managed to solve the given example using temp file, which is being an absolutely time and space consuming solution....
# 5  
You can simply do whatever you want with test in ed/sed/awk etc.
Notice that, you can edit content of file during reading it and forward output from it to other file and after that simple overwrite it e.g. in awk:
Code:
awk 'some_code' some_file > new_file; mv new_file some_file

Or use ed like it:
Code:
ed file <<-ENDIT
g/nrumber_of_line/a/some_new_text/
w
q
ENDIT

depends from your expectations.
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Epic Editor was not able to obtain a license for your use. Feature Epic Editor :Licen
durgaprasadr13
Epic Editor was not able to obtain a license for your use. Feature Epic Editor :License server is down... Solaris
1
Solaris
set EDITOR=vi -> default editor not setting for cron tab
aarora_98
Hi All, I am running a script , working very fine on cmd prompt. The problem is that when I open do crontab -e even after setting editor to vi by set EDITOR=vi it does not open a vi editor , rather it do as below..... ///////////////////////////////////////////////////// $ set...... Shell Programming and Scripting
6
Shell Programming and Scripting
Pasting text in VI editor from a different editor
harishmitty
Hi, I knw its a silly question, but am a newbie to 'vi' editor. I'm forced to use this, hence kindly help me with this question. How can i paste a chunk 'copied from' a different editor(gedit) in 'vi editor'? As i see, p & P options does work only within 'vi'.... UNIX for Dummies Questions & Answers
10
UNIX for Dummies Questions & Answers
VI Editor
doyindayo
I need to delete a line of statement with vi editior in linux, i am using rm but won't work.... UNIX and Linux Applications
3
UNIX and Linux Applications
vi editor
diptiman
suppose i have a lines as follows -rw-r----- 1 ora92 orainst 104846848 Jan 15 2005 0001_0000003971.arc -rw-r----- 1 ora92 orainst 104851456 Jan 15 2005 0001_0000003972.arc -rw-r----- 1 ora92 orainst 104852992 Jan 15 2005 0001_0000003973.arc -rw-r----- 1 ora92 orainst...... Solaris
15
Solaris