Sponsored Content
Top Forums Programming Substitute string using location (preferably perl). Post 302539424 by admax on Sunday 17th of July 2011 11:44:44 AM
Old 07-17-2011
Substitute string using location (preferably perl).

I have a string like.

ATATATATTATTATATTATATTATT

I want to substitute the characters to "C" by using these locations
3 7
10 18
15 20

desired Output:
ATCCCCCTTACCCCCCCCCCTTATT

any clue will be great help. Smilie
thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match keyword on string and substitute under vi

Hi guys, with sed when I need to make a substitution inside a line containing a specific keyword, I usually use: sed '/keyword/ s/cat/dog/g' This will substitute "cat" with "dog" on those lines containing "keyword". Now I want to use this inside vi, for several reason that I cannot... (2 Replies)
Discussion started by: lycaon
2 Replies

2. Shell Programming and Scripting

To substitute a string in a line to another string

Suppose, d=ABC*.BGH.LKJ Now I want to replace 'DEFGHIJ' instead of '*.B' and store the value in d. Any Idea? Can we use sed here? The outout should be like this: d=ABCDEFGHIJGH.LKJ Please help.. (4 Replies)
Discussion started by: Niroj
4 Replies

3. Shell Programming and Scripting

How to substitute brackets in the beginning of string in perl?

Hi, I have a string like this user can specify different query sets that is why "or" is mentioned: $string="]("; or $string="](("; or $string="]((("; or $string="]((((("; (1 Reply)
Discussion started by: vanitham
1 Replies

4. Shell Programming and Scripting

Put one string from one location to another location in a file

Hi Everyone, I have 1.txt here a b c' funny"yes"; d e The finally output is: here a b c d e' funny"yes"; (1 Reply)
Discussion started by: jimmy_y
1 Replies

5. Shell Programming and Scripting

Substitute Perl Script

I am having trouble with a part of my substitute script I am using. I have it look through a file and find an exact match and then if it finds that match in the 1 file it should run the following 1 liner on 3 different files. perl -pi -e 's/$CurrentName\s/$NewName/g' foo.cfg; The issue that is... (8 Replies)
Discussion started by: Takau
8 Replies

6. UNIX for Dummies Questions & Answers

Find and substitute a string

Hi, I started exploring unix recently. Now i have got a requirement like i have a input file where i am having some strings line by line (One string Might be single line or multiple lines). Now i need find these strings in another file and if its found i have to replace it with another string... (2 Replies)
Discussion started by: Sivajee
2 Replies

7. Shell Programming and Scripting

Substitute string with an index number

Objective is to substitute Jan with 01, Feb with 02 and so on. The month will be provided as input. I could construct below awk and it worked. echo Jun | \ awk 'BEGIN{split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",mon," ")}{ for (i=1;i<=12;i++){ if ($1==mon) printf("%02d\n",i)} }' ... (4 Replies)
Discussion started by: krishmaths
4 Replies

8. Shell Programming and Scripting

Grep for string and substitute if exits with a yes/no

Hi I have 3 files in total. file 1 is enriched.txt file2 is repressed.txt and file 3 is my content.txt What i need is query the content file against both enriched and repressed and wherever the gensymbol is same in both the files then add a yes value against it file1 Gene ABC XYZ MNO... (12 Replies)
Discussion started by: Diya123
12 Replies

9. Shell Programming and Scripting

[sed]: Substitute a string with a multiline value

Dear all, I try to replace a string of characters in a file (MyFile.txt) by a multiline value of the variable "Myvar": $ cat MyFile.txt DESCRIPTION '@TargetTable SCHEMA' ( @InputFlowDef ); $ The content of Myvar: $ echo "$Myvar" col1 , col2 , col3 $ (4 Replies)
Discussion started by: dae
4 Replies

10. UNIX for Beginners Questions & Answers

Search a string and display its location on the entire string and make a text file

I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file. Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies
wmemcpy(3)						     Library Functions Manual							wmemcpy(3)

