The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Assigning values to an array via for/while loop fiori_musicali Shell Programming and Scripting 2 11-24-2008 11:01 PM
Assigning the values to an Array kkraja Shell Programming and Scripting 1 08-11-2008 06:28 AM
string manipulating psalas UNIX for Dummies Questions & Answers 9 04-15-2008 10:00 AM
assigning values to a variable trichyselva UNIX for Dummies Questions & Answers 3 12-14-2007 01:55 AM
Assigning values to an array yongho UNIX for Dummies Questions & Answers 4 07-13-2005 08:49 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-15-2009
Anteus Anteus is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 54
retreiving and assigning values and manipulating string in a for loop

Hi

I am new to shell scripting and i am preparing a script.
for now i am work on a sub part of it..but i am unable to make it work.

---
the test code that i am working on
--------------------------
IFS=""
Sample_eve=`psg proc_s | grep tY`
n=0
for line in $Sample_eve
do
n=`expr $n + 1`
Sam$n=$(`echo $line |awk -F" " {print $5}' |awk -F":" '{print $2}'`)
echo $Sam$n
done
----------------------------
what i am trying to this is..
list all the process named proc_s that are currently running and are on the machine tY..
populate them in the variable Sample_eve.
and then access each line from the Sample_eve and process them on an individual basis.
but it is not happening ..for loop only goes through once..if i do not set IFS="" then line takes word by word data from the $Sample_eve...by which i cannot get seperate start time for each process. (it runs 35 times for 4 lines..i want to make it run only 4 time for 4 line).

i am doing `echo $line |awk -F" " {print $5}' |awk -F":" '{print $2}'` ..so as to get the start time for each process in minutes..then i am assigning it into array Sam so as to get the start Minute for each process.
but getting an output error like this..
for this array assignment as Test[9]: 04^J28^J04^J09: not found.
04, 28,04,09 are correctly shown they are the minutes ..but is not in a proper manner.

i am stuck with this thing .. please help me. I am unable to make the code work.

i am using the korn shell.
thanks
 

Bookmarks

Tags
awk, cut, for each, for loop

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0