![]() |
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 |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need to serach if a new line character exists on the last line in a file | sunilbm78 | UNIX for Dummies Questions & Answers | 10 | 02-29-2008 02:15 PM |
| serach and replace file name in the path in a remote xml file | kiranreddy1215 | Shell Programming and Scripting | 1 | 11-12-2007 11:31 AM |
| serach file using awk | mohan705 | Shell Programming and Scripting | 3 | 08-28-2007 11:04 AM |
| Case-insensitive serach with awk | acheepi | Shell Programming and Scripting | 4 | 07-15-2005 05:58 PM |
| text serach in unknown file | ted | UNIX for Advanced & Expert Users | 11 | 10-23-2003 03:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Serach and delete
Hi,
This is the format of the file that i have CompanyNumber Run Date: 8/3/2006 6:22:15PM Address: Person: A03120 SP SNNu 100 1 200 2 CompanyNumber Run Date: 8/3/2006 6:22:15PM Address: Person: A03562 SP SNNu 100 1 200 2 i want to delete all the lines between CompanyNumber and Address: and add a new column called as person id to the o/p this is the o/p that i need Person SP SNNu A03120 100 1 A03120 200 2 Person SP SNNu A03562 100 1 A03562 200 2 Thanks kk |
|
||||
|
Another awk try
Code:
sed '/^$/d' inpfilename | awk -f awkfile ; Code:
/Person/ {
i=0;
name=$2
getline; printf("%-10s%10s%10s\n", "Person", $1,$2);
getline
while($1 != "CompanyNumber" || $1 == "" )
{
sp[i]=$1; snnu[i]=$2;
i++;
if(getline == 0) break;
}
for(cnt=0;cnt<i;cnt++)
{
printf("%-10s%10s%10s\n",name,sp[cnt],snnu[cnt]);
}
printf("\n");
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|