Solved

LInux and vi

Posted on 2014-11-17
4
106 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
  • 2
4 Comments
 
LVL 5

Assisted Solution

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

Assisted Solution

by:Dave Gould
Dave Gould earned 250 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 125 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 125 total points
ID: 40447836
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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.

827 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