NAME
wmemcpy, wmemchr, wmemcmp, wmemmove, wmemset - Perform memory operations on wide-character arrays LIBRARY
Standard C Library (libc) SYNOPSIS
#include <wchar.h> wchar_t *wmemcpy( wchar_t *wstr1, const wchar_t *wstrs2, size_t n); wchar_t *wmemchr( const wchar_t *wstr, wchar_t wc, size_t n); int wmemcmp( const wchar_t *wstr1, const wchar_t *wstr2, size_t n); wchar_t *wmemmove( wchar_t *wstr1, const wchar_t *wstr2, size_t n); wchar_t *wmemset( wchar_t *wstr, wchar_t wc, size_t n); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: wmemcpy(), wmemchr(), wmemcmp(), wmemmove(), wmemset(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the location of a wide-character string. Points to the location of a destination wide-character string. Points to the location of a source wide-character string. Specifies a wide character for which to search (except for the wmemset() case, in which wc is the tar- get of the copy). Specifies the number of wide characters to search. DESCRIPTION
The wmemcpy(), wmemchr(), wmemcmp(), wmemset(), and wmemmove() functions operate on wide-character strings in memory areas. A memory area is a group of contiguous wide characters bound by a count and not terminated by a null wide character. These memory functions do not check for overflow of the receiving memory area. They are also not affected by locale; therefore, they do not give special treatment to a null wide character or wide-character values that do not correspond to valid multibyte characters. Unless stated otherwise, these functions order two wide characters the same way as two integers of the integral type wchar_t. All of these memory functions are declared in the wchar.h header file. The wmemcpy() function copies n wide characters from the string pointed to by the wstr2 parameter into the location pointed to by the wstr1 parameter. When copying overlapping strings, the behavior of this function is unreliable. The wmemchr() function sequentially searches the wide-character string at the location pointed to by the wstr parameter until one of the following occurs: The wide character specified by the wc parameter has been found. The number of wide characters specified by the n param- eter have been searched at location wstr. If wc is found, the wmemchr() function returns a pointer to that wide character in the string pointed to by wstr. If wc is not found after searching n wide characters, the function returns a null pointer. The wmemcmp() function compares the first n wide characters of the string pointed to by the wstr1 parameter with the first n wide charac- ters of the string pointed to by the wstr2 parameter. This function returns one of the following values: Less than zero if the value of the object in wstr1 is less than the value of the object in wstr2 Zero if the value of object in wstr1 is equal to the value of the object in wstr2 Greater than zero if the value of the object in wstr1 is greater than the value of the object in wstr2 The wmemset() function first copies the value of the wide character specified by the wc parameter into each of the first n locations of the string pointed to by the wstr parameter and then returns the value of wstr. The wmemmove() function copies n wide characters from the string at the location pointed to by the wstr2 parameter to the string at the location pointed to by the wstr1 parameter. Copying takes place as though the n wide characters from string wstr2 are first copied into a temporary array having n wide characters that does not overlap either of the strings pointed to by wstr1 or wstr2. Then, n number of wide characters from the temporary array are copied to the string pointed to by wstr1. Consequently, this operation is nondestructive and pro- ceeds from left to right. The wmemmove() function returns the value of wstr1. When the value of n is zero, all these functions either return zero or copy zero wide characters, depending on whether the purpose of the function is to compare or copy wide characters. RETURN VALUES
The wmemchr() function returns a pointer to the location of wc in wstr or a null pointer if wc is not found in the first n wide characters of wstr. The wmemcmp() function returns a value greater than, equal to, or less than 0 (zero), according to whether the first n wide characters of the string pointed to by the wstr1 parameter have a value greater than, equal to, or less than the first n wide characters in the string pointed to by the wstr2 parameter. The wmemcpy() and wmemmove() functions return the wide-character string pointed to by the wstr1 parameter. The wmemset() function returns the wide-character string pointed to by the wstr parameter. RELATED INFORMATION
Functions: bcopy(3), memccpy(3), string(3), swab(3), wcscat(3), wcsspn(3), wcsstr(3), wcswcs(3) delim off wmemcpy(3)
All times are GMT -4. The time now is 01:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy