View Full Version : [SOLVED] awk: can I decrement `length($x)`
alphaniner
January 15th, 2010, 04:50 PM
Is there anyway to modify the value of `length($x)` in the following:
awk '{print substr($9,1,length($9))}'
Specifically, I want to decrease it by one. I know there's a myriad of other ways I could do what I want to do, I'm just hoping I can avoid doing them.
saulgoode
January 15th, 2010, 08:34 PM
Why not just subtract one from value returned?
awk '{print substr($9, 1, length($9) - 1)}'
lisati
January 15th, 2010, 08:39 PM
Why not just subtract one from value returned?
awk '{print substr($9, 1, length($9) - 1)}'
Beat me to it!
Saving the result(s) a function/procedure returns and working on the saved copy is sometimes easier than trying to modify the function/procedure yourself.
alphaniner
January 15th, 2010, 10:32 PM
Why not just subtract one from value returned?
awk '{print substr($9, 1, length($9) - 1)}'
<grumble> I swear I tried that and it didn't work. Thank you.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.