Sponsored Content
Top Forums Shell Programming and Scripting Moving files into dirs corresponding to dates Post 302948376 by newbie2010 on Monday 29th of June 2015 10:47:31 AM
Old 06-29-2015
I need also to run command inside

Thanks for all your responses, they were really helpful!

I was also hoping to run this kind of a command in the array:

Code:
for i in `ls -d */  ; do (cd $i; echo $i && ls);done

What this does is it cds to all of the directories and then prints out the files within them.

Is this also possible using the array created that contains all the directories? I have been unable to get the array to perform what the above command does.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

I need to ls all files in 4-6 deep dirs

I need to print to file , a listing of all files below a certain directory. Example: I need to print to file a listing of all files below the etc dir (including the subdirectories) with their full path. Any ideas on how to do this with one command. Or is this something I need to do on all... (4 Replies)
Discussion started by: gforty
4 Replies

2. Shell Programming and Scripting

script find files in two dirs HELP

I have a directory which is /home/mark/files/ , inside this particular I have a bunch of filles (see examples below) TST_SHU_00014460_20090302.txt TST_SHU_00016047_20090302.txt TST_SHU_00007838_20090303.txt TST_SHU_00056485_20090303.txt TST_SHU_00014460_20090303.txt... (2 Replies)
Discussion started by: fierusbentus
2 Replies

3. Shell Programming and Scripting

Find most recent files in dirs and tar them up?

Hey all.. This should be simple but stoopid here can't get head around it! I have many directories, say 100 each with many files inside. I need a script to traverse through the dirs, find most recent file in each dir and add it to a tar file. I can find the files with something like for... (1 Reply)
Discussion started by: bobdung
1 Replies

4. Shell Programming and Scripting

Have absolute path for files in different dirs

Hi everybody. I need a command to print the absolute path of files which name starts always with a pattern (MOD03), independently on where they are in the filesystem. I have tryedls -ld ${INPUTPREFIX}/*/*/* | grep MOD03 | awk '{ print $8 }'but I have to use "/*/*/*" in this case to have the... (5 Replies)
Discussion started by: canduc17
5 Replies

5. Shell Programming and Scripting

sort retrieved data files in different dirs

Hi, I have a script to retrieve data files from server and store them in a directory on local disk. The script runs everyday as cron job. But now those files are too many so my boss wants me to put the files into different directories base on dates. Those files look like this: ... (4 Replies)
Discussion started by: leafei
4 Replies

6. Shell Programming and Scripting

AWK help print dirs with files in it

Hi, I'm writing some start of day checks for my work. I want to check some dirs for files that have been created longer than 10 mins ago and not been transfered. I've already used a find command to write a list of files that meet this criteria to a log called sod.log i.e. ... (1 Reply)
Discussion started by: elcounto
1 Replies

7. UNIX for Dummies Questions & Answers

Reading the dates from a file & moving the files from a directory

Hi All, I am coding for a requirement where I need to read a file & get the values of SUB_DATE. Once the dates are found, i need to move the files based on these dates from one directory to another. ie, this is how it will be in the file, SUB_DATE = 20120608,20120607,20120606,20120606... (5 Replies)
Discussion started by: dsfreddie
5 Replies

8. Debian

Problem with files/dirs deletion

Hi, The other day i installed a PHP based CMS (modx) on my shell account and noticed that i couldn't delete any of files/dirs it created after. Also, i noticed that all that stuff is owned by username-www instead of username. I tried chown, chmod and using a PHP script to do the same wti... (4 Replies)
Discussion started by: pentago
4 Replies

9. Red Hat

Moving files with specific dates

Hi, These are the list of files in one directory in the server : # ls -lrt total 10120 -rw-r--r-- 1 root root 4484 Jul 8 2011 install.log.syslog -rw-r--r-- 1 root root 51890 Jul 8 2011 install.log -rw------- 1 root root 3140 Jul 8 2011 anaconda-ks.cfg drwxr-xr-x 2 root root... (2 Replies)
Discussion started by: anaigini45
2 Replies

10. Shell Programming and Scripting

Replace a string in files in all dir and sub dirs

Hello, I need to replace xml version='1.1' with xml version='1.0' in all xml files under /app/jenkins/ in all dir and sub dirs in my CentOS VM, I tried below command but it didn't help, looks like I'm missing a character somewhere. grep -rl "xml version='1.1'" . | xargs sed -i 's/"xml... (2 Replies)
Discussion started by: mahesh Madpathi
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:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy