1748170 Members
3870 Online
108758 Solutions
New Discussion юеВ

Re: Scripting question

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor
Solution

Re: Scripting question

>but I need the whole contents of the file and not just the lines containing PP=.

Then just print them:
awk '
/PP=/{print $1, $2 *2; next}
{ print $0 }' filename > file1
Raj D.
Honored Contributor

Re: Scripting question

mlewi000,

Check this out:


Code:
--------------------------------------------
# awk '{$2=$2*2} /PP=/ {print $0}' pp_file
--------------------------------------------

# cat pp_file
PP= 2 As a quick 0909 A00990
PP= 3 As a quick A09093 2342
PP= 5 sas a quick 09000! A00
PP= 9 sa a aqij 0900 A009
PP= 6 as oks fA09000 0090 00
SP= 7 sk sa aik a0000 aa
PP= 8.1 Asa sfllks 9990
NP= 3 aksfs A0009 aa0009
#
# awk '{$2=$2*2} /PP=/ {print $0}' pp_file
PP= 4 As a quick 0909 A00990
PP= 6 As a quick A09093 2342
PP= 10 sas a quick 09000! A00
PP= 18 sa a aqij 0900 A009
PP= 12 as oks fA09000 0090 00
PP= 16.2 Asa sfllks 9990
#



Cheers,
Raj.




*Remember to assign points to the responses all who tried o help you.
" If u think u can , If u think u cannot , - You are always Right . "
Suraj K Sankari
Honored Contributor

Re: Scripting question

Hi,
If you satisfied with the answer and your problem got solved then please make a habit to assign points,
Those people who give there valuable time for your problem they should expect some apparition from you in terms of points.

To know how to assign points please go through the below link

http://forums13.itrc.hp.com/service/forums/helptips.do?admit=109447627+1256027208667+28353475#33

Thanks
Suraj
Dadski
Advisor

Re: Scripting question

Old School and Raj D, apologies for not getting back, but the weekend took hold. I did'nt really get what I was looking for but you 2 were close. Thanks for everyones time and effort. I'm going to look into an awk script combined with sed to achieve it. All points assigned
Dadski
Advisor

Re: Scripting question

told a complete lie, Dennis your response was perfect, solved it a treat. Thanks for your time and I have assigned your points.
Dadski
Advisor

Re: Scripting question

Dennis thanks, thats perfect.
Dadski
Advisor

Re: Scripting question

Michael, just read your comments, i was'nt aware firstly, a while back when I first joined about the points, nor did I realise poeple should become really touchy on the system, or that when the weekend arrives you should be waiting at the computer and neglecting time with the family and friends, just to appease some guy, who has no life and personality. Next time I post I will ensure I neglect my parental responsibilities to appease some aneraked plebs appetite for some points. Which actually you did'nt post any correct answers. Denis, thanks for the correct answer, I gues it was just that awk option I was looking for and not aware of, please have all 10 points and old schoool and Raj for your time and being close.
Michael Steele_2
Honored Contributor

Re: Scripting question

Gee Martin, wouldn't blow your bubble if it became a paid for service instead of the accumulatin of 100's of years of experience all for free?
Support Fatherhood - Stop Family Law
Michael Steele_2
Honored Contributor

Re: Scripting question

Hi

Let me take a different approach since its easy to miss some of these links in your profile. Here is your profile

http://forums11.itrc.hp.com/service/forums/publicProfile.do?forumId=1&userId=CA828944

At the very bottom under the last section titled "My Questions" is a hard to miss link call "unassigned points", every thread where you haven't provided 0 to 10 points still gets flagged. And the only way you can remove these flags is by assigning points.
Support Fatherhood - Stop Family Law