Dynamically creating text files using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dynamically creating text files using shell script
# 1  
Old 05-07-2009
Dynamically creating text files using shell script

Hi All,
I want to create a shell script which dynamically create text files. i am using the following script
$i=1
while [ $i -le 4 ]
do
cat > test_$i.txt
done

but while running the script it was stopping(the cursor not going to next step, i have to enter ctrl+c to make it stop). it is creating only file test_1.txt only. The others are not creating. Can anyone help me out.
> sh myprogramme.sh
****Here the control is stopping, i entered ctrl+c to stop****
>
# 2  
Old 05-07-2009
Code:
#!/bin/sh

i=1
while [ $i -le 4 ]
do
   touch  test_$i.txt
   i=`expr $i + 1`
done

# 3  
Old 05-07-2009
Thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating a text based game using shell script.

Hello guys I'm new to shell scripting and I need to make a game using shell script. I want to know if it is possible for me a total noob to shell scripting to make this game. The game concept is simple: First thing when you launch the script you get a menu in which you select if you want to... (3 Replies)
Discussion started by: Othmane
3 Replies

2. Shell Programming and Scripting

Creating IN list in PLSQL script dynamically by using shell script

Hi all, I have a PLSQL script which has a IN list where it takes some ids as input. For example SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID IN (comma separated list ) I want to run this quest inside a shell script but I would like to prepare the IN list dynamically where the employee ids... (1 Reply)
Discussion started by: LoneRanger
1 Replies

3. Shell Programming and Scripting

Bc in shell script is creating blank files

Hi, I am creating a shell script which will check the processing of the main script if the error count is more than 2% of the record count in a feed. Part of the code is below: err_tol=`echo $feed_cnt \* 0.02 |bc` while read line do err_cnt=$(grep -i "$line" $err_log | wc -l) ... (5 Replies)
Discussion started by: member2014
5 Replies

4. Shell Programming and Scripting

Creating new users using a text file as imput (using only shell script and/or awk)

I need somebody who could help with an exercise. You have a text file called users.txt with this info inside: users.txt: user1:1234:/home/homedir1 ; user2:1234:/home/homedir2 ; user3:1234:/home/homedir3 ; user4:1234:/home/homedir4 ; The script should create an user using the... (2 Replies)
Discussion started by: marcosruiz
2 Replies

5. Homework & Coursework Questions

Need help creating shell script with output that has 2014 calendar and 2 text items from a"fortune"

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 required to create a bash shell script with either emacs or vi. It must include the year 2014 calendar on... (9 Replies)
Discussion started by: dandanhelpmeman
9 Replies

6. Programming

Dynamically added text fields passed to PHP script

If I am posting this to the wrong section please move it somewhere it fits. I apologize if this is not the correct section. I have a site where I want to have form that in a "Visitor name" section to be able to add fieldets as needed. I think I have that worked out. So the below code is the... (4 Replies)
Discussion started by: GroveTuckey
4 Replies

7. Shell Programming and Scripting

Creating variables dynamically and using it in script?

Hi, I have a problem that I am trying to solve and would greatly appreciate some input to solve this. I have a file containing variable length of line. Each line in the file has values separated by "," and i need to grep for these values in a some files. For example below is a sample file with 3... (12 Replies)
Discussion started by: davidtd
12 Replies

8. Shell Programming and Scripting

how to create the files dynamically in c shell script

how can i CREATE a txt file dynamically in c shell: for instance: #! /bin/csh for each i (*) cat>file$i.txt for each j do .... (1 Reply)
Discussion started by: jdsignature88
1 Replies

9. Shell Programming and Scripting

Dynamically Creating and Printing to Files

Hello, If anyone could help me out with this, it would be greatly appreciated. I am trying to dynamically create files and print to them. Here is the code I have to so far. thanks. if (n < 5000 ) { # do nothing } else { n = 0; filenum++; # out = ("out" filenum); } ... (1 Reply)
Discussion started by: Laud12345
1 Replies

10. Shell Programming and Scripting

Shell script dynamically case in VAR

Hallo, I am working on a kdialog. This shall be able to load the required commands from a .conf file. First step runs good by loading the entries (selectabel entries) in a variable: MIRRORSELECT=$(kdialog --radiolist "Select your nearest mirror" $VAR1) The kdialog is accordingly correct... (2 Replies)
Discussion started by: ACTGADE
2 Replies
Login or Register to Ask a Question