Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, In javapath.txt file, I have a line like this, JAVA_PATH=`locate /bin/javac | grep 1.6.0 | awk '{if (NR==1) {print}}' ` echo "$JAVA_PATH" I want to set JAVA_HOME from this ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    3

    how to remove specific pattern from a line using shell script

    Hi,

    In javapath.txt file, I have a line like this,
    JAVA_PATH=`locate /bin/javac | grep 1.6.0 | awk '{if (NR==1) {print}}' `
    echo "$JAVA_PATH"

    I want to set JAVA_HOME from this JAVA_PATH.
    JAVA_PATH is like /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/javac
    I am print this into a file like,
    echo "JAVA_HOME=$JAVA_PATH" > javahome.sh

    For JAVA_HOME, I need to give upto /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64

    How can specifically remove /bin/javac from the file javahome.sh
    please help me on this.

    Thank you,

    Arun

  2. #2
    Just Joined!
    Join Date
    Mar 2007
    Location
    Bogotá, Colombia
    Posts
    39
    Code:
    JAVA_HOME=`echo $JAVA_PATH | sed 's@/bin/javac@@'`
    export JAVA_HOME

Posting Permissions

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