Find the answer to your Linux question:
Results 1 to 3 of 3
hi all mozilla -V the output is Mozilla 1.7.13, Copyright (c) 2003-2004 mozilla.org, build 2006050116 how to truncate this , using bash script. i wanna out put like mozilla-1.7.13 i ...
  1. #1
    Linux Newbie
    Join Date
    Feb 2007
    Location
    hyderabad, india
    Posts
    247

    how to truncate

    hi all
    mozilla -V
    the output is
    Mozilla 1.7.13, Copyright (c) 2003-2004 mozilla.org, build 2006050116
    how to truncate this , using bash script.
    i wanna out put like
    mozilla-1.7.13
    i dont know the above command(mozilla -V) is usefull or not..
    this folder is place in my machine path
    /usr/lib
    i have to get this path using bashscript.
    please help me
    thank you in advance
    "Relationships are built on trust and communication"

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    mozilla -V | sed -e 's/\([^,]*\),.*/\L\1/' -e 's/ /-/'
    Last edited by scm; 07-25-2007 at 06:04 AM. Reason: Forgot to translate the space to a hyphen. :-(

  3. #3
    Linux Newbie
    Join Date
    Feb 2007
    Location
    hyderabad, india
    Posts
    247
    Quote Originally Posted by scm View Post
    mozilla -V | sed -e 's/\([^,]*\),.*/\L\1/' -e 's/ /-/'
    thank you very much.. it is great help
    let me ask one more qury about this please.
    i have to export the ".so" files to other folder..
    i tried like this
    Code:
    #include <gtk/gtk.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    int main()
    {
    
       char buf5[256] = {0};
       char buf6[256] = {0};
      
            FILE *fp1;
            fp1=popen ("rpm -ql mozilla | grep xpcom.so ", "r");
            if (fp1)
            {
             fgets (buf5, sizeof (buf5), fp1);
             buf5[strlen(buf5) - 1] = '\0';
            }//if)FD)
            pclose(fp1);
    
            FILE *fp2;
            fp2=popen ("rpm -ql mozilla | grep moz.so ", "r");
            if (fp2)
            {
             fgets (buf6, sizeof (buf6), fp2);
             buf6[strlen(buf6) - 1] = '\0';
            }//if)FD)
            pclose (fp2);
    
    char *s1;
    char *s2;
    
    s1=g_strconcat("ln -s -f ",buf5," /root/.libs/",NULL);
    s2=g_strconcat("ln -s -f ",buf6," /root/.libs/",NULL);
    
    
       FILE* F;
       F=popen(s1,"r");
       pclose (F);
    
       FILE* F1;
       F1=popen(s2,"r");
       pclose (F1);
    
      return 0;
    }
    it is saved as one.c and compile like
    Code:
    gcc one.c -o one `pkg-config gtk+-2.0 --cflags --libs`
    i used here a little gtk program..

    the output is saving file in my path sucessfully...
    i think you understand my theme of the program.

    i done this...
    but i have convert this whole program to bash script coz , i want single line solution to check mozilla path and check mozilla version and enterd into the full path folder and link those perticulat two ".so" files to my given path( to /root/.libs).

    is it possible..
    please help me

    thank you in advance
    "Relationships are built on trust and communication"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...