Sponsored Content
Full Discussion: Loop through files
Top Forums UNIX for Dummies Questions & Answers Loop through files Post 302104262 by kshelluser on Wednesday 24th of January 2007 10:31:45 AM
Old 01-24-2007
Loop through files

Hi,

I'm trying loop through all files in a directory that have a filename starting with 'CC', and process them one by one. Can any provide an example of how I could do this. I've started with:

if test -f CC*
then

#add files to an array

#loop through array and process the file based on the filename held in each array element

else
#print no files found to the log file and send email
echo 'process bypassed - payments file not available' >> jnls/process.jnl
head -20 jnls/process.jnl | mailx -s "Failure in process.sh" emailaccount
fi

p.s. it's on a kornshell
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop through files in a directory

Hi, I want to write bash script that will keep on looking for files in a directory and if any file exists, it processes them. I want it to be a background process, which keeps looking for files in a directory. Is there any way to do that in bash script? I can loop through all the files like... (4 Replies)
Discussion started by: rladda
4 Replies

2. Shell Programming and Scripting

reading from 2 files through while loop

hi i have two files cat input.txt 123456| 43256 456482|5893242 cat data.txt xv 123456 abcd dsk sd 123456 afsfn dd df 43256 asdf ff ss 456482 aa sf 5893242 ff ff aa 5893242 aa aa i need to read inputs from input.txt and find data for data.txt. then i need to print them as a... (2 Replies)
Discussion started by: windows
2 Replies

3. Shell Programming and Scripting

Grep Different Files Using a Loop?

I have a script to GREP for a text expression within certain files, the files being named file.11012008 thru file.11302008. 30 files in all, one for each day of the month. Instead of entering the following 3 lines of code 30 different times, I'm trying to find a way to loop the process: ... (6 Replies)
Discussion started by: foleyml
6 Replies

4. UNIX for Dummies Questions & Answers

For loop using 2 files

Hi all, Can anyone shed any light on the following problem? I have 2 columns in File1: 10 8 30 44 50 59 94 96 ... (15 Replies)
Discussion started by: dr_sabz
15 Replies

5. Shell Programming and Scripting

loop through files in directory

hi all i have some files present in a directory i want to loop through all the files in the directory each time i loop i should change the in_file parameter in the control file and load it into a table using sql loader there is only one table where i have to load alll the files ... (3 Replies)
Discussion started by: rajesh_tns
3 Replies

6. Shell Programming and Scripting

Loop to copy like files

Hi, I need to write a script that copies all .zip files in the subdirectories of ~100 folders. No clue how to write a loop that goes into each folder, searches for a .zip file, and copies it and extracts it to a unique location. I imagine something like cp -f /home/folder1/*.zip... (6 Replies)
Discussion started by: nez
6 Replies

7. Linux

rename files using loop with different name

Hi, i need to write a shell script where i have to loop through all the file in a directory and rename them based on below condition. file1.dat file2.dat file3.dat the above files has to be moved to another directory like below file1_201001.dat file2_201002.dat file3_201003.dat... (3 Replies)
Discussion started by: feroz
3 Replies

8. Shell Programming and Scripting

awk_Compare two files with a loop

Hi, I have a small query when comparing two files with awk. I have a small piece of code running in a shell. See below: gawk -F"," 'NR == FNR { A=1; next } \!A' OFS="," 2011.csv 2012.csv > diff_2012.csv The code works fine (Note I had to escape the ! with \! to run in shell). What I want... (6 Replies)
Discussion started by: theflamingmoe
6 Replies

9. UNIX for Dummies Questions & Answers

Loop over files and use awk

Hi, I have a large number of files which are numbered numerically, i.e. of the type 1.usr, 2.usr, 3.usr ... This is what I'd like to do: 1. In ascending order, use awk to read a value from each file. 2. Write this value to another file (say data.txt). This file, 'data.txt' should be... (4 Replies)
Discussion started by: lost.identity
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 02:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy