What keeps you from trying it (mayhap with the -x (--xtrace) option set)? Commands accepting multiple arguments don't even need the for loop nor the array. Try
.
Be aware that running a command blind folded with a resulting argument list that you don't know upfront is dangerous; applied to the wrong directories with the wrong options might render your system unuseable!
And, files with white space chars in their names might irritate / confuse the command.
Hi,
Is it possible to create a dynamic array in shell script. I am trying to get the list of logfiles that created that day and put it in a dynamic array. I am not sure about it. help me
New to scripting
Gundu (3 Replies)
Hi all,
i am quite fimiliar with shell scripting but i wouldn't regard myself as a semi professional at it.
I am trying to create an array variable to read in 4 lines from a file using head and tail command in a pipeline and store each line into each array. I have done the scripting in unix... (2 Replies)
i want to create an array
the array elements are populated depending upon the number of entries present in a data file
The data file is created dynamically
how to achieve the same
thanks (1 Reply)
I am facing a strange error while creating posix threads:
Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output.
Snippet 1
This works:
--------------
int *threadids;
threadids = (int *) malloc (num_threads * sizeof(int));
... (4 Replies)
I have an interesting requirement. I have declaried an array like :-
arr=`find . ! -name "." | xargs -I {} echo {} | cut -c 2-${#}`
Then i will try to access the array elements like :-
i=0
for i in ${arr}; do
Here comes the confusions, the array elements are basically dir and files stored... (2 Replies)
Hi gurus,
I need to create arrays from variables, via a loop.
The issue I have is with the array name creation. How do I use a variable to define an array?
I want to do something like
declare -a $H
where $H is my loop variable.
I then need to add items to each array I've created,... (3 Replies)
I am having trouble creating an array, I've tried everything google gives me but it won't work, and it seems as though it should. Using Ubunto 12.04 and bash.
#!/bin/bash
ARRAY=one two three
echo ${ARRAY}When I do this I receive the error
: two: not found
and
: Bad substitution
When I... (3 Replies)
Dear community,
how can I create an array from file taking only the 4th field?
out.txt file is something like this:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20So the final array should be:
4 8 12 16 20With this command I created an array with all the fields, but I need only the 4th... (13 Replies)
Discussion started by: Lord Spectre
13 Replies
LEARN ABOUT DEBIAN
tree::simple::visitor::tonestedarray
Tree::Simple::Visitor::ToNestedArray(3pm) User Contributed Perl Documentation Tree::Simple::Visitor::ToNestedArray(3pm)NAME
Tree::Simple::Visitor::ToNestedArray - A Visitor for creating nested array trees from Tree::Simple objects.
SYNOPSIS
use Tree::Simple::Visitor::ToNestedArray;
my $visitor = Tree::Simple::Visitor::ToNestedArray->new();
# given this Tree::Simple tree
my $tree = Tree::Simple->new("Root")
->addChildren(
Tree::Simple->new("Child1")
->addChildren(
Tree::Simple->new("GrandChild1"),
Tree::Simple->new("GrandChild2")
),
Tree::Simple->new("Child2"),
);
# include the trunk (Root)
$visitor->includeTrunk(1);
# visit the tree
$tree->accept($visitor);
my $array_tree = $visitor->getResults();
# this then creates the equivalent nested array tree:
# [
# 'Root', [
# 'Child1', [
# 'GrandChild1',
# 'GrandChild2'
# ],
# 'Child2'
# ]
# ]
# if you don't include the trunk (Root) then ...
$tree->accept($visitor);
my $array_tree = $visitor->getResults();
# this then creates the following nested array tree:
# [
# 'Child1', [
# 'GrandChild1',
# 'GrandChild2'
# ],
# 'Child2'
# ]
DESCRIPTION
Given a tree constructed from a Tree::Simple heirarchy, this Visitor will create the equivalent tree of nested arrays.
METHODS
new There are no arguments to the constructor the object will be in its default state. You can use the "setNodeFilter" and "includTrunk"
methods to customize its behavior.
includTrunk ($boolean)
Setting the $boolean value to true(1) will cause the node value of the tree's root to be included in the nested array output, setting
it to false will do the opposite.
setNodeFilter ($filter_function)
This method accepts a CODE reference as its $filter_function argument and throws an exception if it is not a code reference. This code
reference is used to filter the tree nodes as they are placed into the array tree. The $filter_function is passed a Tree::Simple
object, and is expected to return the value desired for inclusion into the array tree.
visit ($tree)
This is the method that is used by Tree::Simple's "accept" method. It can also be used on its own, it requires the $tree argument to be
a Tree::Simple object (or derived from a Tree::Simple object), and will throw and exception otherwise.
getResults
This method will return the array tree constructed.
BUGS
None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.
CODE COVERAGE
See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more inforamtion.
SEE ALSO
These Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module, you should refer to that
module for more information.
AUTHOR
stevan little, <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
Copyright 2004, 2005 by Infinity Interactive, Inc.
<http://www.iinteractive.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2005-07-14 Tree::Simple::Visitor::ToNestedArray(3pm)