Sponsored Content
Top Forums Shell Programming and Scripting How to split a field into two fields? Post 302169112 by vbrown on Wednesday 20th of February 2008 10:07:37 AM
Old 02-20-2008
How to split a field into two fields?

Hi,

I have a comma delimited text file where character fields (as opposed to numeric and date fields) are always enclosed with double quotes. Records are separated by the newline character. In a shell script I would like to split a particular field into two separate fields (enclosed with double quotes). The field I would like to split always begins with <description> and ends with </description> and is always the 5th field in a record.

e.g. I would like to convert this:

18,"A",2008-02-11,"Y","<description> some long text </description>","N",1

to this:

18,"A",2008-02-11,"Y","<description> some lo","ng text </description>","N",1

I'm not bothered where in the field the split occurs - somewhere in the middle is optimal.

Really grateful for any help on this one.

Thanks, Vicky
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

returning split fields

I have a variable with data in this format field1;field2;field3 I wanted to split the variable like this field1 field2 field3 this statement was working fine echo $key_val | awk '{gsub(";" , "\n"))' but sometimes we get the data in the variable in this format... (3 Replies)
Discussion started by: mervin2006
3 Replies

2. Web Development

split the fields in a column into 3 columns

Have a column "address" which is combination of city, region and postal code like. Format is : city<comma><space>region<space>postal code abc, xyz 123456 All these three city, region and postal code are not mandatory. There can be any one of the above. In that case a nell... (2 Replies)
Discussion started by: rakshit
2 Replies

3. Shell Programming and Scripting

Sorting on two fields time field and number field

Hi, I have a file that has data in it that says 00:01:48.233 1212 00:01:56.233 345 00:09:01.221 5678 00:12:23.321 93444 The file has more line than this but i just wanted to put in a snippet to ask how I would get the highest number with time stamp into another file. So from the above... (2 Replies)
Discussion started by: pat4519
2 Replies

4. Shell Programming and Scripting

compare two fields and get a third field

Hello, I'm trying to get a value based on a comparison of two fields, this is: file1 687.45 687.18 687.322 687.405 686.865 file 2 685 6.43 686 6.43 687 6.42 688 6.42 (3 Replies)
Discussion started by: Gery
3 Replies

5. Shell Programming and Scripting

AWK:Split fields separated by semicolon

Hi all, I have a .vcf file which contains 8 coulmns and the data under each column as shown below, CHROM POS ID REF ALT QUAL FILTER INFO 1 3000012 . A G 126 ... (6 Replies)
Discussion started by: mehar
6 Replies

6. Shell Programming and Scripting

awk to split one field and print the last two fields within the split part.

Hello; I have a file consists of 4 columns separated by tab. The problem is the third fields. Some of the them are very long but can be split by the vertical bar "|". Also some of them do not contain the string "UniProt", but I could ignore it at this moment, and sort the file afterwards. Here is... (5 Replies)
Discussion started by: yifangt
5 Replies

7. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

8. Shell Programming and Scripting

Split fields from a file

Hi All, I have a file where a list of email id's are stored as shown below: emailid1@blh.com emaild2@blh.com asdf@blah.com emailid3@blh.com In my shell script, i am sending emails to above id's My requirement is to seperate the email id's into 2 groups.. emailid1@blh.com... (10 Replies)
Discussion started by: galaxy_rocky
10 Replies

9. Shell Programming and Scripting

Inserting a field without disturbing field separator on other fields

Hi All, I have the input as below: cat input 032016002 2.891 97.109 16.605 27.172 24.017 32.207 0.233 0.021 39.810 0.077 0.026 19.644 13.882 0.131 11.646 0.102 11.449 76.265 23.735 16.991 83.009 8.840 91.160 0.020 99.980 52.102 47.898 44.004 55.996 39.963 18.625 0.121 1.126 40.189... (15 Replies)
Discussion started by: am24
15 Replies

10. Shell Programming and Scripting

awk to add plus or minus to fields and split another field

In the tab-delimited input below I am trying to use awk to -10 from $2 and +10 to $3. Something like awk -F'\t' -v OFS='\t' -v s=10 '{split($4,a,":"); print $1,$2-s,$3+s,a,$5,$6} | awk {split(a,b,"-"); print $1,$2-s,$3+s,b-s,b+s,$5,$6}' input should do that. I also need to -10 from $4... (2 Replies)
Discussion started by: cmccabe
2 Replies
LSROLL(1p)						User Contributed Perl Documentation						LSROLL(1p)

NAME
lsroll - List the rollrecs in a DNSSEC-Tools rollrec file SYNOPSIS
lsroll [options] <rollrec-files> DESCRIPTION
This script lists the contents of the specified rollrec files. All rollrec files are loaded before the output is displayed. If any rollrecs have duplicated names, whether within one file or across multiple files, the later rollrec will be the one whose data are displayed. OUTPUT FORMATS
The output displayed for each zone in a rollrec file depends on the selected records, the selected attributes, and the selected output format. Each option in these option groups is described in detail in the next section. The three base output formats, along with the default -skip format, are described here. The -terse option indicates that a minimal amount of output is desired; the -long option indicates that a great deal of output is desired. The record-selection and attribute-selection options may be used in conjunction with -terse to display exactly the set of rollrec fields needed. The default output format is that used when neither -terse nor -long is given, and is a middle ground between terse and long output. If the -skip option is given, then the default output format is a little more restricted than the normal default. Some rollrec fields don't make sense in the context of a skip records, and so are given as "---". These fields are the KSK rollover phase, the ZSK rollover phase, the TTL value, and the phase start. The table below shows the fields displayed for each output format. rollrec field default terse long skip ------------- ------- ----- ---- ---- rollrec name yes yes yes yes rollrec type no no yes no zonename no no yes yes zone file yes no yes yes zonegroup no no yes no keyrec file yes no yes yes KSK phase yes no yes no ZSK phase yes no yes no administrator no no yes no directory no no yes no logging level no no yes no TTL value no no yes no display flag no no yes no phase start no no yes no last KSK rollover no no yes no last ZSK rollover no no yes no zonesigner arguments no no yes no The rollrec name field is often the same as its zonename, but this is not necessarily the case. The rollrec name can contain spaces, while the zonename can't. For this reason, lsroll displays the rollrec name in quotes, even if the name contains no spaces. This is intended to allow for easier parsing by other programs. OPTIONS
There are three types of options recognized by lsroll: record-selection options, attribute-selection options, and output-format options. Each type is described in the subsections below. Record-selection Options These options select the records that will be displayed by lsroll. By default, all records will be displayed; selecting one or the other of these options will restrict the records shown. In order to simplify the lsroll code and keep it easily understandable, these options are mutually exclusive. -roll List all "roll" records in the rollrec file. -skip List all "skip" records in the rollrec file. Attribute-selection Options These options select the attributes of the records that will be displayed by lsroll. -type Include each rollrec record's type in the output. The type will be either "roll" or "skip". -zonename The record's zonename is included in the output. The zonename is distinct from the record's rollrec name, which is always included in the output. While these two fields are often the same, they need not be. In split-zone zones, the rollrec names must be different, while the zonename field is the same. -zonefile The record's zonefile is included in the output. This field is part of the default output. -zg The record's zonegroup is included in the output, enclosed in double quotes. If a rollrec does not contain a zonegroup, then the value "" is given. -keyrec The record's keyrec file is included in the output. This field is part of the default output. -kskphase The record's KSK rollover phase are included in the output. If this option is given with the -zskphase option, then the output will follow the format described for the -phases option. This field is part of the default output. -zskphase The record's ZSK rollover phase are included in the output. If this option is given with the -kskphase option, then the output will follow the format described for the -phases option. This field is part of the default output. -phases The record's KSK and ZSK rollover phases are included in the output. The listing is given with the KSK phase first, followed by the ZSK phase. Examples of output from this option are: KSK phase ZSK phase output 0 0 0/0 3 0 3/0 0 5 0/5 -admin The record's administrator value is included in the output. If an administrator value is not included in a rollrec, then the value "(defadmin)" will be given. -directory The name of the directory that holds the zone's files is included in the output. If a zone directory is not included in a rollrec, then the value "(defdir)" will be given. -loglevel The rollerd logging level for this zone. This value may be given in the rollrec file in either the textual or numeric form. The textual form of the logging level will be displayed, not the numeric. If a logging level value is not included in a rollrec, then the value "(deflog)" will be given. If an undefined logging level value is included in a rollrec, then the value "(unknownlog)" will be given. -ttl The record's TTL value is included in the output. -display The record's display flag, used by blinkenlights, is included in the output. -phstart The record's rollover phase is included in the output. If no rollover has yet been performed for this zone, an empty date is given. -lastksk The record's last KSK rollover date is included in the output. If no KSK rollover has yet been performed for this zone, an empty date is given. -lastzsk The record's last ZSK rollover date is included in the output. If no ZSK rollover has yet been performed for this zone, an empty date is given. -zsargs The record's user-defined zonesigner arguments are included in the output. If no arguments have been set for this zone, then the value "(none)" is given. -zonegroup The zonegroups defined in the rollrec are listed, enclosed in double quotes. All other rollrec fields are ignored. If the -long option is specified, then each zonegroup name will be accompanied by the number of rollrec entries in that zonegroup. Output-format Options These options select the type of output that will be given by lsroll. -count Only a count of matching keyrecs in the rollrec file is given. -headers Display explanatory column headers. -terse Terse output is given. Only the record name and any other fields specifically selected are included in the output. -long Long output is given. All record fields are included. -help Display a usage message. -Version Displays the version information for lsroll and the DNSSEC-Tools package. COPYRIGHT
Copyright 2005-2012 SPARTA, Inc. All rights reserved. See the COPYING file included with the DNSSEC-Tools package for details. AUTHOR
Wayne Morrison, tewok@tislabs.com SEE ALSO
blinkenlights(8), rollchk(8), rollinit(8), rollerd(8) Net::DNS::SEC::Tools::rollrec.pm(3) file-rollrec(5) perl v5.14.2 2012-06-21 LSROLL(1p)
All times are GMT -4. The time now is 06:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy