how to eliminate the unused lines from output

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
-2
down vote

favorite












I am new to scripting I got below output from my script.



OUTPUT:



/opt/soft/was85qa/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/elmd_qa/variables.xml


How to eliminate below lines



/opt/soft/
/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/
/variables.xml


final output should be like below



was85qa & elmd_qa









share|improve this question























  • Please tell us what you're trying to do, and where this paths (?) are coming from ? With the information given, we can provide you with MANY useless non-generic options. Read this.
    – RoVo
    Feb 7 at 16:13











  • Is it always the same that you have to eliminate? Does it depende on the depth of the folders? The name?...
    – M. Becerra
    Feb 7 at 16:14










  • its always the same I need to eliminate
    – mrr
    Feb 7 at 16:15










  • @RoVo I am extracting the output from one of my file
    – mrr
    Feb 7 at 16:16














up vote
-2
down vote

favorite












I am new to scripting I got below output from my script.



OUTPUT:



/opt/soft/was85qa/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/elmd_qa/variables.xml


How to eliminate below lines



/opt/soft/
/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/
/variables.xml


final output should be like below



was85qa & elmd_qa









share|improve this question























  • Please tell us what you're trying to do, and where this paths (?) are coming from ? With the information given, we can provide you with MANY useless non-generic options. Read this.
    – RoVo
    Feb 7 at 16:13











  • Is it always the same that you have to eliminate? Does it depende on the depth of the folders? The name?...
    – M. Becerra
    Feb 7 at 16:14










  • its always the same I need to eliminate
    – mrr
    Feb 7 at 16:15










  • @RoVo I am extracting the output from one of my file
    – mrr
    Feb 7 at 16:16












up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I am new to scripting I got below output from my script.



OUTPUT:



/opt/soft/was85qa/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/elmd_qa/variables.xml


How to eliminate below lines



/opt/soft/
/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/
/variables.xml


final output should be like below



was85qa & elmd_qa









share|improve this question















I am new to scripting I got below output from my script.



OUTPUT:



/opt/soft/was85qa/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/elmd_qa/variables.xml


How to eliminate below lines



/opt/soft/
/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/
/variables.xml


final output should be like below



was85qa & elmd_qa






command-line scripts text-processing playonlinux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 7 at 16:13

























asked Feb 7 at 16:08









mrr

12




12











  • Please tell us what you're trying to do, and where this paths (?) are coming from ? With the information given, we can provide you with MANY useless non-generic options. Read this.
    – RoVo
    Feb 7 at 16:13











  • Is it always the same that you have to eliminate? Does it depende on the depth of the folders? The name?...
    – M. Becerra
    Feb 7 at 16:14










  • its always the same I need to eliminate
    – mrr
    Feb 7 at 16:15










  • @RoVo I am extracting the output from one of my file
    – mrr
    Feb 7 at 16:16
















  • Please tell us what you're trying to do, and where this paths (?) are coming from ? With the information given, we can provide you with MANY useless non-generic options. Read this.
    – RoVo
    Feb 7 at 16:13











  • Is it always the same that you have to eliminate? Does it depende on the depth of the folders? The name?...
    – M. Becerra
    Feb 7 at 16:14










  • its always the same I need to eliminate
    – mrr
    Feb 7 at 16:15










  • @RoVo I am extracting the output from one of my file
    – mrr
    Feb 7 at 16:16















Please tell us what you're trying to do, and where this paths (?) are coming from ? With the information given, we can provide you with MANY useless non-generic options. Read this.
– RoVo
Feb 7 at 16:13





Please tell us what you're trying to do, and where this paths (?) are coming from ? With the information given, we can provide you with MANY useless non-generic options. Read this.
– RoVo
Feb 7 at 16:13













Is it always the same that you have to eliminate? Does it depende on the depth of the folders? The name?...
– M. Becerra
Feb 7 at 16:14




Is it always the same that you have to eliminate? Does it depende on the depth of the folders? The name?...
– M. Becerra
Feb 7 at 16:14












its always the same I need to eliminate
– mrr
Feb 7 at 16:15




its always the same I need to eliminate
– mrr
Feb 7 at 16:15












@RoVo I am extracting the output from one of my file
– mrr
Feb 7 at 16:16




@RoVo I am extracting the output from one of my file
– mrr
Feb 7 at 16:16










1 Answer
1






active

oldest

votes

















up vote
1
down vote













If the text is always the same, you can just use sed search and replace function and hard-code what needs to be excluded:



echo $OUTPUT | sed -r 's#/opt/soft/([^/]*)/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/([^/]*)/variables.xml#1 & 2#'


You could also use cut, because if it's always the same, the strings you're looking for are always on the same position (--> 4 and 11).



echo $OUTPUT | cut -d'/' -f 4,11 --output-delimiter=" & "


Instead of echo $OUTPUT you can add the part beginning with the pipe (|) directly behind your command to run the script.






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1003935%2fhow-to-eliminate-the-unused-lines-from-output%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    If the text is always the same, you can just use sed search and replace function and hard-code what needs to be excluded:



    echo $OUTPUT | sed -r 's#/opt/soft/([^/]*)/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/([^/]*)/variables.xml#1 & 2#'


    You could also use cut, because if it's always the same, the strings you're looking for are always on the same position (--> 4 and 11).



    echo $OUTPUT | cut -d'/' -f 4,11 --output-delimiter=" & "


    Instead of echo $OUTPUT you can add the part beginning with the pipe (|) directly behind your command to run the script.






    share|improve this answer


























      up vote
      1
      down vote













      If the text is always the same, you can just use sed search and replace function and hard-code what needs to be excluded:



      echo $OUTPUT | sed -r 's#/opt/soft/([^/]*)/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/([^/]*)/variables.xml#1 & 2#'


      You could also use cut, because if it's always the same, the strings you're looking for are always on the same position (--> 4 and 11).



      echo $OUTPUT | cut -d'/' -f 4,11 --output-delimiter=" & "


      Instead of echo $OUTPUT you can add the part beginning with the pipe (|) directly behind your command to run the script.






      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        If the text is always the same, you can just use sed search and replace function and hard-code what needs to be excluded:



        echo $OUTPUT | sed -r 's#/opt/soft/([^/]*)/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/([^/]*)/variables.xml#1 & 2#'


        You could also use cut, because if it's always the same, the strings you're looking for are always on the same position (--> 4 and 11).



        echo $OUTPUT | cut -d'/' -f 4,11 --output-delimiter=" & "


        Instead of echo $OUTPUT you can add the part beginning with the pipe (|) directly behind your command to run the script.






        share|improve this answer














        If the text is always the same, you can just use sed search and replace function and hard-code what needs to be excluded:



        echo $OUTPUT | sed -r 's#/opt/soft/([^/]*)/WebSphere/gct8apps_qa_node/config/cells/gct8apps_qa_cell/clusters/([^/]*)/variables.xml#1 & 2#'


        You could also use cut, because if it's always the same, the strings you're looking for are always on the same position (--> 4 and 11).



        echo $OUTPUT | cut -d'/' -f 4,11 --output-delimiter=" & "


        Instead of echo $OUTPUT you can add the part beginning with the pipe (|) directly behind your command to run the script.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 7 at 16:31

























        answered Feb 7 at 16:24









        RoVo

        5,8091338




        5,8091338



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1003935%2fhow-to-eliminate-the-unused-lines-from-output%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491