[plug] re: awk
Binh Nguyen
linuxfilesystem at yahoo.com.au
Sun Jul 20 20:58:24 WST 2003
Jon Miller wrote:
> I seemed to recall that there is a way to get a listing of files (in
> this case rpms) where one could use (correct me if I'm wrong) awk to
> limit the output to either the filename only or filename and version
> only. However I've looked at man awk and awk --help, and I just do
> not understand how it is used. I would appreciate it if someone
> could send an example with a simple explanation.
>
> Thanks
I must admit that I've been writing a Linux dictionary of late and have come
across this problem. Anyway, rpm -qa --info and then pipe it into the
program below. Please note that this is very roar and that I also have a few
other scripts/programs that are designed to transform it into something much
neater (more suitable for the dictionary). Also, this could be an old/er
version of the program. Could do with some nipping up.
Binh.
>Start Program
/**
* Title: Mr<p>
* Description: Distributed under GPL license.
* <p>
* Copyright: Copyright (c) Binh Nguyen<p>
* Company: <p>
* @author Binh Nguyen
* @version 1.0
*/
import java.io.*;
/* NB - This program is designed to specifically to strip the
* Redhat RPM database.
* To compile using gcj
* gcj --main=redhat redhat.java
* To strip
* ./a.out 'name of file to be stripped' > 'name of stripped file'
*/
public class redhat
{
public static void main (String args[])
throws java.io.FileNotFoundException, java.io.IOException
{
FileReader fr = new FileReader (new File(args[0]));
BufferedReader br = new BufferedReader(fr);
String s;
while ((s=br.readLine())!=null)
{
//Version
if (s.startsWith("Version"))
{
continue;
}
//Release
else if (s.startsWith("Release"))
{
continue;
}
//Install date
else if (s.startsWith("Install date"))
{
continue;
}
//Group
else if (s.startsWith("Group"))
{
continue;
}
//Size
else if (s.startsWith("Size"))
{
continue;
}
//Signature
else if (s.startsWith("Signature"))
{
continue;
}
//Packager
else if (s.startsWith("Packager"))
{
continue;
}
//Summary
else if (s.startsWith("Summary"))
{
continue;
}
//URL
else if (s.startsWith("URL"))
{
continue;
}
//Name
else if (s.startsWith("Name"))
{
System.out.println();
// System.out.println(s);
int temp=0, end=0;
temp=s.indexOf(' ', 15); String d=s.substring(14, temp);
System.out.println("Package: " + d);
continue;
}
else System.out.println(s);
}
return;
}
}
>End Program
More information about the plug
mailing list