The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Executing scripts in Parallel itsme_maverick Shell Programming and Scripting 2 06-06-2008 08:23 AM
Reading 5 Students names and grades using while loop???? dlbomber1 Shell Programming and Scripting 1 11-25-2007 10:46 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 01:25 AM
Executing Shell Scripts BuyoCat UNIX for Dummies Questions & Answers 1 09-06-2005 10:11 PM
executing variables in ksh scripts? zedmelon Shell Programming and Scripting 3 08-06-2003 10:50 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-07-2007
Registered User
 

Join Date: Oct 2007
Posts: 13
Unhappy executing scripts by reading names from a file

file.txt contains
------------------
sat1 1300
sat2 2400
sat3
sat4 500

I need to write a shell script that will output like the below
#output

sat1.ksh 1300
sat2.ksh 2400
sat3.ksh
sat4.ksh 500

my try
-------
#!/bin/ksh

for i in `cat file.txt`
do
SCR_NAME=`echo $i| awk '{print $1}'`
PARAM=`echo $i| awk '{print $2}'`
echo "${SCR_NAME}.ksh ${PARAM}"
# want to call a function here in future
done

can someone please advise??

~

Last edited by konark; 11-07-2007 at 04:23 PM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-07-2007
Registered User
 

Join Date: Oct 2007
Posts: 13
Any suggestion for the above query '??

Last edited by konark; 11-07-2007 at 04:25 PM.
Reply With Quote
  #3 (permalink)  
Old 11-07-2007
Registered User
 

Join Date: Oct 2007
Posts: 13
Unhappy

FILE=file.txt

for i in `cat $FILE`
do
SCR_NAME=`awk '{print $1}' $i`
PARAM=`awk '{print $2}' $i`
echo "${SCR_NAME}.ksh ${PARAM}"
done


I m trying to do something like this. It doesnt work .Can you please help
~
~
~
Reply With Quote
  #4 (permalink)  
Old 11-07-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,441
Code:
awk '{$1=$1".ksh"}1' file
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0