Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to replace certain patterns in a file thru unix!! Post 6191 by mexx_freedom on Friday 31st of August 2001 12:10:20 AM
Old 08-31-2001
Data

Hi optimus,
i turned the knob!
looked in regular expresions too, but all i cud find is pattern replacement but noting on positional replacement!
Help if u can plzzz.
Regards
Manish
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching patterns in 1 file and deleting all lines with those patterns in 2nd file

Hi Gurus, I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
Discussion started by: toms
4 Replies

2. UNIX for Dummies Questions & Answers

replace multiple patterns in a string/filename

This should be somewhat simple, but I need some help with this one. I have a bunch of files with tags on the end like so... Filename {tag1}.ext Filename2 {tag1} {tag2}.ext I want to hold in a variable just the filename with all the " {tag}" removed. The tag can be anything so I'm looking... (4 Replies)
Discussion started by: kerppz
4 Replies

3. Shell Programming and Scripting

Need help in retrieving log from a UNIX file using the search patterns

Hi everyone, I am trying to retrieve certain log from a big file. The log size can be from 200 - 600 lines. I have 3 search patterns, out of which 2 (first and last lines) search patterns are common for all the transactions but 3rd search pattern (occurs in the middle of transaction) is... (5 Replies)
Discussion started by: msrayudu
5 Replies

4. Shell Programming and Scripting

Replace patterns in a file

Hi all, I here have a file which contains a list of files inside, all of which have the suffix ".log". And now I would wish to replace all the pattern ".log" with ".log.bz2" there. So how could I archive this? Thanks (4 Replies)
Discussion started by: isaacniu
4 Replies

5. Shell Programming and Scripting

Search and replace multiple patterns in a particular column only - efficient script

Hi Bigshots, I have a pattern file with two columns. I have another data file. If column 1 in the pattern file appears as the 4th column in the data file, I need to replace it (4th column of data file) with column 2 of the pattern file. If the pattern is found in any other column, it should not... (6 Replies)
Discussion started by: ss112233
6 Replies

6. Shell Programming and Scripting

Replace multiple patterns together with retaining the text in between

Hi Team I have the following text in one of the file j1738-abc-system_id(in.value1)-2838 G566-deF-system_id(in.value2)-7489 I want to remove system_id(...) combination completely The output should look like this j1738-abc-in.value1-2838 G566-deF-in.value2-7489 Any help is appreciated... (4 Replies)
Discussion started by: Thierry Henry
4 Replies

7. Shell Programming and Scripting

Bash - Find files excluding file patterns and subfolder patterns

Hello. For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Discussion started by: jcdole
2 Replies

8. UNIX for Beginners Questions & Answers

awk Replace Multiple patterns within a list_file with One in target_file

I'm facing a problem 1) I got a list_file intended to be used for inlace replacement like this Replacement pattern ; Matching patterns EXTRACT ___________________ toto ; tutu | tata | tonton | titi bobo ; bibi | baba | bubu | bebe etc. 14000 lines !!! ... (5 Replies)
Discussion started by: mpvphd
5 Replies

9. Shell Programming and Scripting

Sed, how replace specific symbols between two patterns

I have a big xmltv file with many lines like: <?xml version="1.0" encoding="UTF-8"?> <tv> <channel id="channel 1 +3HD"> <display-name lang="it">channel +3HD</display-name> <icon src="http://mywebsite.com/dsgbnjfdc65657/channel +3HD.png" /> ... (8 Replies)
Discussion started by: Tapiocapioca
8 Replies

10. UNIX for Beginners Questions & Answers

Grep multiple patterns(file) and replace whole line

I am able to grep multiple patterns which stored in a files. However, how could we replace the whole line with either the pattern or new string? For example: pattern_file: *Info in the () is not part of the pattern file. They are the intended name to replace the whole line after the pattern... (5 Replies)
Discussion started by: wxboo
5 Replies
strmerge(1int)															    strmerge(1int)

Name
       strmerge - batch string replacement

Syntax
       strmerge [ -m prefix ] [ -p patternfile ] [ -s string ] source-program...

Description
       The  command  reads  the strings specified in the message file produced by and replaces those strings with calls to the message file in the
       source program to create a new source program. The new version of source program has the same name as the input source  program,  with  the
       prefix nl_. For example, if the input source program is named the output source program is named You use this command to replace hard-coded
       messages (text strings identified by the command) with calls to the function and to create a source message catalog file. The  source  mes-
       sage  catalog  contains the text for each message extracted from your input source program. The command names the file by appending .msf to
       the name of the input source program. For example, the source message catalog for the program is named You can use the source message cata-
       log as input to the command.

       At  run	time, the program reads the message text from the message catalog.  By storing messages in a message catalog, instead of your pro-
       gram, you allow the text of messages to be translated to a new language or modified without the source program being changed.

       In the source-program argument, you name one or more source programs for which you want strings replaced. The command does not replace mes-
       sages  for source programs included using the directive. Therefore, you might want a source program and all the source programs it includes
       on a single command line.

       You can create a patterns file (as specified by patternfile ) to control how the command replaces text. The patterns file is  divided  into
       several	sections, each of which is identified by a keyword. The keyword must start at the beginning of a new line, and its first character
       must be a dollar sign ($).  Following the identifier, you specify a number of patterns. Each pattern begins on a new line and  follows  the
       regular expression syntax you use in the editor. For more information on the patterns file, see the reference page.

Options
       -m   Add  prefix  to  message  numbers in the output source program and source message catalog.	You can use this prefix as a mnemonic. You
	    must process source message catalogs that contain number prefixes using the option.  Message numbers will be in the form:
	    <prefix><msg_num>

	    Set numbers will be in the form:
	    S_<prefix><set_num>

	    If you process your input source program with this option, the resulting source program and source message catalog may not	be  porta-
	    ble.  For more information, see the Guide to Developing International Software.

       -p   Use  patternfile  to  match strings in the input source program.  By default, the command searches for the pattern file in the current
	    directory, your home directory and finally

	    If you omit the option, the command uses a default patterns file that is stored in

       -s   Write string at the top of the source message catalog. If you omit the option, uses the string specified in the section  of  the  pat-
	    terns file.

Restrictions
       You can specify only one rewrite string for all classes of pattern matches.

       The command does not verify if the message text file matches the source file being rewritten.

       The command does not replace strings to files included with directive. You must run the command on these files separately.

Examples
       The following produces a message file for a program called
       % strextract -p c_patterns prog.c prog2.c
       % vi prog.msg
       % strmerge -p c_patterns prog.c prog2.c
       % gencat prog.cat prog.msf
       % vi nl_prog.c
       % vi nl_prog2.c
       % cc nl_prog.c nl_prog2.c -li

       In this example, the command uses the file to determine which strings to match. The input source programs are named and

       If  you	need  to  remove  any  of the messages or extract one of the created strings, edit the resulting message file, Under no conditions
       should you add to this file. Doing so could result in unpredictable behavior.

       You issue the command to replace the extracted strings with calls to the message catalog.  In response to this command, creates the  source
       message catalogs, and and the output source programs, and

       Before compiling the source programs, you must edit and to include the appropriate and function calls.

       The command creates a message catalog and the command creates an executable program.

See Also
       intro(3int), extract(1int), gencat(1int), strextract(1int), trans(1int), regex(3), catopen(3int), catgets(3int), patterns(5int)
       Guide to Developing International Software

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