Sponsored Content
Top Forums Shell Programming and Scripting Replace, insert n times a specific character Post 302350725 by peterro on Friday 4th of September 2009 05:54:21 PM
Old 09-04-2009
Couple ways I can think of doing something like this. Search/replace all instances of 'A' with 'XXXXXXXXXX':

Code:
:%s/A/XXXXXXXXXX/g

or.. search for the character you want with '/A'. Once found (or before) map a key to perform the switch on the next character in your search:

Code:
:map v nxiXXXXXXXXXX^V[ESC]

I tend to use 'v' as my mapped key since it isn't used for anything else.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert character in a specific position of a file

Hi, I need to add Pipe (|) at 5th and 18th position of all records a file. How can I do this? I tried to add it at 5th position using the below code. It didnt work. Please help!!! awk '{substr($0,5,1) ~ /|/}{print}' $input_file > $temp_file (1 Reply)
Discussion started by: gpaulose
1 Replies

2. Shell Programming and Scripting

Using sed to replace specific character and specific position

I am trying to use sed to replace specific characters at a specific position in the file with a different value... can this be done? Example: File: A0199999123 A0199999124 A0199999125 Need to replace 99999 in positions 3-7 with 88888. Any help is appreciated. (5 Replies)
Discussion started by: programmer22
5 Replies

3. Shell Programming and Scripting

how to replace specific character , if possible using sed

My script is extracting data from SQl session, however sometimes the result contains one or multiple space after/before any numerical value. e,g . "123","1 34","1 3 45", "43 5" How to remove these unwanted spaces..so that I can get the following result : "123","134",1345","435" (1 Reply)
Discussion started by: mady135
1 Replies

4. Shell Programming and Scripting

Help with replace character based on specific location

Hi, I got long list of reference file (column one is refer to the header in input file; column 2 is info of start position in input file; column 3 is info of end position in input file;) shown as below: read_2 10 15 read_3 5 8 read_1 4 10 . . . Input file (huge file with total... (6 Replies)
Discussion started by: perl_beginner
6 Replies

5. Shell Programming and Scripting

How to replace a character in a specific column in a file?

This is a file that I have test line 1 (55) ) test line 2 (45) ) I would like to change all the parens in position 1 of this file to a ); i only want to check position 1 in every line of the file. I have tried different varations of sed, but cannot seem to be able to limit it to... (1 Reply)
Discussion started by: JoeG
1 Replies

6. UNIX for Advanced & Expert Users

Replace certain character at specific place with related character

hello i have file with 100k records and each one has certain value that starts at 28th column and certain value that starts at 88th column e.g. 1st file <25>1234567 ..... <88> 8573785485 i have aditional file with values which are related to value that starts at 88th column of the... (1 Reply)
Discussion started by: dell1520
1 Replies

7. Shell Programming and Scripting

Insert character at specific location in a each line of the file

Hi All, I am trying to write a shell script where it should insert character 'I' in 180th position of each line(except first and last line) of the file. Below is the script for file in /home/test/bharat/*.RET do # Process file echo "File Name=" $file #l_fileName="${file##*/}" ... (19 Replies)
Discussion started by: bharath561989
19 Replies

8. Post Here to Contact Site Administrators and Moderators

Search for a pattern and replace a space at specific position with a Character in File

In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123. So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
3 Replies

9. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

10. UNIX for Beginners Questions & Answers

How to insert new line after a specific character in scripts?

Hi, I'm trying to add a new line after finding a specific String. That is my string: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html and I want to change that file to: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html extra_hosts: -... (4 Replies)
Discussion started by: siamak
4 Replies
times(1)                                                           User Commands                                                          times(1)

NAME
times - shell built-in function to report time usages of the current shell SYNOPSIS
sh times ksh times DESCRIPTION
sh Print the accumulated user and system times for processes run from the shell. ksh Print the accumulated user and system times for the shell and for processes run from the shell. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), sh(1), time(1), attributes(5) SunOS 5.10 15 Apr 1994 times(1)
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy