Sponsored Content
Full Discussion: Using gsub with xml formats
Top Forums Shell Programming and Scripting Using gsub with xml formats Post 302975620 by emare on Thursday 16th of June 2016 05:58:11 AM
Old 06-16-2016
Using gsub with xml formats

Hello,

I'm looking again for your precious help.

I'm running an IBM AIX box.
I have 'wrong' xml files and waiting for the bug correction I need to manipulate them
The problem is a missing tag.
Now you know that xmls are full of < and > and \ so our scripts just go beserk.
To be on the safe side I want to insert a tag between two known tags:

wrong data
Code:
<PackDate>20160615</PackDate>
<TMCCode>BA</TMCCode>
<FullPallet>N</FullPallet>
<BlockCode>0</BlockCode>
<AdmQualifier>568U#3-335</AdmQualifier>

correct data
Code:
<PackDate>20160615</PackDate>
<TMCCode>BA</TMCCode>
<FullPallet>N</FullPallet>
<AviExp>123456</AviExp>
<BlockCode>0</BlockCode>
<AdmQualifier>568U#3-335</AdmQualifier>

Instead of using while...read... I tried gsub, but all those fancy delimiters just don't let the command to work properly. Furthermore there are CRLF that are to be taken into account.

This is my try:
Code:
awk '{gsub("<FullPallet>N</FullPallet>\n<BlockCode>0</BlockCode>","<FullPallet>N</FullPallet>\n<AviExp>123456</AviExp>\n<BlockCode>0</BlockCode>");printf"%s",$0}' S210404890.xml > test.txt

Any help is really appreciated.

thanks,
Ema
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

date formats

Hi, I want to generate file name in the following date format, "YYYYMMDDHHHHMISS" plz. help me how to do that? (6 Replies)
Discussion started by: harshad.katruwa
6 Replies

2. UNIX for Dummies Questions & Answers

Change multiple filename formats with WHILE

Hi All, I'm trying to run a simple shell program to change all the files named *.cvs to *.txt. I am trying to use WHILE and this is what I have so far: This changes the first file from *.cvs to *.txt, but it is not cycling through the other files. My suspicion is that I don't have the... (5 Replies)
Discussion started by: ScKaSx
5 Replies

3. Solaris

different date formats in same server

when I ssh and run date command, it shows date in 24 hour date format. But when I telnet the same server, it shows date in 12 hour format, ie. in AM/PM (1 Reply)
Discussion started by: na75369
1 Replies

4. UNIX for Dummies Questions & Answers

Help with Date Formats

Hi, Following are the results of various date formats: 1. date +%h" "%d Result: Jun 02 2. date Result: Tue Jun 2 09:59:15 CDT 2009 If i use the date format as date +%h%d then i am getting the date as 02. I want the day to be displayed as "2" instead of "02". so my result should... (1 Reply)
Discussion started by: sandeep_1105
1 Replies

5. Shell Programming and Scripting

Compare two files in different formats and get output

File A: DATAFILE TABLESPACE ------------------------- ------------------------- /dev/rprod_0032_011 D_EEM /dev/rprod_0032_012 D_ESO_REF ... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

6. Shell Programming and Scripting

Output with horizontal formats

// AIX 5.3 & 6.1 This command powermt display dev=all returns the output of Pseudo name=hdiskpower50 Symmetrix ID=000190101757 Logical device ID=05F0 state=alive; policy=SymmOpt; priority=0; queued-IOs=0 ==============================================================================... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

7. Shell Programming and Scripting

Need to check the file formats

Hi, I want to check the incoming files whether the file is Mac file or dos/windows file in unix shell script. Sometimes client is posting Mac file and sometimes it is dos file. Could you please help me how to determine/check whether the file is Mac or dos. Help in advance Thanks (4 Replies)
Discussion started by: lkeswar
4 Replies

8. Shell Programming and Scripting

How to compare dates in different formats?

Hi, I have a log file that records date time stamp in this format <Jun 7, 2015 12:56:54 PM EDT>. The date command give me the date in this format Mon Jun 8 08:40:58 EDT 2015 If the difference in the timestamp in the logfile & the current System datetime stamp is less than 15 mins then... (4 Replies)
Discussion started by: shifahim
4 Replies

9. Shell Programming and Scripting

Comparing different time formats

I am trying to do a comparison of files based on their last modified date. I am pulling the first file from a webapp folder using curl. curl --silent -I http://localhost:8023/conf/log4j2.xml | grep Last Last-Modified: Tue, 22 Mar 2016 22:02:18 GMT The second file is on local disk. stat... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies
Locale::Codes::LangFam(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangFam(3pm)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangFam(3pm)
All times are GMT -4. The time now is 09:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy