![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Processing a log file based on date/time input and the date/time on the log file | primp | Shell Programming and Scripting | 4 | 03-16-2008 11:23 AM |
| read a list one at a time | nortypig | Shell Programming and Scripting | 7 | 08-27-2006 09:50 PM |
| why shell scripting takes more time to read a file | brkavi_in | Shell Programming and Scripting | 1 | 06-23-2006 08:20 AM |
| Terminal Hungup at the time of read | pkusumam | Shell Programming and Scripting | 1 | 11-30-2001 04:19 AM |
| How to read and write files one line at a time. | s_chopra | UNIX for Dummies Questions & Answers | 2 | 04-18-2001 09:39 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to read max of 10 file at a time?
Hi All,
Please advise . Welcome more suggestions. For examples, I have 1000 file with prefix x??? In fact, I want to convert them to x???.txt with max 10 files at a time. As such, I will need to call another script to read from those 10 *txt files and sleep 5000 to convert the next 10 again. xaaa ; ; xbbz Hope to hear from. Regards, |
|
|||||
|
Aigles, about your solution:
1) It does not work if the number of files is not multiple of 10. 2) The user is asking to work with 10 files at a time. You are working with one at a time. Here is one possible solution to rename the files: Code:
for mFile in x??? do mv $mFile $mFile".txt" done Code:
set -- x???.txt
printf "%s %s %s %s %s %s %s %s %s %s\n" $@ | \
while read m10Files
do
echo "m10Files = "${m10Files}
done
|
|
|||||
|
Quote:
2) The script is called every ten files. I add a variable containing the file names (can be used as a parameter for the script) Code:
count=0
file_list=
limit=10
ls x??? | \
while read file
do
mv $file $file.txt
count=`expr $count+1`
file_list="$file_list $file.txt"
if [ $count -ge $limit ]
then
/path/to/another_script $file_list &
sleep 5000 # Wait more than an hour (5000 secs)
count=0
file_list=
fi
done
[ $count -gt 0 ] && /path/to/another_script $file_list &
|
|
||||
|
Code:
count=0
limit=10
mydate=`date '+%Y%m%d%H%M%S'`
cd /var/tmp/VAS
for mFile in x????
do
mv $mFile $mFile".txt"
count=`expr $count+1`
if [ $count -le $limit ]
then
sh up.sh 2>LOG/update.sh.$mydate.log &
sleep 5000
mv *out LOG/
count=0
fi
done
Something wrong... Please advise |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|