Solved

VI - how to replace arbitary column(s)

Posted on 2004-10-05
2
584 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
  • 2
2 Comments
 
LVL 20

Expert Comment

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CPU monthly average? 12 133
FTP on FreeBSD server 2 141
What are recommended OS for exim mail server? 10 116
Remote Change Dates on AIX Automation 7 71
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…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
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 video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

820 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