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
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
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
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
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
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 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
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
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
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
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
fruadm(1M) System Administration Commands fruadm(1M)
NAME
fruadm - prints and updates customer data associated with FRUs
SYNOPSIS
/usr/platform/sun4u/sbin/fruadm
/usr/platform/sun4u/sbin/fruadm -l
/usr/platform/sun4u/sbin/fruadm [-r] path [text]
DESCRIPTION
fruadm prints or sets the customer data for Field-Replaceable Units (FRUs).
Without arguments, fruadm prints the paths of all FRU ID-capable FRUs (containers) in the system, along with the contents of the customer
data record, if present, for each such FRU; for FRUs without customer data, fruadm prints only the container's path.
Only a privileged user can create or update data in containers. The privileges required to perform these write operations are hardware
dependent. Typically, a default system configuration restricts write operations to the superuser or to the platform-administrator user.
OPTIONS
The following options are supported:
-l List the system's frutree paths.
-r Recursively display or update the data for all containers rooted at the argument path.
OPERANDS
The following operands are supported:
path A full or partial system frutree path for or under which to print or set the customer data. The first field of each
line of output of fruadm -l gives the valid full frutree paths for the system.
Paths can include shell meta-characters; such paths should be quoted appropriately for the user's shell. For par-
tial paths, the first matching full path is selected for display or update. Without the -r option, the path must be
that of a container; with the -r option, all containers (if any) under path will be selected.
text Up to 80 characters of text set as the customer data. If the text contains white space or shell metacharacters, it
should be quoted appropriately for the user's shell.
EXAMPLES
Example 1: Displaying All Customer Data
The following example prints all customer data available from FRUs on the system. For containers with no customer data, only the contain-
ers' paths will be listed.
example% fruadm
Example 2: Displaying Customer Data For a Single FRU
The following command prints the customer data, if present, for the specified FRU:
example% fruadm /frutree/chassis/system-board
Example 3: Displaying Customer Data For a Single FRU
The following command prints the customer data, if present, for the first mem-module found:
example% fruadm mem-module
Example 4: Setting Customer Data
The following example sets the customer data for a FRU:
example# fruadm system-board 'Asset Tag 123456'
Example 5: Setting Customer Data
The following command sets the customer data for all FRUs under chassis:
example# fruadm -r /frutree/chassis "Property of XYZ, Inc."
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWfruip.u |
+-----------------------------+-----------------------------+
|Interface Stability |Unstable |
+-----------------------------+-----------------------------+
SEE ALSO
prtfru(1M), attributes(5)
SunOS 5.10 22 Feb 2002 fruadm(1M)