For Loop to execute a command on a series of files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers For Loop to execute a command on a series of files
# 1  
Old 11-16-2009
For Loop to execute a command on a series of files

Hello,

I have a set of input data that I split into batches using the following command:


split -l 4000000 MyInput.in Split_a

Once I get the split files, I run a certain command on the split files that spews an output. So far I have been doing it without a for loop. How can I translate the following pseduo code so that I don't need to execute the command for every single split input.

For all the files that have been split
do
command <Split_a*.in> <Split_a*.out>
done


Thanks,
Gussi
# 2  
Old 11-16-2009
for i in Split_a*
do
whatever $i
done
# 3  
Old 11-17-2009
MySQL

Thanks TonyLawrence,

The code served me well!

~Gussi
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use for loop to execute multiple .sql files while using SQLPLUS for db connection.?

Hello , Im calling every single file inside my script like 1.sql,2.sql so on it looks so tedious. I want to replace with for loop where every file gets executed. When i use for loop im getting errorUnexpected EOF] , can anyone please help me out in this.. How i can use for loop to invoke my... (6 Replies)
Discussion started by: preethi87
6 Replies

2. Shell Programming and Scripting

Execute a Command in a .Dat File and use it in other Files

We have a process where we store the database password in a config file like below from where the password is picked up and used in Database Scripts ID, Password But we now have a Audit Requirement not to have the passwords in Config Files directly. We have a command which could fetch the... (2 Replies)
Discussion started by: infernalhell
2 Replies

3. Shell Programming and Scripting

Fibonacci series -going into infinite loop

Hello, I am a beginner to shell programming. Coded the following for Fibonacci series. #!/bin/bash fib() { i=0 j=1 arr=0 arr=1 echo "enter the limit:" read n while do fo= expr $j - 1 f1=$j f2= expr $j + 1 arr= expr ${arr} + ${arr} echo ${arr} (3 Replies)
Discussion started by: Rookie222
3 Replies

4. UNIX for Dummies Questions & Answers

Loop awk command on files in a folder

Hi, I'd like to loop an action over all files with given extension within a folder. The "main" action is: awk -F "\t" 'BEGIN{OFS="\t"}{if ($10=="S") print$0; }' input.txt > output.txt The input.txt should be every file in the folder with *.subVCF extension; and the output should be a file... (3 Replies)
Discussion started by: dovah
3 Replies

5. Shell Programming and Scripting

Execute script in series of folders

I'm trying to get a script to iterate of an array in bash run a series of commands in those folders. #Folder names folders=(folder1 folder2 folder3) #Common path for folders fold_path="/Users/Rich/Projects/" # For each element array copy script to folder and execute for f in... (2 Replies)
Discussion started by: 3therk1ll
2 Replies

6. Shell Programming and Scripting

How to execute a command inside a while loop?

How do we execute a command inside a while loop? (7 Replies)
Discussion started by: Little
7 Replies

7. Shell Programming and Scripting

Execute command with loop

I have a below command ALTER TABLE `abc` ADD PARTITION ( PARTITION 20130613 VALUES less than (DAY('13'))); Below is requirement It runs in Loop as DAY start with 13 and end with 100 along with this of counter "20130613" also increases per command as the next command should be ... (8 Replies)
Discussion started by: kaushik02018
8 Replies

8. Shell Programming and Scripting

find command in while loop - how to get control when no files found?

I have the following statement in script: find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do ... done When there are no files located by the find comand it returns: "find: bad status-- /home/rnitcher/test/....." to the command line How do I get control in... (3 Replies)
Discussion started by: mavsman
3 Replies

9. Shell Programming and Scripting

Can we execute series of commands from a single script?

Hi, I am trying to call a certain command from within a shell script, but everytime it executes the script, only the first command runs and it comes out of the control, how do i do it? code : ```````` #!/bin/sh # # #i=1 #while #do # i=`expr $i + 1` #done StoreXML -project xnat -l... (2 Replies)
Discussion started by: virendra maloo
2 Replies

10. Shell Programming and Scripting

command for a series of operations

I want to append a file containing a list of names and the sorted contents of the file should be copied to a new file. All this should be on a single line( using pipes and redirection) Pls help .. thankyou (1 Reply)
Discussion started by: phiber_optik
1 Replies
Login or Register to Ask a Question