Sponsored Content
Top Forums Shell Programming and Scripting sed and awk to find pattern and add priffix Post 303022084 by Chubler_XL on Thursday 23rd of August 2018 09:18:08 PM
Old 08-23-2018
Here is another solution. I'm thinking that SR and SFCHT1 should only be matched between [ and ]:

Code:
sed -e '/[[][^]]*SFCHT1[]-]/s/poweredOn/poweredOn|T1/' \
    -e '/[[][^]]*SR[]-]/s/poweredOn/poweredOn|DR/' file.csv


Example:

Code:
$ file.csv
Server1|poweredOn|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)
Server2|poweredOn|268401|[Z0110-DSP-SFCHT1-VMS-R001SM] Not SR/Server1.vmx|Red Hat Enterprise Linux 3.2 (32-bit)
Server3|poweredOn|268401|[Z0109-XXX-PFCHT2-VMS-R001SM] Not SR or SFCHT1/Server1.vmx|Solaris 3.2

$ sed -e '/[[][^]]*SFCHT1[]-]/s/poweredOn/poweredOn|T1/' \
      -e '/[[][^]]*SR[]-]/s/poweredOn/poweredOn|DR/' file.csv
Server1|poweredOn|DR|T1|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)
Server2|poweredOn|T1|268401|[Z0110-DSP-SFCHT1-VMS-R001SM] Not SR/Server1.vmx|Red Hat Enterprise Linux 3.2 (32-bit)
Server3|poweredOn|268401|[Z0109-XXX-PFCHT2-VMS-R001SM] Not SR or SFCHT1/Server1.vmx|Solaris 3.2

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep and sed to find a pattern and add newline

Hello All, I have log file the result from a multithreaded process. So when a process finishes it will write to this log file as 123 rows merged. The issue is sometimes the processess finish at the same time or write to the file at the same time as 123 rows merged.145 rows merged. At... (5 Replies)
Discussion started by: ssikhar
5 Replies

2. Shell Programming and Scripting

Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (2 Replies)
Discussion started by: rajan_san
2 Replies

3. UNIX for Advanced & Expert Users

Urgent Help required : awk/sed help to find pattern and delete till end of line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (1 Reply)
Discussion started by: rajan_san
1 Replies

4. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

5. Shell Programming and Scripting

awk to find pattern and add lines

My file goes like this: SID_LIST_HOSTNAME_LISTENER_3 = (SID_LIST = (SID_DESC = (SID_NAME = ORA0008) (ORACLE_HOME = /opt/oracle/product/ORA0008) (ENVS = "LD_LIBRARY_PATH=/opt/oracle/product/ORA0008/lib") ) (SID_DESC = (SID_NAME = ORA0007) ... (4 Replies)
Discussion started by: jpsingh
4 Replies

6. Shell Programming and Scripting

[Solved] Find duplicate and add pattern in sed/awk

<Update> I have the solution: sed 's/\{3\}/&;&;---;4/' The thread can be marked as solved! </Update> Hi There, I'm working on a script processing some data from a website into cvs format. There is only one final problem left I can't find a solution. I've processed my file... (0 Replies)
Discussion started by: lolworlds
0 Replies

7. Shell Programming and Scripting

using sed to find a pattern

Hi All, I have a file with 100 lines contain a pattern like: input: a,b,4,2343,56456,7656,78787,786234,00:59:16.740 04 17 2012,4564,2453,556 f,j,er,45,fh,67,00:59:45.840 04 25 2012, sdf,grty,rtyr,wqerw output a,b,4,2343,56456,7656,78787,786234,00:59:16.7 04172012,4564,2453,556... (9 Replies)
Discussion started by: mimilaw
9 Replies

8. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies

9. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

10. Shell Programming and Scripting

Using awk or sed to find a pattern that has lines before and after it

Dear gurus, Please help this beginner to write and understand the required script. I am looking for useing awk for sed. I have a few thousand lines file whose contain are mostly as below and I am trying to achieve followings. 1. Find a string, say user1. Then hash the line containing the... (6 Replies)
Discussion started by: ran_bon_78
6 Replies
OBUS-GEN-CLIENT(1)					      General Commands Manual						OBUS-GEN-CLIENT(1)

NAME
obus-gen-client - generate client-side ocaml bindings from D-Bus introspection files SYNOPSIS
obus-gen-client [ options ] input-file DESCRIPTION
obus-gen-client generates an ocaml module from D-Bus introspection files. The generated module contains functions to send method calls, receive signals and read/write properties. It depends on the interface module generated with obus-gen-interface. The module generated by obus-gen-client it is meant to be edited. OPTIONS
-o output-prefix Use this name as output prefix. It defaults to the input file name without its extension and extended with "_client". For example, if the input file name is "foo.xml" (or "foo.obus"), then "obus-gen-client" will generate "foo_client.ml" and "foo_client.mli". -keep-common Keeps common interfaces, i.e. all interfaces starting with "org.freedesktop.DBus". By default they are dropped. -help or --help Display a short usage summary and exit. AUTHOR
Jeremie Dimino <jeremie@dimino.org> SEE ALSO
obus-introspect(1), obus-gen-interface(1), obus-gen-server(1). April 2010 OBUS-GEN-CLIENT(1)
All times are GMT -4. The time now is 07:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy