The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find and FTP multiple files in Korn Shell lambjam UNIX for Dummies Questions & Answers 2 08-13-2007 11:50 PM
Run a process through inetd using korn shell!!! vishi_82 Shell Programming and Scripting 8 06-11-2007 09:00 AM
Lookup between 2 files ( korn shell ) pavan_test UNIX for Dummies Questions & Answers 17 01-31-2006 04:07 PM
korn shell + sftp + list files alienET Shell Programming and Scripting 1 03-24-2005 11:12 AM
Multiple su - in Korn Shell script furrari Shell Programming and Scripting 2 07-30-2004 10:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-22-2005
stevefox stevefox is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 115
Question How to process multiple files in Korn Shell

How do I make the below ksh to process all of the files inside a user specified directory?
Currently it can only process one file at a time.

#!/bin/ksh

tr -s '\11 ' ' ' < $1 > temp0

sed -e 's/,//g' temp0 > temp1

cut -d' ' -f1,4,5 temp1 > final_output

rm temp0 temp1
  #2 (permalink)  
Old 11-22-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
This should work

Code:
for file in /dir/to/process/*
do
tr -s '\11 ' ' ' < $file > temp0
sed -e 's/,//g' temp0 > temp1 
cut -d' ' -f1,4,5 temp1 >> final_output
rm temp0 temp1
done
  #3 (permalink)  
Old 11-22-2005
stevefox stevefox is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 115
Thank you Vino!
It worked.
  #4 (permalink)  
Old 11-22-2005
Abhishek Ghose Abhishek Ghose is offline
Registered User
  
 

Join Date: Sep 2005
Location: Chennai
Posts: 81
Quote:
Originally Posted by vino
This should work

Code:
for file in /dir/to/process/*
do
tr -s '\11 ' ' ' < $file > temp0
sed -e 's/,//g' temp0 > temp1 
cut -d' ' -f1,4,5 temp1 >> final_output
rm temp0 temp1
done

You really dont need "rm temp0 temp1" in the loop. You can use rm outside the loop.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0