Sponsored Content
Full Discussion: A typical array script
Top Forums Shell Programming and Scripting A typical array script Post 302502799 by Renjesh on Wednesday 9th of March 2011 01:31:45 AM
Old 03-09-2011
Error A typical array script

Hi All,

I need to store the output of "find ." to an array one by one. Output of find . in my case will look like :-
Code:
.
./one
./one/a
./one/b
./one/c
./two

So my first array element should be "/one" and second one "/one/a" (need to remove "." from the output as well).

Then I need to access each element from the array. Please help me out

Thanks
Renjesh

Last edited by Franklin52; 03-09-2011 at 04:26 AM.. Reason: Please use code tags
 

8 More Discussions You Might Find Interesting

1. Solaris

Typical way to disable a dameon

I want to disable some services starting automatically while system booting, for instance if i want to disable vold what i have to do ? i think some services related to a script init level shell directory,and i think as well that since solaris 10 they added a command to enable and disable services... (2 Replies)
Discussion started by: XP_2600
2 Replies

2. Shell Programming and Scripting

typical mail script

hi i have a requirement to write a mail script which needs to be automated.There are 7 CSV files generated for 7 clients in a single day.Each file will contain one header and the name of the file follows a nomenclature like ABC_20080402_ClientID.csv.ClientID is lets say... (3 Replies)
Discussion started by: dr46014
3 Replies

3. UNIX for Dummies Questions & Answers

Meaning and typical use of -3 signal in kill

Hi, What is the use of the signal -3 in kill command in unix? I read the meaning and typical use of this signal in one of the Oreilly books as below. Quit -- stop running (and dump core). Sent when you type CTRL-\. what does the CTRL-\ command do? Is it the combination of CTRL and... (6 Replies)
Discussion started by: venkatesht
6 Replies

4. Shell Programming and Scripting

Guidance needed for a typical shell script with sql query

Hi , I have a txt file with contents like: 1234 2345 3456 7891 I need to write a script which takes input file as txt file..run a sql query for that number and place the output of query in another file.. select * from bus_event where acct_nbr='1234'( from input txt file) the query... (20 Replies)
Discussion started by: Rajesh Putnala
20 Replies

5. Emergency UNIX and Linux Support

Calculating total space in GB for all files with typical pattern

Hi Experts, In a particular dir, I have many files *AJAY*. How can I get total size of all such files. I tried du -hs *AJAY* but it gave me individual size of all files. All I require is summation of all. Thanks, Ajay (4 Replies)
Discussion started by: ajaypatil_am
4 Replies

6. UNIX for Dummies Questions & Answers

Typical steps to be followed while applying an application patch upgrade on linux

what are the typical steps used by system adminstrators while applying an application patch upgrade (1 Reply)
Discussion started by: ramky79
1 Replies

7. Shell Programming and Scripting

Typical problem in UNIX

Input file I have a file with four fields. f1,f2,f3,f4 A,1,10,00,S B,2,20,00,00,D C,3,100,00,00,G I want Output like f1|f2|f3|f4 A|1|10,00|S B|2|20,00,00|D C|3|100,00,00|G please help on this (4 Replies)
Discussion started by: bharat1211
4 Replies

8. UNIX for Dummies Questions & Answers

How to compile a software for a non-typical platform?

I am quite new to compiling source codes in linux and have been running into a lot of problems in trying to do so since the platform configuration is different from most. For starters, I know that you need to enter the following commands in order to install any software manually in linux:... (2 Replies)
Discussion started by: Ice_Drake1
2 Replies
Tree::Simple::Visitor::FromNestedArray(3pm)		User Contributed Perl Documentation	       Tree::Simple::Visitor::FromNestedArray(3pm)

NAME
Tree::Simple::Visitor::FromNestedArray - A Visitor for creating Tree::Simple objects from nested array trees. SYNOPSIS
use Tree::Simple::Visitor::FromNestedArray; my $visitor = Tree::Simple::Visitor::FromNestedArray->new(); # given this nested array tree my $array_tree = [ 'Root', [ 'Child1', [ 'GrandChild1', 'GrandChild2' ], 'Child2' ] ]; # set the array tree we # are going to convert $visitor->setArrayTree($array_tree); $tree->accept($visitor); # this then creates the equivalent Tree::Simple object: # Tree::Simple->new("Root") # ->addChildren( # Tree::Simple->new("Child1") # ->addChildren( # Tree::Simple->new("GrandChild1"), # Tree::Simple->new("GrandChild2") # ), # Tree::Simple->new("Child2"), # ); DESCRIPTION
Given a tree constructed from nested arrays, this Visitor will create the equivalent Tree::Simple heirarchy. METHODS
new There are no arguments to the constructor the object will be in its default state. You can use the "setNodeFilter", "includTrunk" and "setArrayTree" methods to customize its behavior. includTrunk ($boolean) Setting the $boolean value to true(1) will cause the node value of the $tree object passed into "visit" to be set with the root value found in the $array_tree. Setting it to false(0), or not setting it, will result in the first value in the $array_tree creating a new node level. 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 created, the $filter_function is passed the node value extracted from the array prior to it being inserted into the tree being built. The $filter_function is expected to return the value desired for inclusion into the tree. setArrayTree ($array_tree) This method is used to set the $array_tree that our Tree::Simple heirarchy will be constructed from. It must be in the following form: [ 'Root', [ 'Child1', [ 'GrandChild1', 'GrandChild2' ], 'Child2' ] ] Basically each element in the array is considered a node, unless it is an array reference, in which case it is interpreted as containing the children of the node created from the previous element in the array. The tree is validated prior being accepted, if it fails validation an execption will be thrown. The rules are as follows; The array tree must not be empty. It makes not sense to create a tree out of nothing, so it is assumed that this is a sign of something wrong. All nodes of the array tree must not be array references. The root node is validated against this in this function, but all subsequent nodes are checked as the tree is built. Any nodes found to be array references are rejected and an exception is thrown. If you desire your node values to be array references, you can use the node filtering mechanism to acheive this as the node is filtered after it is validated. The array tree must be a single rooted tree. If there is a second element in the array tree, it is assumed to be the children of the root, and therefore must be in the form of an array reference. 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. 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::FromNestedArray(3pm)
All times are GMT -4. The time now is 12:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy