Reset the counter in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reset the counter in shell script
# 1  
Old 12-03-2010
Reset the counter in shell script

I am executing the following script using 'awk -f process.awk out' where 'out' is the input file which consists of 5000 sequences. Each time it takes one sequence, run the below program by creating a directory, run the mfold command within that directory, running another shell script 'final5' and redirect the output to a file from final5 shell. After that the directory is deleted, taking second sequence from 'out' and repeating this process. It is working well upto 1020 directories. From 1021 it is giving error. After executing this 1000 times, can we reset the counter to 1 in such a way it takes it as directory 1 and start this process for 1001 to 2000 sequences. Similarly I have to reset the counter to five times because input file contains 5000 seqeunces. Shell scripting for this is highly appreciated. Thanks in advance.


Code:
 
process. awk
 
BEGIN {
   FS=">";RS=">";ORS="";
}
$NF { d++
  system("mkdir dir"d);
  print ">"$0 > ("dir"d"/input");
  system("cd dir"d"; mfold SEQ=input");
  system("cd dir"d"; /home/rsankar/bin/mfold SEQ=input");
  system(cd "/home/rsankar/rna/temp");
  system("sh final5");
  system("rm -rf dir"d);

# 2  
Old 12-04-2010
Please show us what you have as input, and what you want as output.

Massively using "system" function in awk may demonstrate that what you are trying to achieve should be done by a shell script instead.
# 3  
Old 12-04-2010
You need to close the file after you are done writing to it:
Code:
close("dir"d"/input")

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with simple script with counter

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am to create a script that checks a file for specific attributes. Read, write, execute, if the file is empty,... (13 Replies)
Discussion started by: silencep77
13 Replies

2. UNIX for Advanced & Expert Users

Automating Password reset without shell usage

Our application runs on AIX and the users of the application do not have a way to land at the prompt/shell by any means. When they login to the box, the application opens up directly. I would like to know of a way to automate the password reset process for these user ids, without them having to... (2 Replies)
Discussion started by: ggayathri
2 Replies

3. UNIX for Dummies Questions & Answers

Automatic counter script

Hello, I am having trouble calculating some numbers and I was hoping someone could help me solve this. I have one file with 1 column and what I'm trying to do is add up the lines until a certain value is reach, then jump to where it last finished counting and continue. so for ex: if I... (27 Replies)
Discussion started by: verse123
27 Replies

4. Shell Programming and Scripting

How to display a counter in shell script?

Hi, I am writing a script which processes large number of files in a directory. I wanto display a counter which increment after processing each file. I am processing each file in a for loop. If I echo a variable with its value increasing with each file, I will get around 5000 lines as output.... (10 Replies)
Discussion started by: jaiseaugustine
10 Replies

5. UNIX for Dummies Questions & Answers

shell (tcsh) prompt gets reset on every cd

Hi, I type in my shell: set prompt="(%M) %c%b%# " to get something like: a/b/c> this works, but only partially. every time I move to to a different directory (i.e. 'cd <some dir>'), the prompt is reset. Meaning, when I 'echo $prompt' after setting the prompt I get the correct prompt,... (8 Replies)
Discussion started by: yuvalbn
8 Replies

6. AIX

reset the counter days for uptime command

hello, i send the uptime command in the AIX and the days that is UP 14652 days this is around 40 years, today is with the correct date&time, hos can I reset the counter days? somebody can help me? regards (3 Replies)
Discussion started by: timflr
3 Replies

7. Shell Programming and Scripting

How to reset password in shell script?

Hi folks, How can we reset the password via shell script... How can i manage to pass password for the prompt. gws000i010:/ # passwd test1 New Password: (1 Reply)
Discussion started by: bullz26
1 Replies

8. Shell Programming and Scripting

Accumulate counter in script

Hi, I'm new to unix and have a problem? I'm writing a basic script in ksh and it is a basic quiz with 5 questions. I need to be able to accumulate the correct answers at the end and echo out the total correct answers, I cannot work it out? Please see script so far. If anyone can help that will... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

9. Shell Programming and Scripting

Counter Script..help please

I have generated a script that will email a list of people if a certain PID is not running, using "mailx". I have the script running every 5 minutes as a cron job. I want the script to stop sending an email, if the email has been sent 5 times (meaning PID is dead). I want this so that my... (3 Replies)
Discussion started by: Sunguy222
3 Replies

10. UNIX for Dummies Questions & Answers

Error in Script (counter)

Hello: Executing following script i'm getting error: 1=1+1: 0403-058 Assignment requires an lvalue. It's not assuming the counter but i don't know why. Some hint? Thank you very much in advance. #!/bin/ksh <path>/tiempos.txt num_exe=1 TIEMPOS=<path>/tiempos.txt while ] do (2 Replies)
Discussion started by: Felix2511
2 Replies
Login or Register to Ask a Question