![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| grep using date format | ali560045 | Shell Programming and Scripting | 4 | 12-26-2007 08:59 AM |
| grep using date format | ali560045 | Shell Programming and Scripting | 8 | 12-11-2007 06:39 PM |
| how i prepare a c++ code(c code) for implementing my own protocol format | amitpansuria | High Level Programming | 1 | 09-06-2007 11:09 PM |
| how to format a grep command | jasongr | Shell Programming and Scripting | 2 | 11-18-2005 02:07 PM |
| How to format number/string in ksh | GNMIKE | Shell Programming and Scripting | 2 | 07-03-2005 03:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi
I have a file which is having line like below Personal Unit=AU003 (Industrial Products Division),Plant=B00089,Departmant=D110 When ever i fine line starting sith Personal Unit and contains Plant Department I need to pick this line and format it like Personal Unit=AU003 Plant=B00089 Departmant=D110 -->RAM:AU003:B00089 110:system date:header of the filei used sed sed -e '/Personal Unit/{;h;s/^/#/p;x;}' -e '/Business Unit/{s/,Plant/\nPlant/g' -e 's/,Departmant/\nDepartmant/g'} FileName But it is not fullfilling my all need can any one please suggest |
|
||||
|
its not the exact output what we expected
Quote:
Hi I have multiple lines in this script. As soon as it fine the sentence immediatly it has to return the given out put. more over the below mentioned extra line it is not giving. I shall be very thankful if do so |
|
||||
|
Quote:
[krishna@newtrans-test ~]$ cat ram1 Personal Unit=US003 (Industrial Products Division),Plant=B00089,Departmant=D110 This is my own Personal Unit=US003 (Industrial/Products Division),Plant=B00089,Departmant=D110 We need to makfmkldfd Personal Unit=US004 (Consumer Products Div)Plant=B00089,Departmant=D1119 mdkmvckldmldm This is for some idea when junk of data in file Personal Unit=US004 (Consumer Products Div),Plant=B00078,Departmant=D111 Personal Unit=US006 (Machinery Mfg Division),Plant=B00089,Departmant=D1188 Personal Unit=US007 (Adhesives Division) ,Plant=B00089,Departmant=D110 Personal Unit=US009 (Adhesives Division) Personal Unit=US010 (Adhesives Division) [krishna@newtrans-test ~]$ sed -e '/Personal Unit/{;h;s/^/#/p;x;}' -e '/Personal Unit/{s/,Plant/\nPlant/g' -e 's/,Departmant/\nDepartmant/g'} ram1 # Personal Unit=US003 (Industrial Products Division),Plant=B00089,Departmant=D110 Personal Unit=US003 (Industrial Products Division) Plant=B00089 Departmant=D110 This is my own # Personal Unit=US003 (Industrial/Products Division),Plant=B00089,Departmant=D110 Personal Unit=US003 (Industrial/Products Division) Plant=B00089 Departmant=D110 We need to makfmkldfd # Personal Unit=US004 (Consumer Products Div)Plant=B00089,Departmant=D1119 Personal Unit=US004 (Consumer Products Div)Plant=B00089 Departmant=D1119 mdkmvckldmldm This is for some idea when junk of data in file # Personal Unit=US004 (Consumer Products Div),Plant=B00078,Departmant=D111 Personal Unit=US004 (Consumer Products Div) Plant=B00078 Departmant=D111 # Personal Unit=US006 (Machinery Mfg Division),Plant=B00089,Departmant=D1188 Personal Unit=US006 (Machinery Mfg Division) Plant=B00089 Departmant=D1188 # Personal Unit=US007 (Adhesives Division) ,Plant=B00089,Departmant=D110 Personal Unit=US007 (Adhesives Division) Plant=B00089 Departmant=D110 # Personal Unit=US009 (Adhesives Division) Personal Unit=US009 (Adhesives Division) # Personal Unit=US010 (Adhesives Division) Personal Unit=US010 (Adhesives Division) [krishna@newtrans-test ~]$ Along with this where ever i am splitting that row i need to get the combination of values Like --> RAM:US007:B00089 110:systendate:fileheaderConclusion is wherever i find Personal Unit=US007 (Adhesives Division) ,Plant=B00089,Departmant=D110 immediatly next line must be Personal Unit=US007 (Adhesives Division) ,Plant=B00089,Departmant=D110 Personal Unit=US007 (Adhesives Division) Plant=B00089 Departmant=D110 --> RAM:US007:B00089 110:systendate:fileheaderand important is this script should touch only the line which are having combination of Personal Unit,Plant,Department in a single line IF you can do this for me thanks alot Last edited by krishna.fuji; 10-03-2008 at 02:29 AM.. |
|
||||
|
Quote:
Code:
awk -F, '{if(/Personal Unit/&&/Plant/&&/Departmant/){printf "# %s\n%s\n%s\n%s\n",$0,$1,$2,$3}else{print}}' file
|
![]() |
| Bookmarks |
| Tags |
| linux commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|