awk - using variables in pattern which contain full pathname
Hello.
I would like to make this bash command working.
In the following code, the bash variable 'ZYPPER_LOCAL_REP' contain a full pathname like '/path/to/path/somewhere'
I run into problems because of the use of a bash variables and because the variable contain a string with some '/'
With C Shell you can get the root, head, tail and extension of a pathname by using pathname variable modifiers.
Example Script:
#! /bin/csh
set pathvar=/home/WSJ091305.txt
echo $pathvar:r
echo $pathvar:h
echo $pathvar:t
echo $pathvar:e
The result of executing this script is:
... (7 Replies)
Hi! I need to get PID of some particular process and I wonder if I can use pgrep tool for this purpose. The problem is that pgrep doesn't perform pattern matching on the whole command line, even if I use -f key. Parsing output of ps command is not quite convenient... Also deamon, which PID I need... (2 Replies)
How would I get folders owned by specific users.. I want to pass users as a shell variable to awk.
drwxr-x--x 3 user1 allusers 512 Oct 14 2006 946157019/
drwxr-x--x 3 user2 allusers 512 Mar 9 2008 94825883/
drwxr-x--x 3 user3 allusers 512 Mar 9 2008 948390501/
... (3 Replies)
How to to pass variable to the below awk command
I would like to pass variables to the awk command instead of the constants "a/cc" but I don't know exactly the correct syntax
awk '/a/,/cc/' temp1.out
file.txt
a
b
s
cc
g
d
output
a
b
s (8 Replies)
I am trying to print text between two variables in a file
I have tried the following things but none seem to work:
awk ' /'$a'/ {flag=1;next} /'$b'/{flag=0} flag { print }' file
and also
sed "/$a/,/$b/p" file
But none seem to work
Any Ideas?
Thanks in Advance (5 Replies)
Hi,
I need to extract all the content between two strings stored in two variables "startstring" and "endstring"
startstring=hello
enstring=world
#notworking
awk '/$startstring/, $NF ~ /$endstring/ ' file > file2
The above code is not working with variables. It works when actual string... (2 Replies)
I am running an awk to verify all the memory settings for tomcat, and need to include path or directory in output ....
I am running:
awk '{ print $3 }' /opt/dir1/dir2/*/tomcat/bin/setenv.sh
Output results:
-Xms1024m
-Xmx1536m
-Xmx1536m
-Xmx1024m
-Xms1024m
-Xms1024m
-Xms512m
-Xms1024m... (3 Replies)
Hi,
I need to do find and replace, but the pattern is not full known.
for example,
my file has /proj/app-d1/sun or /data/site-d1/conf
here app-d1 and site-d1 is not constant. It may be different in different files. common part is /proj/xx/sun and /data/xxx/conf
i want to find where ever... (6 Replies)
Hello.
Question 1 :
I want to comment out all lines of a cron file which are not already commented out for each full path pattern matched.
Example 1 nothing to do because line is already commented out; pattern = '/usr/bin/munin-cron'
# */5 * * * * munin test -x... (3 Replies)
Discussion started by: jcdole
3 Replies
LEARN ABOUT DEBIAN
data::dumpxml
DumpXML(3pm) User Contributed Perl Documentation DumpXML(3pm)NAME
Data::DumpXML - Dump arbitrary data structures as XML
SYNOPSIS
use Data::DumpXML qw(dump_xml);
$xml = dump_xml(@list)
DESCRIPTION
This module provides a single function called dump_xml() that takes a list of Perl values as its argument and produces a string as its
result. The string returned is an XML document that represents any Perl data structures passed to the function. Reference loops are han-
dled correctly.
The following data model is used:
data : scalar*
scalar = undef | str | ref | alias
ref : scalar | array | hash | glob | code
array: scalar*
hash: (key scalar)*
The distribution comes with an XML schema and a DTD that more formally describe this structure.
As an example of the XML documents produced, the following call:
$a = bless [1,2], "Foo";
dump_xml($a);
produces:
<?xml version="1.0" encoding="US-ASCII"?>
<data xmlns="http://www.cpan.org/.../Data-DumpXML.xsd">
<ref>
<array class="Foo">
<str>1</str>
<str>2</str>
</array>
</ref>
</data>
If dump_xml() is called in a void context, then the dump is printed on STDERR automatically. For compatibility with "Data::Dump", there is
also an alias for dump_xml() called simply dump().
"Data::DumpXML::Parser" is a class that can restore data structures dumped by dump_xml().
Configuration variables
The generated XML is influenced by a set of configuration variables. If you modify them, then it is a good idea to localize the effect.
For example:
sub my_dump_xml {
local $Data::DumpXML::INDENT = "";
local $Data::DumpXML::XML_DECL = 0;
local $Data::DumpXML::DTD_LOCATION = "";
local $Data::DumpXML::NS_PREFIX = "dumpxml";
return dump_xml(@_);
}
The variables are:
$Data::DumpXML::INDENT
You can set the variable $Data::DumpXML::INDENT to control the amount of indenting. The variable contains the whitespace you want to
be used for each level of indenting. The default is a single space. To suppress indenting, set it to "".
$Data::DumpXML::INDENT_STYLE
This variable controls where end element are placed. If you set this variable to the value "Lisp" then end tags are not prefixed by
NL. This give a more compact output.
$Data::DumpXML::XML_DECL
This boolean variable controls whether an XML declaration should be prefixed to the output. The XML declaration is the <?xml ...?>
thingy. The default is 1. Set this value to 0 to suppress the declaration.
$Data::DumpXML::NAMESPACE
This variable contains the namespace used for the XML elements. The default is to let this be a URI that actually resolve to the XML
schema on CPAN. Set it to "" to disable use of namespaces.
$Data::DumpXML::NS_PREFIX
This variable contains the namespace prefix to use on the elements. The default is "", which means that a default namespace will be
declared.
$Data::DumpXML::SCHEMA_LOCATION
This variable contains the location of the XML schema. If this variable is non-empty, then an "xsi:schemaLocation" attribute is added
to the top level "data" element. The default is not to include this, as the location can be inferred from the default XML namespace
used.
$Data::DumpXML::DTD_LOCATION
This variable contains the location of the DTD. If this variable is non-empty, then a <!DOCTYPE ...> is included in the output. The
default is to point to the DTD on CPAN. Set it to "" to suppress the <!DOCTYPE ...> line.
BUGS
Class names with 8-bit characters are dumped as Latin-1, but converted to UTF-8 when restored by the Data::DumpXML::Parser.
The content of globs and subroutines are not dumped. They are restored as the strings "** glob **" and "** code **".
LVALUE and IO objects are not dumped at all. They simply disappear from the restored data structure.
SEE ALSO
Data::DumpXML::Parser, XML::Parser, XML::Dumper, Data::Dump
AUTHORS
The "Data::DumpXML" module is written by Gisle Aas <gisle@aas.no>, based on "Data::Dump".
The "Data::Dump" module was written by Gisle Aas, based on "Data::Dumper" by Gurusamy Sarathy <gsar@umich.edu>.
Copyright 1998-2003 Gisle Aas.
Copyright 1996-1998 Gurusamy Sarathy.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.8.8 2006-04-08 DumpXML(3pm)