Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

how can i put the condition in for loop for the below.

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-28-2008   -   Original Discussion by mail2sant
mail2sant mail2sant is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 17 October 2012, 12:27 AM EDT
Location: bangalore
Posts: 100
Thanks: 0
Thanked 1 Time in 1 Post
how can i put the condition in for loop for the below.

i have the equation like below

07:35:07 ( AB : 2319f.ab * 22) + ( AB : 2320f.ab * 22.03 ) + ( AB :2321f.ab * 22.07 ) ...... N

i want put ":" as a delimiter and break the equation like below


2319f.ab * 22
2320f.ab *22.03
2321f.ab * 22.07
.
.
N

i know the number of coulmn for Eg 12 then i can user
for (( i=5;i<12;i++ ))

do

cat $1 | cut -d ":" -f"$i" >> a1
done


but for N number of .. how can i cut for the above ?
Sponsored Links
    #2  
Old Unix and Linux 04-28-2008   -   Original Discussion by mail2sant
Ygor's Unix or Linux Image
Ygor Ygor is offline Forum Advisor  
Advisor
 
Join Date: Oct 2003
Last Activity: 15 May 2015, 11:55 AM EDT
Location: 54.23, -4.53
Posts: 1,801
Thanks: 1
Thanked 114 Times in 99 Posts
Try...
Code:
$ echo '07:35:07 ( AB : 2319f.ab * 22) + ( AB : 2320f.ab * 22.03 ) + ( AB :2321f.ab * 22.07 ) ...... N' |\
> awk 'BEGIN{FS=":|\\(";RS=")"}{print $NF}'
 2319f.ab * 22
 2320f.ab * 22.03
2321f.ab * 22.07
 ...... N

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
While loop only if a condition is met Cranie UNIX for Advanced & Expert Users 4 05-09-2011 07:39 AM
Leaving for loop on condition FrancescoIt Shell Programming and Scripting 5 02-14-2011 10:08 AM
Use of -z in while loop condition vidyaj Shell Programming and Scripting 3 12-03-2010 01:21 AM
if condition in a while loop svajhala Shell Programming and Scripting 14 11-16-2010 03:03 PM
What condition to be put in the while loop? nehaquick UNIX for Dummies Questions & Answers 1 02-15-2008 04:06 PM



All times are GMT -4. The time now is 07:12 PM.