Sponsored Content
Full Discussion: Help with tr
Top Forums Shell Programming and Scripting Help with tr Post 302789383 by Scrutinizer on Wednesday 3rd of April 2013 02:24:49 PM
Old 04-03-2013
@yoda, that would be problematic if there is any kind of whitespace other than the newlines. Even if you set FS to a newline, the RS= would compress multiple newlines and create multiple records.

As a work-around one could choose a character that will not occur in the text for example:
Code:
awk '{$1=$1}1' FS='\n' RS=§ OFS="|"

Note that there would need to be curly braces around $1=$1 otherwise it would not print in case of 0 or whitespace in $1

But this would leave a trailing pipe symbol after the last record, so that still would not work as desired...

Also there might be record length limitations..

Last edited by Scrutinizer; 04-03-2013 at 04:52 PM..
This User Gave Thanks to Scrutinizer For This Post:
 
XUPDATE(1p)						User Contributed Perl Documentation					       XUPDATE(1p)

NAME
xupdate - Process XUpdate commands over an XML document SYNOPSIS
xupdate [options] <xupdate-file> <input-file> Options: -u | --usage print brief help on usage -h | --help print documentation -n | --namespace prefix=namespace-uri associate a namespace with a prefix for use in XPath selections in XUpdate file (this option may occur several times) -k | --keep-ws preserve whitespace in the XUpdate file -s | --strip-ws strip ignorable whitespace from the input file -V | --version print current version and revision -i | --indent indent the output XML -j | --extra-indent like -i, but also adds a leading and a trailing linebreak to every text node. but also put an extra newline after every start-tag and before every end-tag OPTIONS
--usage Print a brief help message on usage and exits. --help Prints the manual page and exits. --namespace prefix=namespace-uri Associate a namespace with a prefix. The prefix may be used in the XPath selections in the XUpdate file to address nodes of the source document that belong to the given namespace. This is especially useful for mapping the default namespace to a prefix because XPath by definition doesn't honour default namespaces. This option may occur several times. --keep-ws Preserves any whitespace in XUpdate file. The default behaviour is to remove all ignorable whitespace and any leading or trailing whitespace in all XUpdate command elements in the XUpdate file. --strip-ws Remove "ignorable" whitespace from the input file. The default behaviour is to keep any whitespace unless the --extra-indent (-j) option is used. Note that the whitespace being present or not may affect results returned by some XPath expressions (such as /foo/bar/text()[2]). --version Print version and revision number of This program command and version number of XML::XUpdate library used. --indent Indent the resulting document on output. --extra-indent Indent the resulting document on output as --indent, but also add a leading and a trailing linebreak to every text node. --debug Print some debugging information about commands being applied. DESCRIPTION
This program will parse the given XUpdate file and the input file and print the input file updated accordingly. XUpdate file format is described in XUpdate Working Draft from 2000-09-14 (http://www.xmldb.org/xupdate/xupdate-wd.html). AUTHOR
Petr Pajas, pajas@matfyz.cz COPYRIGHT
Copyright 2002-2003 Petr Pajas, All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2011-08-02 XUPDATE(1p)
All times are GMT -4. The time now is 06:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy