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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
VNC copy paste problem param_it Windows & DOS: Issues & Discussions 2 1 Week Ago 05:02 AM
copy and paste a specific line tiger99 Shell Programming and Scripting 7 02-24-2008 08:43 AM
cut, copy + paste aitor314 UNIX for Dummies Questions & Answers 2 02-06-2006 02:17 AM
copy and paste from MS Windows to Unix Loaded Gun UNIX for Dummies Questions & Answers 9 06-02-2003 02:12 AM
Cut, Copy and Paste with X auswipe UNIX Desktop for Dummies Questions & Answers 4 03-27-2002 01:27 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #15  
Old 05-16-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Code:
sed '/host=atlx3  *sid=atld3 mail=/{;h;s/mail=.*/mail=DISABLE/p;x;s/^/#/;}' abc.txt
There are two spaces and an asterisk between host and sid now. space asterisk means zero or more spaces, so makes multiple spaces optional.
Reply With Quote
Forum Sponsor
  #16  
Old 10-01-2008
Registered User
 

Join Date: Oct 2008
Posts: 5
Thumbs up Grep Words,Cut and the prepare a string

AU Main Date: 08-SEP-08 10:27:11
Profit and Loss Long Report Page: 1
Current Period: AUG-08

Personal Unit=AU003 (Industrial Products Division),Plant=B00089,Departmant=D110
Ptd-Actual Ptd-Budget Ptd-Variance YTD-Actual YTD-Budget YTD-Variance
Account Le BU Pl De In Fu
------------------------------ -- -- -- -- -- -- ------------ ------------ ------------ -------------- ------------- ------------
Operating Distribution 0.00 0.00 0.00 -30,808,210.75 0.00 30808210.75

Cost of Sales/OPNS 180,689.57 0.00 -180,689.57 173818430.54 0.00 -173818430.54

GROSS PROFIT 180,689.57 0.00 -180,689.57 -118521808.49 0.00 118521808.49

Marketing Distrib 0.00 0.00 0.00 0.00 0.00 0.00

Personal Unit=AU004 (Industrial Products Division),Plant=B01189,Departmant=D111


Ptd-Actual Ptd-Budget Ptd-Variance YTD-Actual YTD-Budget YTD-Variance
Account Le BU Pl De In Fu
------------------------------ -- -- -- -- -- -- ------------ ------------ ------------ -------------- ------------- ------------
Operating Distribution 0.00 0.00 0.00 -30,808,210.75 0.00 30808210.75

Cost of Sales/OPNS 180,689.57 0.00 -180,689.57 173818430.54 0.00 -173818430.54

GROSS PROFIT 180,689.57 0.00 -180,689.57 -118521808.49 0.00 118521808.49

Marketing Distrib 0.00 0.00 0.00 0.00 0.00 0.00





I need oput where ever i find Personal unit just capture that line and copy that line to make it like


Personal Unit=AU003
Plant=B00089
Departmant=D110
-->RAM:AU003:B00089110:08-SEP-08:US Primary


I am using

sed -e '/Personal Unit/{;h;s/^/#/p;x;}' -e '/Business Unit/{s/,Plant/\nPlant/g' -e 's/,Departmant/\nDepartmant/g'} filename

But this is not fulfilling my requirement
Any one please help me on this
Reply With Quote
  #17  
Old 10-02-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,292
Quote:
Originally Posted by krishna.fuji View Post
AU Main Date: 08-SEP-08 10:27:11
Profit and Loss Long Report Page: 1
Current Period: AUG-08

Personal Unit=AU003 (Industrial Products Division),Plant=B00089,Departmant=D110
Ptd-Actual Ptd-Budget Ptd-Variance YTD-Actual YTD-Budget YTD-Variance
Account Le BU Pl De In Fu
------------------------------ -- -- -- -- -- -- ------------ ------------ ------------ -------------- ------------- ------------
Operating Distribution 0.00 0.00 0.00 -30,808,210.75 0.00 30808210.75

Cost of Sales/OPNS 180,689.57 0.00 -180,689.57 173818430.54 0.00 -173818430.54

GROSS PROFIT 180,689.57 0.00 -180,689.57 -118521808.49 0.00 118521808.49

Marketing Distrib 0.00 0.00 0.00 0.00 0.00 0.00

Personal Unit=AU004 (Industrial Products Division),Plant=B01189,Departmant=D111


Ptd-Actual Ptd-Budget Ptd-Variance YTD-Actual YTD-Budget YTD-Variance
Account Le BU Pl De In Fu
------------------------------ -- -- -- -- -- -- ------------ ------------ ------------ -------------- ------------- ------------
Operating Distribution 0.00 0.00 0.00 -30,808,210.75 0.00 30808210.75

Cost of Sales/OPNS 180,689.57 0.00 -180,689.57 173818430.54 0.00 -173818430.54

GROSS PROFIT 180,689.57 0.00 -180,689.57 -118521808.49 0.00 118521808.49

Marketing Distrib 0.00 0.00 0.00 0.00 0.00 0.00





I need oput where ever i find Personal unit just capture that line and copy that line to make it like


Personal Unit=AU003
Plant=B00089
Departmant=D110
-->RAM:AU003:B00089110:08-SEP-08:US Primary


I am using

sed -e '/Personal Unit/{;h;s/^/#/p;x;}' -e '/Business Unit/{s/,Plant/\nPlant/g' -e 's/,Departmant/\nDepartmant/g'} filename

But this is not fulfilling my requirement
Any one please help me on this
This is a duplicate of this post:

Grep, then format then prepare a string

No duplicate or cross-posting, please read the:

Simple rules of the UNIX.COM forums:.

Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0