Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Search and replace to first occurrence of string Post 302072454 by gilmord on Wednesday 3rd of May 2006 05:58:06 AM
Old 05-03-2006
Done it! The part after AVG_ is always * characters or less, so this works:

:%s/AVG_\([A-Z0-9]\{1,8\};\)/AVG_\1Average /
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

2. Shell Programming and Scripting

SED replace string by occurrence

hi all, I have a text file with following content PAGENUMBER asasasa asasasa PAGENUMBER sasasasasa PAGENUMBER using sed i want to replace PAGENUMBER by occurrence count eg 1 asasasa asasasa 2 sasasasasa 3 (4 Replies)
Discussion started by: uttamhoode
4 Replies

3. UNIX for Dummies Questions & Answers

Search for a string and replace the searched string in the same position in samefile

Hi All, My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found in the same file..The... (27 Replies)
Discussion started by: ganesh_248
27 Replies

4. Shell Programming and Scripting

Search, replace string in file1 with string from (lookup table) file2?

Hello: I have another question. Please consider the following two sample, tab-delimited files: File_1: Abf1 YKL112w Abf1 YAL054c Abf1 YGL234w Ace2 YKL150w Ace2 YNL328c Cup9 YDR441c Cup9 YDR442w Cup9 YEL040w ... File 2: ... ABF1 YKL112W ACE2 YLR131C (9 Replies)
Discussion started by: gstuart
9 Replies

5. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

6. Shell Programming and Scripting

Replace x Number of String Occurrence with Sed

Ok, So I have a huge file that has over 12000 lines in it. in this file, there are 589 occurrences of the string "use five-minute-interval" spread in various areas in the file. How can i replace the the last 250 of the occurrences of "use five-minute-interval" with "use... (10 Replies)
Discussion started by: SkySmart
10 Replies

7. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies

8. AIX

Replace consecutive occurrence of string in same line

Hi All, I have a requirement to replace consecutive occurence of same string nedd to be replaced. Below is the input and desired output. Input: --------- 123.5|ABC|.|.|. 234.4|DEF|.|.|.|.|.| Output: --------- 123.5|ABC|||. 234.4|DEF||||| so basically "|.|" need to be replaced with... (9 Replies)
Discussion started by: ureddy
9 Replies

9. Shell Programming and Scripting

Replace first occurrence of a string in while loop

####Solved#### Hello, My aim is to replace searched string with incremented value under ubuntu 16.04. Example: aasasasas 9030 31wwo weopwoep weerasas 9030 ew31wo ieopwoep bbqqqsas 9030 ew3swo ieeopwoep ccsaqpas 9030 ewiro o2opwoep Expected: aasasasas 9030 31wwo weopwoep weerasas 9031... (2 Replies)
Discussion started by: baris35
2 Replies

10. UNIX for Beginners Questions & Answers

Search partial string in a file and replace the string - UNIX

I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this. string(Scenario 1)- user::r--,user::ourfrd:r-- String(Scenario 2)- user::r-- File **** # file: /local/Desktop/myfile # owner: me # group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies
memory(3)						     Library Functions Manual							 memory(3)

Name
       memccpy, memchr, memcmp, memcpy, memmove, memset - memory operations

Syntax
       #include <string.h>

       void *memccpy (s1, s2, c, n)
       void *s1, *s2;
       int c;
       size_t n;

       void *memchr (s, c, n)
       void *s;
       int c;
       size_t n;

       int memcmp (s1, s2, n)
       void *s1, *s2;
       size_t n;

       void *memcpy (s1, s2, n)
       void *s1, *s2;
       size_t n;

       void *memset (s, c, n)
       void *s;
       int c;
       size_t n;

       void *memmove (s1, s2, n)
       void *s1, *s2;
       size_t n;

Description
       These functions operate efficiently on memory areas (arrays of characters bounded by a count, not terminated by a null character).  They do
       not check for the overflow of any receiving memory area.

       The subroutine copies characters from memory area s2 into s1, stopping after the first occurrence of character c has been copied, or  after
       n  characters  have been copied, whichever comes first.	It returns a pointer to the character after the copy of c in s1, or a NULL pointer
       if c was not found in the first n characters of s2.

       The subroutine returns a pointer to the first occurrence of character c in the first n characters of memory area s, or a NULL pointer if  c
       does not occur.

       The  subroutine compares its arguments, looking at the first n characters only, and returns an integer less than, equal to, or greater than
       0, according as s1 is lexicographically less than, equal to, or greater than s2.

       The subroutine copies n characters from memory area s2 to s1.  It returns s1.

       The subroutine is like , except that if s1 and s2 specify overlapping areas, works as if an intermediate buffer is used.

       The subroutine sets the first n characters in memory area s to the value of character c.  It returns s.

Restrictions
       The subroutine uses native character comparison, which is signed on PDP-11s, unsigned on other machines.

       Character movement is performed differently in different implementations of and Thus overlapping moves, using these subroutines, may  yield
       unpredictable results.

																	 memory(3)
All times are GMT -4. The time now is 05:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy