how to execute ksh simple shell script without creating .sh file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to execute ksh simple shell script without creating .sh file
# 1  
Old 10-24-2011
how to execute ksh simple shell script without creating .sh file

please help me to execute a simple shell script like
for i in `ls
echo $i
done

. i dont want to create a new sh file to execute it. Can i just type and execute it ? because I always this kind of simple for loops .

Please help .

Thanks
# 2  
Old 10-24-2011
Try it and find out? Smilie

Yes, you can just type it on the command line.
# 3  
Old 10-24-2011
i tried carlom.. what i want is if i need to use two continues for loops , what can i do ? once i type 'done' and hit enter... then the for loop wil be executed.
# 4  
Old 10-24-2011
Code:
$ for i in file*; do echo $i; done
file1
file2
file3

# 5  
Old 10-24-2011
I don't understand what you mean. You can nest for loops with no problem.


Code:
# for i in `ls`
> do
> for j in `ls -l $i`
> do
> echo $j
> done
> done
-rwxr-xr-x
1
myuser
mygroup
1995
Aug
31
2006
myfile

# 6  
Old 10-24-2011
Something like this?
Code:
[root@bt]# for i in 1 2 3;do echo $i; done; for i in 4 5 6; do echo $i; done
1
2
3
4
5
6

--ahamed
# 7  
Old 10-24-2011
thanks ahamed.. i put newline instead of ';' .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with creating a simple shell script

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: Write a shell script that accepts two arguments. The two arguments are the name of 2 files. • If the arguments... (3 Replies)
Discussion started by: Scripter12345
3 Replies

2. Shell Programming and Scripting

Execute a shell script in UNIX m/c from win 7 using ksh

I need to run a shell script on unix machine from windows 7. I used the "RSH" command in win XP successfully for this, But on win 7 it is not working. Can any body tell me how to run RSH on win 7 or any other command for similar use. I use the command as below rsh <unix m/c> -l <username>... (1 Reply)
Discussion started by: arup1980
1 Replies

3. Linux

How to execute a simple select script using a shell script?

Hi team, I have two select statements and need to run them using SYSDBA user select * from temp_temp_seg_usage; select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from dba_segments where segment_name='TEMP_TEMP_SEG_USAGE'; Need to run this using a shell script say named... (1 Reply)
Discussion started by: pamsy78
1 Replies

4. Shell Programming and Scripting

KSH Script to Execute command from specific column in file

Hi Unix Experts,Team I have a file (say comand_file.prm), The file has a command specified in column 6 (say "./execute_script.sh"). I want to execute this command in my script. I am writing a KSH script to achieve this. Could you please assist me with this. (6 Replies)
Discussion started by: Jeevanm
6 Replies

5. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

6. Shell Programming and Scripting

How can I execute another shell from my ksh script?

I am newbie in UNIX, so please excuse me for the stupid question.:) Here is a problem: I created ksh script where the part of the functionality include an opening of a second session with another shell process "runrep"(runrep is a custom reporting shell designed by Advent Geneva). When I run my... (3 Replies)
Discussion started by: alexstar
3 Replies

7. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

8. Shell Programming and Scripting

Creating a .sh script to execute an SQL file

Hello I'm hoping someone may be able to help. I'm absolutely brand new to these shell scripts and have tried to bash bits together from the little learnt but my final script still doesn't work. Sorry if something similar is already posted but couldn't find anything existing close enough to help... (1 Reply)
Discussion started by: Dan27
1 Replies

9. Shell Programming and Scripting

Execute .dat file from a shell script

Hi, I have a .dat file in my home directory of UNIX. I want this file to be executed by a shell script. Please help me out a.s.a.p (2 Replies)
Discussion started by: user9526
2 Replies

10. Shell Programming and Scripting

Creating simple shell program

Hi, I'm new to UNIX shell programming... can anyone help in doing the following : 1) create a text file named "Model File" having following columns : Name Number Physics Chemistry 2) prompt user to n rows enter the name, number, physics ,chemistry 3) display the entire columns and rows... (1 Reply)
Discussion started by: Mayuri P R
1 Replies
Login or Register to Ask a Question