While loop program


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers While loop program
# 1  
Old 07-25-2006
Data While loop program

I have a data file contain the following information:

1
2
3
4
5
10
11
30
90
300
9
29
and on and on

I need to create a program with give me the following data format:

Jon
A
ABCD=1
T=n
X
Y
Exit

Jon
A
ABCD=2
T=n
X
Y
Exit

Jon
A
ABCD=3
T=n
X
Y
Exit

Jon
A
ABCD=4
T=n
X
Y
Exit

Jon
A
ABCD=5
T=n
X
Y
Exit

and on and on until it reaches the last number

Please help!

Thanks!
# 2  
Old 07-26-2006
Code:
[/tmp]$ cat try.ksh
#! /bin/ksh

for num in $(<num.txt)
do
echo "
Jon
A
ABCD=$num
T=n
X
Y
Exit"
done

num.txt contains all numbers.
# 3  
Old 07-26-2006
in a single line

awk '{printf "Jon\nA\nABCD=%d\nT=n\nX\nY\nExit\n\n",$0 }' num.txt
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies

2. UNIX for Dummies Questions & Answers

Using Shell Script To Loop Program Through Multiple Text Files

Hello, So I have approximately 300 files of raw data (.txt) files that I am using to perform statistical analysis. I have been able to construct a Fortran program that is able to perform my statistical analysis on a file by file basis. However, I now want to be able to loop program through... (19 Replies)
Discussion started by: Jimmyd24
19 Replies

3. Shell Programming and Scripting

For loop to run external program

Hi, I was hoping for help with a for loop to run a program (vina) repeatedly using all the files in a folder as input. Currently my code looks like this: #!/bin/bash FILES=/home/afalk/Desktop/battest/*.pdbqt for f in $FILES do vina --config /home/afalk/Desktop/A.txt --ligand "$f".pdbqt done... (5 Replies)
Discussion started by: oldmanwinter
5 Replies

4. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

5. Shell Programming and Scripting

Running binnary program in a loop

I am using a very simple script (MUS) to process some files where the input file for the binary application I am running has to be named infile. So I have this: #!/bin/bash for i in {1..n} do mv block${i} infile done ./dnadist <<EOF D Y EOF However, I want to use dnadist inside the... (3 Replies)
Discussion started by: Xterra
3 Replies

6. Shell Programming and Scripting

Invoking a program in a loop

In the following script, I wish to invoke a compiled C++ program, consimv4 and pass it some command line arguments through the shell script's command line arguments and variables. But for some reason, when I run the script, I just return to the shell prompt and nothing happens. For the life of me,... (7 Replies)
Discussion started by: msaqib
7 Replies

7. Programming

Python program faster than C++ program.

I wrote a simple program that generates a random word 10,000,000 times. I wrote it in python, then in C++ and compared the two completion times. The python script was faster! Is that normal? Why would the python script be faster? I was under the impression that C++ was faster. What are some of... (2 Replies)
Discussion started by: cbreiny
2 Replies

8. Shell Programming and Scripting

program in loop.

eg: sample.dat 21111111110000652 B86860003OLFXXX0000001_20081227 21111111110000652 B86860003ODL-SP0000002_20081227 21111111110000652-B94030001ODL-CH0000003_20081227 22222222220000653-B94030001OLFXXX0000011_20081227 23333333330000654-E71060001OLFXXX0000012_20081227 24444444440000655... (5 Replies)
Discussion started by: kshuser
5 Replies

9. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

10. Shell Programming and Scripting

redirect variable to same program at next loop

Hi all, I don't know how to redirect a variable in this case: while true do ./ready_data ... done ready_data should read a file looking for an ID, if this doesn't exist then add the last ID seen into the first line. When ID exists there is no problem, but when ID doesn't... (0 Replies)
Discussion started by: csecnarf
0 Replies
Login or Register to Ask a Question