Script to loop process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to loop process
# 8  
Old 01-28-2016
Quote:
Originally Posted by ust3
thank reply ,

I changed the code to as below

while read d1
do while read d2
do while read d3
do while read d4
do while read d5
do echo "abc"
done < f5
done < f4
done < f3
done < f2
done < f1
after run it , it pops "f1: No such file or directory" .
may be there is a simpler method .
if I would like to have a script a open a certain amount of files ( eg. 1000 ) in background mode , would advise how to write such script ?
thanks
Hello ust3,

I would like to suggest you please provide complete information about what you are trying to achieve here, it is the simple error which you are getting. You are getting "f1: No such file or directory" because there will not be any file present into your path named f1(You should provide files which are present in the path where you are trying the loop, else provide the exact files path to it.). Without knowing the complete picture of requirement we all here could only guess and increase the number of posts in this thread, hope this helps.

Thanks,
R. Singh
# 9  
Old 01-28-2016
May I doubt that it is wise to explore the limits of your system if you don't know why f1: No such file or directorypops up and how to remedy it?

If you really really want to try sth - at your own risk - here's small example of what you could do (with a recent shell)
Code:
for i in {5..15}; do eval exec "$i>f$i"; done
lsof -p$$
for i in {5..15}; do eval exec "$i>&-"; done

# 10  
Old 01-31-2016
Quote:
Originally Posted by RudiC
May I doubt that it is wise to explore the limits of your system if you don't know why f1: No such file or directorypops up and how to remedy it?

If you really really want to try sth - at your own risk - here's small example of what you could do (with a recent shell)
Code:
for i in {5..15}; do eval exec "$i>f$i"; done
lsof -p$$
for i in {5..15}; do eval exec "$i>&-"; done

thanks reply ,

the script seems create file but not eating up open file , right ?
if I would like to eating up open file , how to modify it ? thanks
# 11  
Old 01-31-2016
Your use of the phrase "eating up open file" is a technical term that is not clear to me (and, apparently, it is not clear to the other volunteers here who are trying to help you.

I gave you code that would read lines from files (but you would have to modify that script to use filenames that you had already created and had loaded with the data you wanted to read) and left a comment where you could fill in whatever code you wanted to use to eat your files. Ravinder showed you how to change that comment into a simple echo that would let the script read your files without actually doing anything with the data found in the files. RudiC gave you code that creates files and keeps file descriptor open (i.e., eats up open file descriptors) until the script terminates. Obviously, none of these meet your goal of eating your file(s).

If you would like to explain to us exactly what you are trying to do and why you are trying to do it, we may be able to help you achieve your goal.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process files in loop which have spaces in name

I have a folder with files and I have to process them in a loop. However the filenames have space characters, so the list get split. $ touch "File Number_1" $ touch "File Number_2" $ ls "/tmp/File Number"_* /tmp/File Number_1 /tmp/File Number_2 I tried following (sorry for using the... (3 Replies)
Discussion started by: Wernfried
3 Replies

2. UNIX for Dummies Questions & Answers

For loop in process each file

Hi I have following codecd /tmp/test/ for vfile in `ls -1` do for vlink in `ls -l /tmp/testfile/*|bin/grep "local/init\.d/$vfile$"|bin/awk -F"->" '{print($1)}'|bin/awk -F"/" '{print($NF)}'` I know `ls -1` list only file, but I don't... (3 Replies)
Discussion started by: stew
3 Replies

3. Shell Programming and Scripting

Bash Question: HowTo Exit Script with User Input While Process is Running Mid-Loop?

Hi, I have written a script that allows me to repetitively play a music file $N times, which is specified through user input. However, if I want to exit the script before it has finished looping $N times, if I use CTRL+c, I have to CTRL+c however many times are left in order to complete the loop.... (9 Replies)
Discussion started by: hilltop_yodeler
9 Replies

4. Shell Programming and Scripting

Infinite while loop script shows more than one process

Hi, I have a script which triggers an infinite loop. #!bin/bash trig=`ls /home/trig.tch |wc -l` function callj { some commands... } while do callj & done The number of process after doing a ps -ef |grep Mon.sh returns processes even after the script is killed by deleting the... (4 Replies)
Discussion started by: chetan.c
4 Replies

5. Shell Programming and Scripting

need to process for loop faster

I have the following code running against a file. The file can have upwards of 10000 lines. problem is, the for loop takes a while to go through all those lines. is there a faster way to go about it? for line in `grep -P "${MONTH} ${DAY}," file | ${AWK} -F" " '{print $4}' | awk -F":"... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. UNIX for Dummies Questions & Answers

Writing a loop to process multiple input files by a shell script

I have multiple input files that I want to manipulate using a shell script. The files are called 250.1 through 250.1000 but I only want the script to manipulate 250.300 through 250.1000. Before I was using the following script to manipulate the text files: for i in 250.*; do || awk... (4 Replies)
Discussion started by: evelibertine
4 Replies

7. Shell Programming and Scripting

Process checking loop

Hi, I want to create a script who will check if the java process is running & if it finds the process is still there it continues to execute & when the process completes it exit from the script. I have written a code to check & notify the process existence but i am not getting how to write... (4 Replies)
Discussion started by: d8011
4 Replies

8. Shell Programming and Scripting

How to loop this process?

for two txt files, f1 and f2, I like to do the following grep "abcde" f1 > abcde$f1 grep "xyz" f1 > xyz$f1 can I use a loop to get this done? Thanks for i in f1 f2 do grep "abcde" $i > abcde$i grep "xyz" $i > xyz$i ... done (11 Replies)
Discussion started by: ksgreen
11 Replies

9. Shell Programming and Scripting

script to loop all process ids and take pmap

Hi all, I need a script that will loop around all the current processes and take a pmap -x <process id> and output each pmap to a separate file. Would anyone have a quick command to do this? (2 Replies)
Discussion started by: borderblaster
2 Replies

10. Shell Programming and Scripting

loop when process running

Hi Gurus, Could you please help me to create a shell script that will be started by a cron job once every night at 24.00 h (that should bee easy:)) The shell script should control every 30 seconds the name of a process, and when the process doesn't run anymore it should execute a few further... (12 Replies)
Discussion started by: blackwire
12 Replies
Login or Register to Ask a Question