xtsed
Section: User Commands (1)
Updated: 2002-10-26
Index
Return to Main Contents
NAME
xtsed - replaces string by regular expression
SYNOPSIS
xtsed -f attribute(s) -c regular expression -v replacement character string
[-A] [-g] [-i INPUT] [-o OUTPUT] [-z] [-t]
DESCRIPTION
This command replaces the character string that matches a regular expression defined by -c with
a character string at the -v argument. When -A is specified, the replacement will be store as a new attribute.
Replacement is applied only for the longest substring that matches a regular expression. If there is a tie, only the first occurrence is replaced.
PARAMETERS
- -f attribute(s)
-
replace strings on the attribute(s)
- -c regular expression
-
specify a reguar expression for character stirngs you want to replace
-
- Match start of line
- Match end of line
Match space-character
- -v character string for replacement
-
character string you will replace with
- -A new attribute
-
define the name for the new attribute
- -g
-
global replacement: replace all substrings that match a regular expression
FILE OPTIONS
- -i input filename
-
if a suffix of the filename is '.gz', the command acts as a filter, extracting the compressed file for processing. The command will read the file as standard input when "-i" is not specified.
- -o output filename
-
if a suffix of the filename is '.gz', the command automatically returns the output data in zip archive. When "-o" is not specified, the result will sent to standard output.
- -z zip archive
-
compress the standard output to zip archive. When the option "-o" is not given and "-z" is specified, the output will be compressed as zip archive.
- -t plain text
-
xtagg treats the input and output data as plain text format.
USAGE
Input file - dat.xt:
<field no="1">
<name>CustomerID</name>
</field>
<field no="2">
<name>Zipcode</name>
</field>
</header>
<body><![CDATA[
A00001 92610
A00002 92619
A00003 90006
A00004 91210
A00005 90362
A00006 90007
A00007 90362
A00008 91210
A00009 90619
A00010 90362
A00011 90362
A00012 92610
]]></body>
Example 1. Blockout zipcodes with '90' as the first 2 digits.
e.g. xtsed -f zip_code -c '^90' -v '###' -i dat.xt -o rsl.xt
Output file -rsl.xt
-
<body><![CDATA[
A00001 92610
A00002 92619
A00003 ###006
A00004 91210
A00005 ###362
A00006 ###007
A00007 ###362
A00008 91210
A00009 ###619
A00010 ###362
A00011 ###362
A00012 92610
]]></body>
Example 2. Generate a permutation code by removing the first digit of the zipcode.
e.g. xtsed -f zip_code:permutation_code -c '^9' -v '' -i dat.xt -o rsl.xt
Output file -rsl.xt
-
<body><![CDATA[
A00001 2610
A00002 2619
A00003 0006
A00004 1210
A00005 0362
A00006 0007
A00007 0362
A00008 1210
A00009 0619
A00010 0362
A00011 0362
A00012 2610
]]></body>
Example 3. Add a bracket for zipcodes with 0 as the last digit.
e.g. xtsed -f zip_code -c '0$' -v '(&)' -i dat.xt -o rsl.xt
Output file -rsl.xt
-
<body><![CDATA[
A00001 9261(0)
A00002 92619
A00003 90006
A00004 9121(0)
A00005 90362
A00006 90007
A00007 90362
A00008 9121(0)
A00009 90619
A00010 90362
A00011 90362
A00012 9261(0)
]]></body>
SEE ALSO
xtchgstr(1),
xtcal(1)
For complete documentation and tutorial of xtsed and other commands, please visit
http://musashien.sourceforge.net
BUG REPORT
If you find a bug in xtsed, please send an electronic mail to
musashi@adm.osaka-sandai.ac.jp.
Before sending a bug report, please verify that you have the lastest version of
MUSASHI.
Read this manual carefully to ensure the error is not caused by a quirk in the language.
AUTHORS
Yukinobu Hamuro, Naoki Katoh, Katsutoshi Yada, Stephane Cheung
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- PARAMETERS
-
- FILE OPTIONS
-
- USAGE
-
- SEE ALSO
-
- BUG REPORT
-
- AUTHORS
-
This document was created by
man2html,
using the manual pages.
Time: 22:43:55 GMT, June 24, 2003