The UNIX Forums
"Join the Network of UNIX System Users"


 
feelexit
Newbie
Rank: 1



UID 142
Digest Posts 0
Credits 0
Posts 25
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 02:22 PM  Profile | P.M. 
grep



grep



hi,

i have some files (650) each file has some information like subs number, hardware id1, hardware id2, hardware id3 and 4. how can i get this informations from all files using a script ? i want to write those info to a file. like column1 (subs number) column2 (hwid1)......column4(hwid4)


how can i do this ??

thanks


Top
combat
Newbie
Rank: 1



UID 93
Digest Posts 0
Credits 0
Posts 71
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 02:23 PM  Profile | P.M. 
aliseva3,
please, include all relevant information in your question.
if we do not have a sample of the file, we will not be able
Top
DomainDomain
Newbie
Rank: 1



UID 120
Digest Posts 0
Credits 0
Posts 48
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 02:23 PM  Profile | P.M. 
try the following awk program:

code:
#!/usr/bin/awk -f
# awk file: h.awk

function print_datas() {
   if (member) print member,serials;
}

begin {
   fs = "[=;]";
}

/^member/ {
   print_datas();
   member  = "";
   serials = "";
}

$1=="membernumber" {
   member = $2;
}

$1=="serialn" {
   sub(/^.*-0*/, "", $2);
   sub(/".*$/,   "", $2);
   serials = (serials ? serials ofs : "") $2;
}

end {
   print_datas();
}
input file:

code:
$ cat h.txt
member
membernumber=09700104;
idnumber="";
areac="";
status=0;
global_synchro="2007-06-05 15:13:13";
hw1
hardware{
serialn="011-001-000229";
version=0101;
hw2
hardware{
serialn="011-001-000225";
version=0101;

hw3
hardware{
serialn="011-001-000255";
version=0101;
member
membernumber=09700777;
idnumber="";
areac="";
status=0;
global_synchro="2007-06-05 15:13:13";
hw1
hardware{
serialn="011-001-000123";
version=0101;
hw2
hardware{
serialn="011-001-000456";
version=0101;
$output:

code:
$ awk -f h.awk h.txt
09700104 229 225 255
09700777 123 456
$
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:26 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005495 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP