Sponsored Content
Top Forums Shell Programming and Scripting sed and special character in data Post 302161023 by MizzGail on Wednesday 23rd of January 2008 11:09:43 AM
Old 01-23-2008
sed and special character in data

I have a script that is reading an existing report, pulling out the customer code, then tacking on the customer name from another file and replacing the existing customer code with the new field. This was written for me by someone else. I'm not real familiar with sed.

The data is getting into the variables correctly, but if the customer name contains a "&" sign, then it repeats the first variable.


My statements are

y=`echo $a$b$i`
z=`echo $a$b$i$b$x`
sed s/"$y "/"$z "/g a.txt > CusT_TmP
cat CusT_TmP a.txt

When I run the script I get back
a=CUST-CD:
b=" "
i=123456
x= W & B

y=CUST-CD: 123456
z=CUST-CD: 123456 W & B Corp

But the entry in the output comes out like

CUST-CD 123456 W CUST-CD 123456 B Corp

Any customer name that I have an & in the name does this.

Any ideas of how to fix this?
Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed-Special character replacement

Hi I want to replace ./testsed.ksh with testsed.ksh ./ is to be removed scriptnm=`sed -e 's/\.///' $0 does not work Please help (3 Replies)
Discussion started by: usshell
3 Replies

2. Shell Programming and Scripting

Decode %s Special Character in Sed

Greetings, I am doing something that I don't know if it is possible... I have a file with a line looks like this: <%s \n%s / %s \n%s \n> and I am trying to replace this line with <%s \n%s \n%s / %s \n%s \n> in Shell script with sed command... StringToReplace='%s \n%s / %s \n%s \n'... (2 Replies)
Discussion started by: wasabihowdi
2 Replies

3. Shell Programming and Scripting

sed special character replace

I need to do the following: text in the format of: ADDRESS=abcd123:1111 - abcd123:1111 is different on every system. replace with: ADDRESS=localhost:2222 sed 's/ADDRESS=<What do I use here?>/ADDRESS=localhost:2222/g' Everything I've tried ends up with: ... (3 Replies)
Discussion started by: toor13
3 Replies

4. Shell Programming and Scripting

how to replace the special character with another using SED

I have the replace the pattern in the file , ); to ); Could someone please help me to get this command. (2 Replies)
Discussion started by: mohan.bit
2 Replies

5. Shell Programming and Scripting

How to substitute variable in sed for special character?

Hi , I have input file like below Hi this is "vinoth". Hi happy to work with 'unix' USA(united states of America) My script variables are below : Dquote=Ộ Squote=&#$567 Obrac=&^986 Cbrac=&^745 I want to read the variables in my SED command to replace the double quote,single... (9 Replies)
Discussion started by: vinothsekark
9 Replies

6. Shell Programming and Scripting

How to replace special character using sed?

How can I replace the follong text including to number 7000? cat tmp0.txt Winston (UK) Wong I would the 7000 to replace Winston (UK) Wong. I fail with method below: sed ' s /Winston\(UK\)Wong/7000 tmp0.txt' (1 Reply)
Discussion started by: vivien_chu
1 Replies

7. UNIX for Dummies Questions & Answers

Replacing special character with sed

Hi All, I have a text file that contains I1SP2 *=*=Y=M=D001D My requirement is to replace all occurrence of =* to =Z expected o/p is I1SP2 *=Z=Y=M=D001D I have tried with sed 's/=*/=Z/g' file sed 's!\=*!\=Z/g' file sed 's!\=*!\=Z!g' file sed 's!\=\*!\=Z!g' file but its not... (3 Replies)
Discussion started by: gotamp
3 Replies

8. Shell Programming and Scripting

sed add special character

Hi all I got test.test.test and need test.test\.test * I need the backslash before the last dot in the line I tried echo test.test.test | sed 's/\./\\./g' but it gives me test\.test\.test Thanks (7 Replies)
Discussion started by: stinkefisch
7 Replies

9. Shell Programming and Scripting

sed command to add special character (')

I have a file (input) which contains are below. Member Analytics Engine Enterprise Manager Dev Tutorial I want to change contains as below by using sed command 'Member Analytics Engine'; 'Enterprise Manager'; 'Dev Tutorial'; First, I tried to add (') on every first line by using sed... (8 Replies)
Discussion started by: anshu ranjan
8 Replies

10. UNIX for Beginners Questions & Answers

With sed replaced special character is printed twice, why?

Dear all, I was wondering If you could help me out. I Am using a batch script to midfy some text files. Input: 912856 912857 912904Amongst others I use this line: REM I want to replace all lines that start with a 6-digit Number with a ftp command "get" followed by a path and the 6-digit... (9 Replies)
Discussion started by: SIEMI
9 Replies
cmmigratepkg(1m)														  cmmigratepkg(1m)

NAME
cmmigratepkg - Migrate Serviceguard legacy Package to a Module Package. SYNOPSIS
cmmigratepkg -p package_name [-x extern_script] [-e] [-s] -o output_filename DESCRIPTION
cmmigratepkg is used to generate a modular package configuration file from a configured legacy package. cmmigratepkg expects the package to be a configured legacy package. The package can be up or down and the cluster can be on-line or off-line. The utility reads the control script of the package, so the package's control script must be located on the node where the command is run. cmmigratepkg can migrate packages created by Serviceguard version A.11.09 through A.11.18. The control script's customer-defined area is any code between "#START CUSTOMER DEFINED FUNCTIONS" and "#END CUSTOMER DEFINED FUNCTION. If the customer-defined area has code that needs to be migrated to the modular package then cmmigratepkg can create an external script by inserting the shell code from the control script into the external_script file. The external script is generated from the external template found in $SGCONF/examples/external_script.template. (See chapter 4 of the Managing Serviceguard manual for more information about the tem- plate.) The external_script_name is the full pathname and file name of the file. The extexternal scriptfile must be copied to each node where the package can run and make sure that the permissions are set to 744, and owned by root. Non-Serviceguard variables defined in the legacy package control script can be converted to user defined parameters called PEV, parameter environment variable. The PEV is defined in the package configuration file and has a prefix of "PEV_". See description under the -e option. The cmmigratepkg displays informational message about the variables which it cannot convert because they are non-Serviceguard variables. If these non-Serviceguard variables are used and defined in the customer defined area then there is no need to convert them to PEV. If they are defined in another location in the control script, and the values should be part of the package, they can be converted to PEV using the -e option. The PEV are defined in the new package configuration file. If non-Serviceguard functions are defined in the legacy package control script, cmmigratepkg lists the non-Serviceguard functions to STD- OUT. These functions are not converted. You must determine if the functions are called and how you want to migrate them to the modular package. You can put them into the new external script file. cmmigratepkg converts legacy failover packages that are configured with: Services, File Systems, Volume groups, Dependencies, EMS Resources, and User Defined Roles to modular packages. cmmigratepkg generates the modular package configuration file in lowercase. The package configuration file has no comments about the pack- age attributes. If the user wants to see comments regarding the package attributes, they can generate a temporary package configuration file using cmmakepkg -v. The following control script parameters are obsolete and the cmmigratepkg gives a warning about them not be able to convert: RAIDSTART, RAIDSTOP, RAIDTAB, MD, GFS, DATA_REP, and DTC_NAME. Note: that cmmigratepkg will not convert CVM3.5 packages or CFS packages. If you are converting packages please see the White paper for more details aboutconverting legacy packages. Options cmmigratepkg supports the following options: -p package_name Name of an existing configured legacy package to convert. -x external_script Name of the external script file to create. -e Generate PEV's from non Serviceguard parameters. All non Serviceguard parameters found in the package control script are con- verted to PEVs. "PEV_" is prepended to the original name. For example, package_root="/srv/colossus", is written as PEV_pack- age_root="/srv/colossus" in the output_file. -s This option comments out service attributes in the output_file. A warning is displayed when the option is used and the package has services defined. When using this option the user should review the output file. -o output_file Name of the output file for the converted package configuration. RETURN VALUE
cmmigratepkg returns the following values: 0 Successful completed. >0 Command failed. EXAMPLES
Converts pkgA writing out new package configuration file. cmmigratepkg -p pkgA -o /etc/cmcluster/pkg/pkgA/pkgA.conf Converts pkgA and also generates an external script. cmmigratepkg -p pkgA -x /etc/cmcluster/pkg/pkgA/external.sh -o /etc/cmcluster/pkg/pkgA/pkgA.conf" AUTHOR
cmmigratepkg was developed by HP. SEE ALSO
cmmakepkg(1m), cmgetconf(1m) Migration White Paper. Requires Optional Serviceguard Software cmmigratepkg(1m)
All times are GMT -4. The time now is 05:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy