Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LInux and vi

Posted on 2014-11-17
4
Medium Priority
?
110 Views
Last Modified: 2014-11-18
Using vi, I need to search for all occurances of 8585 and replace it with 8586 in a single command

How can I do this?

Thanks
0
Comment
Question by:Anthony Lucia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Assisted Solution

by:Dave Gould
Dave Gould earned 1000 total points
ID: 40447445
Escape
:1,$s/8585/8586/g
0
 
LVL 5

Assisted Solution

by:Dave Gould
Dave Gould earned 1000 total points
ID: 40447457
To explain:
1,$ = from line 1 to end of file

s/8585/8586/ = substitute 8585 with 8586 . The / char can be replaced by almost any other character - some people prefer #, for example, especially when manipulating paths in a file

g = global ie it will change all occurences of 8585 if there are more than one occurence on a single line
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 500 total points
ID: 40447562
:%s/8585/8586/g

2 characters less :)

% means every line in the file
0
 
LVL 25

Assisted Solution

by:madunix
madunix earned 500 total points
ID: 40447836
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question