Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Need help to use regex to do search and replace. Don't know how to and can't figure out how :( Post 303026916 by newbie_01 on Wednesday 5th of December 2018 06:06:31 AM
Old 12-05-2018
Need help to use regex to do search and replace. Don't know how to and can't figure out how :(

Hi,

Below is an excerpt from a 20000+ lines and I want to do a search and replace of a specific string but I don't know how and I can't figure out how to. Can't find an example from Google or anywhere to do what I am wanting to do.

Code:
A                    2018-11-21 08:42:17 TEST_TEST 2018-11-21 00:50:45 Accessed:   2,146,893,824 /NFS_mnt/mnlNFS111/vol_abcp_db/abcp/.snapshot/mnl1ns123_vol_abcp_db_ss.0/db/temp/abcp_temp_10.dbf
A                    2018-11-21 08:41:52 TEST_TEST 2018-11-21 00:50:45 Accessed:   2,146,697,216 /NFS_mnt/mnlNFS111/vol_abcp_db/abcp/.snapshot/mnl1ns123_vol_abcp_db_ss.0/db/temp/abcp_temp_9.dbf
A                    2018-11-21 03:29:04 TEST_TEST 2017-06-17 22:01:33 Accessed:          22,528 /NFS_mnt/mnlNFS111/vol_abcp_db/abcp/.snapshot/mnl1ns123_vol_abcp_db_ss.0/db/LTS/abcp_ABCD_TEST_COMM_P201406_tts_exp.dta
A                    2018-11-21 03:28:57 TEST_TEST 2017-06-17 22:01:28 Accessed:     563,101,696 /NFS_mnt/mnlNFS111/vol_abcp_db/abcp/.snapshot/mnl1ns123_vol_abcp_db_ss.0/db/LTS/abcp_abcd_test_comm_201406_data_01.dbf

I need to search for all lines that contain the string /db/LTS/abcp_ but only those that ends in .dbf. So from the excerpts above, it should find the line below:

Code:
A                    2018-11-21 03:28:57 TEST_TEST 2017-06-17 22:01:28 Accessed:     563,101,696 /NFS_mnt/mnlNFS111/vol_abcp_db/abcp/.snapshot/mnl1ns123_vol_abcp_db_ss.0/db/LTS/abcp_abcd_test_comm_201406_data_01.dbf

And I want to replace them so it so that it will be

Code:
A                    2018-11-21 03:28:57 TEST_TEST 2017-06-17 22:01:28 Accessed:     563,101,696 /NFS_mnt/mnlNFS111/vol_abcp_db/abcp/.snapshot/mnl1ns123_vol_abcp_db_ss.0/db/LTS/abct_abcd_test_comm_201406_data_01.dbf

So, basically I need to change /db/LTS/abcp_ to /db/LTS/abct_. It is the one in BOLD that I am wanting to search and replace.
The grep regex below seems to do what I wanted. But I don't know how to do like a sed search and replace thing Smilie

Code:
$: grep "/db/LTS/abcp_.*dbf$" xx.txt
A                    2018-11-21 03:28:57 TEST_TEST 2017-06-17 22:01:28 Accessed:     563,101,696 /NFS_mnt/mnlNFS111/vol_abcp_db/abcp/.snapshot/mnl1ns123_vol_abcp_db_ss.0/db/LTS/abcp_abcd_test_comm_201406_data_01.dbf

Any help will be much appreciated.

P.S.:
- Is there any way to colorize or highlight certain text? I was hoping to be able to do that in this post but can't find the option to do so. I thought that option was available on the older forum ??? Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

2. Programming

I don't know how to replace input char with appropriate integer

Hi guys, I asked for help on programming forums and no one didn't helped me so I ask for help here. I am playing with some tasks from my book and I can't figure where did I get wrong. From the first program I get a blank screen, program won't generate 10*10 matrix. And second problem is I... (6 Replies)
Discussion started by: solaris_user
6 Replies

3. Emergency UNIX and Linux Support

search replace regex question

Hi, I need to run a search and replace on a large database, what I need to change is all instances of #### (eg. 1764 or 1964) to (####) (eg. (1764) or (1964)) But there might be other numbers in there such as (1764) and I do not need those changed to ((1764)) How can I... (7 Replies)
Discussion started by: lawstudent
7 Replies

4. Shell Programming and Scripting

Regex:search/replace but not for escaped character

Hi Input: - -- --- ---- aa-bb-cc aa--bb--cc aa---bb---cc aa----bb----cc Output: . - -. -- aa.bb.cc (7 Replies)
Discussion started by: chitech
7 Replies

5. Shell Programming and Scripting

Perl:Regex for Search and Replace that has a flexible match

Hi, I'm trying to match the front and back of a sequence. It works when there is an exact match (obviously), but I need the regex to be more flexible. When we get strings of nucleotides sometimes their prefixes and suffixes aren't exact matches. Sometimes there will be an extra letter and... (2 Replies)
Discussion started by: jdilts
2 Replies

6. Shell Programming and Scripting

Regex - search and replace

I have file which contains data in the following format all in a single line: BDW_PUBLN_ID DECIMAL(18:0) NOT NULL PRIMARY INDEX ARGO_ACCT_DEP_PI ( OFC_ID ,CSHBX_ID ,TRXN_SEQ_NUM ,PROCG_DT ) PARTITION BY RANGE_N(PROCG_DT BETWEEN DATE '2012-03-01' AND DATE '2014-12-31' EACH INTERVAL '1' MONTH );... (4 Replies)
Discussion started by: ysvsr1
4 Replies

7. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

8. Shell Programming and Scripting

Multi line regex for search and replace

I have text file like below: a.txt Server=abc Run=1 Time=120.123 Tables=10 Sessions=16 Time=380.123 Version=1.1 Jobs=5 Server=abc Run=2 Time=160.123 Tables=15 Sessions=16 Time=400.258 Version=2.0 (1 Reply)
Discussion started by: sol_nov
1 Replies

9. Red Hat

Centos server, had to replace the motherboard now the embedded NICs don't work

Basically what the title says. Had to replace the motherboard on an HP DL380 G6 today, of course now the embedded NICs don't work because the ifcfg-eth files have the MAC addresses for the embedded NICs from the old machine. How can I find the new/correct MAC addresses so I can edit the... (2 Replies)
Discussion started by: xdawg
2 Replies

10. Shell Programming and Scripting

Search Replace Specific Column using RegEx

Have Pipe Delimited File: > BRYAN BAKER|4/4/2015|518 VIRGINIA AVE|TEST > JOE BAXTER|3/30/2015|2233 MockingBird RD|ROW2On 3rd column where the address is located, I want to add a space after every numeric value - basically doing a "s//&\ / ": > BRYAN BAKER|4/4/2015|5 1 8 VIRGINIA AVE|TEST > JOE... (5 Replies)
Discussion started by: svn
5 Replies
smd-client(1)						 Sync Mail Dir (smd) documentation					     smd-client(1)

NAME
smd-client - receives diffs and performs actions SYNOPSIS
smd-client [-v|--verbose] [-d|--dry-run] [-t|--translator] [-l|--local-sync] [--rename-only] [--override-db dbf] endpoint mailboxes DESCRIPTION
smd-client needs to know a name (endpoint) for the client (that must not be used by others) and a list of mailboxes (directories). smd-client waits on stdin a mail dir diff. It attempts to execute these actions, eventually asking data printing commands on stdout and expecting the data on stdin. OPTIONS
-t --translator Specify a program to translate remote mailbox names to local ones. Note that the translator 'cat' (the identity program) is opti- mized away -l --local-sync Local synchronization, no changes is made to the db-file since smd-server takes care of it --rename-only Do not synchronize the mailboxes but generate the script '~/smd-rename.sh' to uniform the files names in the mailbox --override-db dbf Use dbf as the db-file -v --verbose Increase program verbosity (printed on stderr) -d --dry-run Do not perform any action for real NOTES
smd-client is a low level utility. You should use higher level tools like smd-pull(1) and smd-push(1) SEE ALSO
mddiff(1), smd-server(1), smd-pull(1), smd-push(1) AUTHOR
Enrico Tassi <gares@fettunta.org> 11 June 2012 smd-client(1)
All times are GMT -4. The time now is 02:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy