Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] Replace the second pattern alone in VI. Post 302877821 by gctex on Tuesday 3rd of December 2013 12:44:21 PM
Old 12-03-2013
[Solved] Replace the second pattern alone in VI.

I have lines like:
Code:
table10 table_name_10 table10 table_name_10
table20 table_name_20 table20 table_name_20
table30 table_name_30 table30 table_name_30

I want to change the second "table_names" in all lines to test_table_name. Required output would be:

Code:
table10 table_name_10 table10 test_table_name_10
table20 table_name_20 table20 test_table_name_20
table30 table_name_30 table30 test_table_name_30

How do I do that in VI editor?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED Search Pattern and Replace with the Pattern

Hello All, I have a string "CP_STATUS OSSRC_R6_0_Shipment_R1H_CU AOM_901046 R1H_LLSV1_2008031", and I just want to extract LLSV1, but I dont get the expected result when using the sed command below. # echo "CP_STATUS OSSRC_R6_0_Shipment_R1H_CU AOM_901046 R1H_LLSV1_2008031" | awk '{print... (4 Replies)
Discussion started by: racbern
4 Replies

2. Shell Programming and Scripting

perl:: search for tow pattern and replace the third pattern

Hi i want to search two pattern on same line and replace onther pattern.. INPut file aaaa bbbbb nnnnnn ttttt cccc bbbbb nnnnnn ppppp dddd ccccc nnnnnn ttttt ffff bbbbb oooooo ttttt now i want replace this matrix like.. i want search for "bbbbb","nnnnnn" and search and replace for... (4 Replies)
Discussion started by: nitindreamz
4 Replies

3. Shell Programming and Scripting

[solved] remove pattern with sed

Hi, i want to remove a certain pattern when i type pwd. pwd will look like this: ..../....../....../Pat_logs/..../....../...../...... the dotted lines are just random directory names, i want it to remove the "Pat_logs/...../....../....../" part so for example: ... (8 Replies)
Discussion started by: a27wang
8 Replies

4. Shell Programming and Scripting

replace pattern after the first pattern match

I need this. aaa OOOOO bbb ccc OOOOO ddd fff ggg OOOOO iii OOOOO I need all OOOOO replaced with PPPPP, but only change after the pattern ggg. So the first two OOOOO should not be changed. OUTPUT should be :- aaa (2 Replies)
Discussion started by: anilcliff
2 Replies

5. Shell Programming and Scripting

pattern match and replace another pattern in same line

I have a pattern username:x:32005:32006::/usr/local/user:/bin/bash I need to match the line containing username and replace /bin/bash with /usr/local/my/bin/noshell So it becomes username:x:32005:32006::/usr/local/user:/usr/local/my/bin/noshell (7 Replies)
Discussion started by: anilcliff
7 Replies

6. Shell Programming and Scripting

[SOLVED] Replace a string in nextline after searching a pattern

Hi, I have a requirement where I need to replace a string in a line and this line will be identified by search criteria on previous line: E.g.: I have an xml file and Contents as below: <Root> <NameValue> <name>Global/Text/Data</name> <value>This is valid... (14 Replies)
Discussion started by: mailing2vamsi
14 Replies

7. Shell Programming and Scripting

Linux: replace pattern with pattern

Hi, I am a rookie of Linux. I have a problem on how can I replace a certain pattern in Linux with nothing. Can anyone help me?:( sample.txt: <binding>App189 ABC SampleMachine1 ABC XXX YYY ZZZ </binding> <binding>App190 ABC SampleMachine2 ABC XXX YYY ZZZ </binding> <binding>App191... (3 Replies)
Discussion started by: dirkaulo
3 Replies

8. UNIX for Dummies Questions & Answers

[Solved] Extract a pattern using sed or cut

Hi, Need help to extract a pattern using sed or cut or any other means. Input 'name1',1234567890 'name2',2222222222 'name3',3333333333 Expected output name1,1234567890 name2,2222222222 name3,3333333333 (3 Replies)
Discussion started by: mukulverma2408
3 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Replace NA with column mean

Hi experts, I'm looking for a unix solution to replacing "NA" within a matrix with the mean of the column: $cat file ID a b c d day 10 5 100 50 cat 20 6 200 50 dog NA 8 NA 50 car 15 NA NA ... (3 Replies)
Discussion started by: torchij
3 Replies

10. Shell Programming and Scripting

sed command to replace two character pattern with another pattern

Not able to paste my content. Please see the attachment :-( (2 Replies)
Discussion started by: vivek d r
2 Replies
PG_COPY_FROM(3) 														   PG_COPY_FROM(3)

pg_copy_from - Insert records into a table from an array

SYNOPSIS
bool pg_copy_from (resource $connection, string $table_name, array $rows, [string $delimiter], [string $null_as]) DESCRIPTION
pg_copy_from(3) inserts records into a table from $rows. It issues a COPY FROM SQL command internally to insert records. PARAMETERS
o $connection - PostgreSQL database connection resource. o $table_name - Name of the table into which to copy the $rows. o $rows - An array of data to be copied into $table_name. Each value in $rows becomes a row in $table_name. Each value in $rows should be a delimited string of the values to insert into each field. Values should be linefeed terminated. o $delimiter - The token that separates values for each field in each element of $rows. Default is TAB. o $null_as - How SQL NULL values are represented in the $rows. Default is N ("\N"). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 pg_copy_from(3) example <?php $db = pg_connect("dbname=publisher") or die("Could not connect"); $rows = pg_copy_to($db, $table_name); pg_query($db, "DELETE FROM $table_name"); pg_copy_from($db, $table_name, $rows); ?> SEE ALSO
pg_copy_to(3). PHP Documentation Group PG_COPY_FROM(3)
All times are GMT -4. The time now is 01:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy