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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem in For Loop The Observer Shell Programming and Scripting 2 05-28-2008 03:43 AM
for loop problem namishtiwari Shell Programming and Scripting 5 01-25-2008 12:58 PM
Problem with for loop/sed ? chiru_h Shell Programming and Scripting 2 08-27-2006 12:55 PM
loop Problem dhananjaysk Shell Programming and Scripting 3 03-31-2006 02:05 PM
problem with while loop mridula High Level Programming 1 12-11-2005 11:44 AM

Closed Thread
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
  #1 (permalink)  
Old 05-25-2007
maskot maskot is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 20
loop problem

Got a problem with a loop that do this for each line:
a=$(( cost + $( awk ' { print $2 } ' file) ))
awk ' $2 ~ "^[0-9]" && $2 > 0 {$2='$a';print} ' file

#!/bin/sh
cost=30
for, until, while?
do
"db update OD_LINK_COST something"
done

For troubleshoot the file looks like this
55 10
56 10
57 20
58 10
and so on
  #2 (permalink)  
Old 05-25-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
Something like that ?


Code:
#!/bin/sh
cost=30
awk -v cost=$cost '$2 ~ "^[0-9]" && $2 > 0 {$2 += cost; print}' file

Output:

Code:
55 40
56 40
57 50
58 40

Jean-Pierre.
Closed Thread

Bookmarks

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 11:20 PM.


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