LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-02-2011, 06:12 AM   #1
texasj
LQ Newbie
 
Registered: Feb 2011
Posts: 23

Rep: Reputation: 2
Question inserting same word on different lines in vi


Hi everybody,
I am having problem in adding a word in same place on different line in vi editor (/bin/bash), hope someone is having solution for this..! (O.S is RHEL5 )

echo "enter your name: "
echo "enter your surname: "
echo "enter your address: "
echo "enter your city: "

I want to insert -n
so as to see the output as follows
echo -n "enter your name: "
echo -n "enter your surname: "
echo -n "enter your address: "
echo -n "enter your city: "
 
Old 08-02-2011, 06:18 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

Using vi(m):
Code:
:%s/echo "/echo -n "/
Using sed:
Code:
sed -i 's/echo "/echo -n "/' infile
Hope this helps.
 
1 members found this post helpful.
Old 08-02-2011, 07:25 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
shorter vi/vim
Code:
:%s/echo/echo -n/
 
1 members found this post helpful.
Old 08-04-2011, 12:28 AM   #4
texasj
LQ Newbie
 
Registered: Feb 2011
Posts: 23

Original Poster
Rep: Reputation: 2
Thanks veeeeery much druuna & chrism01
 
Old 08-04-2011, 02:37 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
@texasj: You're welcome
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] help with inserting mutiple lines usign sed puth Programming 2 02-13-2010 04:40 PM
print second word in 1st line along with 5th word in all the lines after the first bangaram Programming 5 08-31-2009 04:42 AM
Inserting first two lines into a file ZAMO Programming 2 09-04-2008 09:20 AM
Inserting blank lines in text file David the H. Linux - General 5 11-24-2007 04:34 PM
Inserting lines into a file through shell scripting false-hopes Linux - General 1 10-22-2005 12:39 PM


All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration