02-20-2008
Try this:
sed -e 's/A,X/1/g' -e 's/B,Y/2/g' -e 's/B,Z/3/g' CM.txt
you can put this in a file.sed and run it like so:
sed -f sedfile file
Using sed
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Friends,
Can any one help with this:
I have a huge file with the format as
A SAM 4637
B DEPT1 4758 MILAN
A SMITH 46585
B DEPT2 5385 HARRYIS
B SAMUL 63547 GEORGE
B DANIEL 899 BOISE
A FRES 736 74638
I have to read this file and write only the records that starts with "B" only
... (5 Replies)
Discussion started by: sbasetty
5 Replies
2. Shell Programming and Scripting
Can any one help me to correct following script.
I have 2 directories DropZone and ProcessZone. File pattern is *VEHDESCSUM*.
Finding the 'no of files' in DropZone directory using ls *VEHDESCSUM* |wc -l
If DropZone has more than one file or 0 files then exit 1
If DropZone has one file then... (2 Replies)
Discussion started by: ramanagh
2 Replies
3. Shell Programming and Scripting
Hi,
I have a comma separated file with millions of records in it.
I have a requirement to split the file based on the value in a one of the columns.
Suppose i have a text file with columns like C1, C2,C3,C4
Column C4 can hold the values either 01 or 02 03 or 04.
I nned to extract... (2 Replies)
Discussion started by: Raamc
2 Replies
4. Shell Programming and Scripting
Hi, Gurus,
I got a problem to resolve following issue:
I have one file file1as following:
start_dt=2010-01-01 12:00:02
start_dt=2011-01-01 09:00:02
start_dt=2009-01-01 11:00:02I have another file file2 as following:
title1, 2010-01-03 10:00:02
title2, 2011-01-04 11:00:02
title3,... (5 Replies)
Discussion started by: ken002
5 Replies
5. Shell Programming and Scripting
AWK Command parse a file based on string.
I am trying to write a shell script to parse a file based on a string and move the content of the file to another file.
Here is scenario.
File content below
Mime-Version: 1.0
Content-Type: multipart/mixed;
... (2 Replies)
Discussion started by: aakishore
2 Replies
6. Shell Programming and Scripting
I am fairly new to programming and trying to resolve this problem. I have the file like this.
CHROM POS REF ALT 10_sample.bam 11_sample.bam 12_sample.bam 13_sample.bam 14_sample.bam 15_sample.bam 16_sample.bam
tg93 77 T C T T T T T
tg93 79 ... (4 Replies)
Discussion started by: empyrean
4 Replies
7. Shell Programming and Scripting
Hi All,
I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form
1). Intercomponents Checking
Passed: All Server are passed.
======================================================================
2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies
8. Shell Programming and Scripting
Hi,
I have a flaty file from which i am fetching few columns in tablular form as below code.
Now i want to fetch the column 6 and 7 in below code only if it either of them is non zero.However below startement
awk -F, '$6==0 && $7==0{exit 1}' ${IFILE}
is not working..Not sure where is the... (36 Replies)
Discussion started by: Vivekit82
36 Replies
9. Shell Programming and Scripting
I collect data in a file in below format(Month Day Year Size) in RedHat Linux. Now i want to calculate the data size date wise. As i code shell script after long time, i forgot the features and syntax. Can anyone help me regard this please.
Feb 8 2014 15
Feb 10 2014 32
Feb 10 2014 32
Feb 12... (2 Replies)
Discussion started by: makauser
2 Replies
10. UNIX for Beginners Questions & Answers
Hi All,
I have a working script as below.
echo "Files loaded with $(cat /var/tmp/script.X1.out)" | mail -s "Files loaded with return code" mailid
This script takes the output from script.X1.out file and appends the text "Files loaded with return code" and sends the email. Now what I want... (5 Replies)
Discussion started by: midhun3108
5 Replies
LEARN ABOUT FREEBSD
xo_close_list
LIBXO(3) BSD Library Functions Manual LIBXO(3)
NAME
xo_emit -- emit formatted output based on format string and arguments
LIBRARY
library ``libxo''
SYNOPSIS
#include <libxo/xo.h>
LIBXO(3) BSD Library Functions Manual LIBXO(3)
NAME
xo_open_list
xo_open_list_h
xo_open_list_hd
xo_open_list_d
xo_open_instance
xo_open_instance_h
xo_open_instance_hd
xo_open_instance_d
xo_close_instance
xo_close_instance_h
xo_close_instance_hd
xo_close_instance_d
xo_close_list
xo_close_list_h
xo_close_list_hd
xo_close_list_d -- open and close lists and instances
LIBRARY
library ``libxo''
SYNOPSIS
int
xo_open_list_h(xo_handle_t *xop, const char *name);
int
xo_open_list(const char *name);
int
xo_open_list_hd(xo_handle_t *xop, const char *name);
int
xo_open_list_d(const char *name);
int
xo_open_instance_h(xo_handle_t *xop, const char *name);
int
xo_open_instance(const char *name);
int
xo_open_instance_hd(xo_handle_t *xop, const char *name);
int
xo_open_instance_d(const char *name);
int
xo_close_instance_h(xo_handle_t *xop, const char *name);
int
xo_close_instance(const char *name);
int
xo_close_instance_hd(xo_handle_t *xop);
int
xo_close_instance_d(void);
int
xo_close_list_h(xo_handle_t *xop, const char *name);
int
xo_close_list(const char *name);
int
xo_close_list_hd(xo_handle_t *xop);
int
xo_close_list_d(void);
DESCRIPTION
Lists are sequences of instances of homogeneous data objects. Two distinct levels of calls are needed to represent them in our output
styles. Calls must be made to open and close a list, and for each instance of data in that list, calls must be make to open and close that
instance.
The name given to all calls must be identical, and it is strongly suggested that the name be singular, not plural, as a matter of style and
usage expectations.
A list is a set of one or more instances that appear under the same parent. The instances contain details about a specific object. One can
think of instances as objects or records. A call is needed to open and close the list, while a distinct call is needed to open and close
each instance of the list:
xo_open_list("item");
for (ip = list; ip->i_title; ip++) {
xo_open_instance("item");
xo_emit("{L:Item} '{:name/%s}':0, ip->i_title);
xo_close_instance("item");
}
xo_close_list("item");
Getting the list and instance calls correct is critical to the proper generation of XML and JSON data.
EXAMPLE:
xo_open_list("user");
for (i = 0; i < num_users; i++) {
xo_open_instance("user");
xo_emit("{k:name}:{:uid/%u}:{:gid/%u}:{:home}0,
pw[i].pw_name, pw[i].pw_uid,
pw[i].pw_gid, pw[i].pw_dir);
xo_close_instance("user");
}
xo_close_list("user");
TEXT:
phil:1001:1001:/home/phil
pallavi:1002:1002:/home/pallavi
XML:
<user>
<name>phil</name>
<uid>1001</uid>
<gid>1001</gid>
<home>/home/phil</home>
</user>
<user>
<name>pallavi</name>
<uid>1002</uid>
<gid>1002</gid>
<home>/home/pallavi</home>
</user>
JSON:
user: [
{
"name": "phil",
"uid": 1001,
"gid": 1001,
"home": "/home/phil",
},
{
"name": "pallavi",
"uid": 1002,
"gid": 1002,
"home": "/home/pallavi",
}
]
LEAF LISTS
In contrast to a list of instances, a "leaf list" is list of simple values. To emit a leaf list, call the xo_emit() function using the ""l""
modifier:
for (ip = list; ip->i_title; ip++) {
xo_emit("{Lwc:Item}{l:item}0, ip->i_title);
}
The name of the field must match the name of the leaf list.
In JSON, leaf lists are rendered as arrays of values. In XML, they are rendered as multiple leaf elements.
JSON:
"item": "hammer", "nail"
XML:
<item>hammer</item>
<item>nail</item>
ADDITIONAL DOCUMENTATION
Complete documentation can be found on github:
http://juniper.github.io/libxo/libxo-manual.html
libxo lives on github as:
https://github.com/Juniper/libxo
The latest release of libxo is available at:
https://github.com/Juniper/libxo/releases
SEE ALSO
xo_emit(3)
HISTORY
The libxo library was added in FreeBSD 11.0.
AUTHOR
Phil Shafer
BSD
December 4, 2014 BSD