Sponsored Content
Full Discussion: Loop through directory names
Top Forums UNIX for Dummies Questions & Answers Loop through directory names Post 302837297 by newbie83 on Thursday 25th of July 2013 01:19:09 PM
Old 07-25-2013
Loop through directory names

Some guidance is highly appreciated.

I have 10 directories with names ending with 'xyz', each of them have about 30000 files. I want to loop through the contents of each directory and produce a single output per directory. So I want to have 10 output files named 'directory_name'_out.

With multiple files I can do

Code:
for file in  *xyz
do
some command $file > $file_out
done

How do I do the same with directories?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Use of $ in directory names

I have a TAR (compressed) file that I uncompressed using the following command $ tar xvf uagent.tar It created a directory structure as follows <root>/arcagent/UAGENT/reloc/$UAGENT_HOME/ How do I access files under the $UAGENT_HOME? Every time I do change directory command, the OS... (3 Replies)
Discussion started by: pkappaz
3 Replies

2. Shell Programming and Scripting

File Names in a Variable in a loop

Hi All , I am having confusion in a shell script. Please guide me. I need to get multiple files (number of files vary time to time, file names are separated by '|') using FTP get from the remote server. Actually, i call the FTP function in a loop. At the last step, i need to move all the get... (3 Replies)
Discussion started by: spkandy
3 Replies

3. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

4. UNIX for Dummies Questions & Answers

How to display only Owner and directory/sub directory names under particular root

hai, I am new to Unix, I have a requirement to display owner name , directory or sub directory name, who's owner name is not equal to "oasitqtc". (here "oasitqtc" is the owner of the directory or sub directory.) i have a command (below) which will display all folders and sub folders, but i... (6 Replies)
Discussion started by: gagan4599
6 Replies

5. UNIX for Dummies Questions & Answers

Loop through directory and extract sub directory names

I am trying to loop through folders and extract the name of the lowest level subfolder I was running the script below, it returns /bb/bin/prd/newyork /bb/bin/prd/london /bb/bin/prd/tokyo I really want newyork london tokyo I couldn't find a standard variable for the lowest level... (1 Reply)
Discussion started by: personalt
1 Replies

6. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

7. UNIX for Dummies Questions & Answers

[Solved] Writing a loop to changing the names of files in a directory

Hi, I would like to write a loop to change the names of files in a directory. The files are called data1.txt through data1000.txt. I'd like to change their names to a1.txt through a1000.txt. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

How to make dynamic variable names for use in while loop?

i=0 while do sizesfor0=`cat 16 | grep 'pickSize' -A 1 | grep '_sz' | cut -d'_' -f1` sizesfor0=${sizesfor0//id=\"lll/:} IFS=: array0=( $sizesfor0 ) echo ${array0} i=$(( $i + 1 )) done So, right now I have two variables in the while statement above sizesfor0 and array0 The... (1 Reply)
Discussion started by: phpchick
1 Replies

9. Shell Programming and Scripting

Print file names in a loop

OS : RHEL 6.1 Shell : Bash I have lots of files in /tmp/stage directory as show below. Using a loop, I need to print all the filenames in this directory except those ending with a number. How can I do this ? # pwd /tmp/stage # # # ls -l * -rw-r--r--. 1 root root 0 Oct 7 18:38 stmt1... (2 Replies)
Discussion started by: kraljic
2 Replies

10. Shell Programming and Scripting

Using nested for loop to iterate over file names

I'm trying to grab a list of file names from a directory, then process those files 5 at a time. In the link below. Instead of using files I'm using the files array which contains 15 strings starting with AAA. So I'm trying to assign $fileset 5 of the strings at a time to pass to a command. So... (4 Replies)
Discussion started by: zBernie
4 Replies
POE::Test::Loops(3pm)					User Contributed Perl Documentation				     POE::Test::Loops(3pm)

NAME
POE::Test::Loops - Reusable tests for POE::Loop authors SYNOPSIS
#!/usr/bin/perl -w use strict; use Getopt::Long; use POE::Test::Loops; my ($dir_base, $flag_help, @loop_modules, $flag_verbose); my $result = GetOptions( 'dirbase=s' => $dir_base, 'loop=s' => @loop_modules, 'verbose' => $flag_verbose, 'help' => $flag_help, ); if ( !$result or !$dir_base or $flag_help or !@loop_modules ) { die( "$0 usage: ", " --dirbase DIR (required) base directory for tests ", " --loop MODULE (required) loop modules to test ", " --verbose show some extra output ", " --help you're reading it ", ); } POE::Test::Loops::generate($dir_base, @loop_modules, $flag_verbose); exit 0; DESCRIPTION
POE::Test::Loops contains one function, generate(), which will generate all the loop tests for one or more POE::Loop subclasses. The "SYNOPSIS" example is a version of poe-gen-tests, which is a stand-alone utility to generate the actual tests. poe-gen-tests also documents the POE::Test::Loops system in more detail. FUNCTIONS
generate( $DIRBASE, @LOOPS, $VERBOSE ) Generates the loop tests. DIRBASE is the (relative) directory in which a subdirectory for each of the LOOPS is created. If VERBOSE is set to a TRUE value some progress reporting is printed. POE::Test::Loops::generate( "./t", [ "POE::Loop::Yours" ], 1, ); SEE ALSO
POE::Loop and poe-gen-tests. AUTHOR &; COPYRIGHT See poe-gen-tests. perl v5.14.2 2012-03-11 POE::Test::Loops(3pm)
All times are GMT -4. The time now is 05:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy