Solved

VI - how to replace arbitary column(s)

Posted on 2004-10-05
2
592 Views
Last Modified: 2010-04-21
I've used vi and unix for years but I've never found a good way to do this.

I want to search and replace based on column/character number

the search part I can do by

/^......<correct number of .>...X/

given its an 'X' in the column I want but I can't do

:1,$s/^.............................X/.....................Y/

unless I want all .'s in the file
0
Comment
Question by:NickUpson
[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
2 Comments
 
LVL 21

Expert Comment

by:tfewster
ID: 12226932
:1,$s/^\(....\)X/\1Y/
0
 
LVL 21

Accepted Solution

by:
tfewster earned 500 total points
ID: 12226966
The way I understand this is:
Look for X in the 5th column;  "Remember" the characters in the columns 1-4 (4 .'s) in a sed variable.
Subsitute the "pattern" found with \1Y, where \1 is the contents of the variable
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

751 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