how to print the matching value from same line, which has multiple Delimiter?

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











up vote
1
down vote

favorite












I have a File under Linux /tmp/volume.log and the content is:



[id:1091666, name:root, deviceName:/dev/sda, maxStorage:107374182400, unitNumber:0, displayOrder:0, rootVolume:true],[id:1091851, name:/var/log/devops|40GB;/home/devops|150GB, deviceName:/dev/sdb, maxStorage:289910292480, unitNumber:1, displayOrder:1, rootVolume:false]],


It will be in single line. This file is generated by some other script.



My Aim is to find the non-root volume disk and parse it to LVM Commands as Variable to extend or create new volumes, at the time of OS Build.



In the above Example.



There are two disks,
1 - sda which is root disk, (if rootVolume is true it is root disk)
2 - sdb which is non root disk (if rootVolume is false it is non root disk)



I have to grep only




rootVolume=false




and grep then




deviceName:/dev/sdb




followed by:




name:/var/log/devops|40GB;/home/devops|150GB




Once I parse all the above in to Variables, I can call those variables in the Commands like



#!/bin/bash
Disk_name=/dev/sdb
Size_Value=40G
LV_name=var_log_devops
Mount_Point=/var/log/devops

sudo pvcreate $Disk_name
sudo vgcreate vgrp01 $Disk_name

sudo lvcreate -L $Size_Value -n $var_log_devops vgrp01
sudo mkfs.xfs $var_log_devops
sudo mkdir -p $/var/log/devops
sudo mount $var_log_devops $/var/log/devops


Right now I am struck with, Extracting the Values from the Text file, becasue they are in single line and multiple Delimiters are present.










share|improve this question



























    up vote
    1
    down vote

    favorite












    I have a File under Linux /tmp/volume.log and the content is:



    [id:1091666, name:root, deviceName:/dev/sda, maxStorage:107374182400, unitNumber:0, displayOrder:0, rootVolume:true],[id:1091851, name:/var/log/devops|40GB;/home/devops|150GB, deviceName:/dev/sdb, maxStorage:289910292480, unitNumber:1, displayOrder:1, rootVolume:false]],


    It will be in single line. This file is generated by some other script.



    My Aim is to find the non-root volume disk and parse it to LVM Commands as Variable to extend or create new volumes, at the time of OS Build.



    In the above Example.



    There are two disks,
    1 - sda which is root disk, (if rootVolume is true it is root disk)
    2 - sdb which is non root disk (if rootVolume is false it is non root disk)



    I have to grep only




    rootVolume=false




    and grep then




    deviceName:/dev/sdb




    followed by:




    name:/var/log/devops|40GB;/home/devops|150GB




    Once I parse all the above in to Variables, I can call those variables in the Commands like



    #!/bin/bash
    Disk_name=/dev/sdb
    Size_Value=40G
    LV_name=var_log_devops
    Mount_Point=/var/log/devops

    sudo pvcreate $Disk_name
    sudo vgcreate vgrp01 $Disk_name

    sudo lvcreate -L $Size_Value -n $var_log_devops vgrp01
    sudo mkfs.xfs $var_log_devops
    sudo mkdir -p $/var/log/devops
    sudo mount $var_log_devops $/var/log/devops


    Right now I am struck with, Extracting the Values from the Text file, becasue they are in single line and multiple Delimiters are present.










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a File under Linux /tmp/volume.log and the content is:



      [id:1091666, name:root, deviceName:/dev/sda, maxStorage:107374182400, unitNumber:0, displayOrder:0, rootVolume:true],[id:1091851, name:/var/log/devops|40GB;/home/devops|150GB, deviceName:/dev/sdb, maxStorage:289910292480, unitNumber:1, displayOrder:1, rootVolume:false]],


      It will be in single line. This file is generated by some other script.



      My Aim is to find the non-root volume disk and parse it to LVM Commands as Variable to extend or create new volumes, at the time of OS Build.



      In the above Example.



      There are two disks,
      1 - sda which is root disk, (if rootVolume is true it is root disk)
      2 - sdb which is non root disk (if rootVolume is false it is non root disk)



      I have to grep only




      rootVolume=false




      and grep then




      deviceName:/dev/sdb




      followed by:




      name:/var/log/devops|40GB;/home/devops|150GB




      Once I parse all the above in to Variables, I can call those variables in the Commands like



      #!/bin/bash
      Disk_name=/dev/sdb
      Size_Value=40G
      LV_name=var_log_devops
      Mount_Point=/var/log/devops

      sudo pvcreate $Disk_name
      sudo vgcreate vgrp01 $Disk_name

      sudo lvcreate -L $Size_Value -n $var_log_devops vgrp01
      sudo mkfs.xfs $var_log_devops
      sudo mkdir -p $/var/log/devops
      sudo mount $var_log_devops $/var/log/devops


      Right now I am struck with, Extracting the Values from the Text file, becasue they are in single line and multiple Delimiters are present.










      share|improve this question















      I have a File under Linux /tmp/volume.log and the content is:



      [id:1091666, name:root, deviceName:/dev/sda, maxStorage:107374182400, unitNumber:0, displayOrder:0, rootVolume:true],[id:1091851, name:/var/log/devops|40GB;/home/devops|150GB, deviceName:/dev/sdb, maxStorage:289910292480, unitNumber:1, displayOrder:1, rootVolume:false]],


      It will be in single line. This file is generated by some other script.



      My Aim is to find the non-root volume disk and parse it to LVM Commands as Variable to extend or create new volumes, at the time of OS Build.



      In the above Example.



      There are two disks,
      1 - sda which is root disk, (if rootVolume is true it is root disk)
      2 - sdb which is non root disk (if rootVolume is false it is non root disk)



      I have to grep only




      rootVolume=false




      and grep then




      deviceName:/dev/sdb




      followed by:




      name:/var/log/devops|40GB;/home/devops|150GB




      Once I parse all the above in to Variables, I can call those variables in the Commands like



      #!/bin/bash
      Disk_name=/dev/sdb
      Size_Value=40G
      LV_name=var_log_devops
      Mount_Point=/var/log/devops

      sudo pvcreate $Disk_name
      sudo vgcreate vgrp01 $Disk_name

      sudo lvcreate -L $Size_Value -n $var_log_devops vgrp01
      sudo mkfs.xfs $var_log_devops
      sudo mkdir -p $/var/log/devops
      sudo mount $var_log_devops $/var/log/devops


      Right now I am struck with, Extracting the Values from the Text file, becasue they are in single line and multiple Delimiters are present.







      shell-script text-processing awk sed perl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 1 at 11:28









      Jeff Schaller

      33.6k851113




      33.6k851113










      asked Oct 1 at 11:15









      user3179298

      134




      134




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          How far would this get you:



          awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file
          name:/var/log/devops|40GB;/home/devops|150GB,
          deviceName:/dev/sdb,


          It splits the single line at ], then scans through all fields to find the target ones, and prints them. You could read the result into shell variables like so, then:



          read VARA VARB REST <<< $(awk -vRS="],*" -vORS=" " '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file)
          echo $VARA
          name:/var/log/devops|40GB;/home/devops|150GB,
          echo $VARB
          deviceName:/dev/sdb,





          share|improve this answer




















          • Hey, this is near perfect. How can i get only the below details ? example : #awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' /tmp/a | grep deviceName: deviceName:/dev/sdb, I would like to have only /dev/sdb and make that as variable.
            – user3179298
            Oct 1 at 12:59











          • With bash's "process substitution", you could try like . <(awk -vRS="],*" '/rootVolume:false/ deviceName/) sub (/:/, "="", $i); sub (/,$/,""", $i); print $i' file) to define the "name" and "deviceName" variables. Watch the leading dot (for "source")!
            – RudiC
            Oct 1 at 13:27


















          up vote
          4
          down vote













          You can use the command cut something like:



          cat /tmp/volume.log | cut -d, -f14 | tr -d "]["
          rootVolume=false

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | cut -d, -f14 | tr -d "][")

          cat /tmp/volume.log | cut -d, -f3
          deviceName:/dev/sda

          cat /tmp/volume.log | cut -d, -f9
          name:/var/log/devops|40GB;/home/devops|150GB


          Or with grep



          cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,"

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,")

          cat /tmp/volume.log | grep -o "deviceName:/dev/sda"

          cat /tmp/volume.log | grep -o "name:/var/log/devops|40GB;/home/devops|150GB" | tr -d "n"


          -o, --only-matching
          Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.



          Use tr after grep to remove , ....etc from your output.






          share|improve this answer






















          • I gave you an example of the text file, but in real we might have more disk's. So I have to grep only the rootvolume=false and once the match is found. Then I need to get the false boot disk name. Then the other partition.
            – user3179298
            Oct 1 at 11:34










          • Hi @user3179298. You can change -f14 to match the information you want in the file. Does this make sense?
            – Goro
            Oct 1 at 11:35











          • Hello Gora, the Field will change server to server. Some times the field 14 will have root volume disk.
            – user3179298
            Oct 1 at 12:05










          • No worries, I will tweak it for you. I thought you have standard files as provided in your example!
            – Goro
            Oct 1 at 12:06











          • I have a logic, but not sure how to get that done. i see every disk are start and end with [ ..... ],[.....],[.....] So, i need to grep for root volume=false, then need to take that [......rootvolume=false ] as variable and use sed or cut to get the disk and other volume information's. then i will parse it to the script for LVM creation. But not sure how to :(
            – user3179298
            Oct 1 at 12:10










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f472553%2fhow-to-print-the-matching-value-from-same-line-which-has-multiple-delimiter%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          How far would this get you:



          awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file
          name:/var/log/devops|40GB;/home/devops|150GB,
          deviceName:/dev/sdb,


          It splits the single line at ], then scans through all fields to find the target ones, and prints them. You could read the result into shell variables like so, then:



          read VARA VARB REST <<< $(awk -vRS="],*" -vORS=" " '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file)
          echo $VARA
          name:/var/log/devops|40GB;/home/devops|150GB,
          echo $VARB
          deviceName:/dev/sdb,





          share|improve this answer




















          • Hey, this is near perfect. How can i get only the below details ? example : #awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' /tmp/a | grep deviceName: deviceName:/dev/sdb, I would like to have only /dev/sdb and make that as variable.
            – user3179298
            Oct 1 at 12:59











          • With bash's "process substitution", you could try like . <(awk -vRS="],*" '/rootVolume:false/ deviceName/) sub (/:/, "="", $i); sub (/,$/,""", $i); print $i' file) to define the "name" and "deviceName" variables. Watch the leading dot (for "source")!
            – RudiC
            Oct 1 at 13:27















          up vote
          0
          down vote



          accepted










          How far would this get you:



          awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file
          name:/var/log/devops|40GB;/home/devops|150GB,
          deviceName:/dev/sdb,


          It splits the single line at ], then scans through all fields to find the target ones, and prints them. You could read the result into shell variables like so, then:



          read VARA VARB REST <<< $(awk -vRS="],*" -vORS=" " '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file)
          echo $VARA
          name:/var/log/devops|40GB;/home/devops|150GB,
          echo $VARB
          deviceName:/dev/sdb,





          share|improve this answer




















          • Hey, this is near perfect. How can i get only the below details ? example : #awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' /tmp/a | grep deviceName: deviceName:/dev/sdb, I would like to have only /dev/sdb and make that as variable.
            – user3179298
            Oct 1 at 12:59











          • With bash's "process substitution", you could try like . <(awk -vRS="],*" '/rootVolume:false/ deviceName/) sub (/:/, "="", $i); sub (/,$/,""", $i); print $i' file) to define the "name" and "deviceName" variables. Watch the leading dot (for "source")!
            – RudiC
            Oct 1 at 13:27













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          How far would this get you:



          awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file
          name:/var/log/devops|40GB;/home/devops|150GB,
          deviceName:/dev/sdb,


          It splits the single line at ], then scans through all fields to find the target ones, and prints them. You could read the result into shell variables like so, then:



          read VARA VARB REST <<< $(awk -vRS="],*" -vORS=" " '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file)
          echo $VARA
          name:/var/log/devops|40GB;/home/devops|150GB,
          echo $VARB
          deviceName:/dev/sdb,





          share|improve this answer












          How far would this get you:



          awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file
          name:/var/log/devops|40GB;/home/devops|150GB,
          deviceName:/dev/sdb,


          It splits the single line at ], then scans through all fields to find the target ones, and prints them. You could read the result into shell variables like so, then:



          read VARA VARB REST <<< $(awk -vRS="],*" -vORS=" " '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' file)
          echo $VARA
          name:/var/log/devops|40GB;/home/devops|150GB,
          echo $VARB
          deviceName:/dev/sdb,






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 1 at 12:09









          RudiC

          1,8429




          1,8429











          • Hey, this is near perfect. How can i get only the below details ? example : #awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' /tmp/a | grep deviceName: deviceName:/dev/sdb, I would like to have only /dev/sdb and make that as variable.
            – user3179298
            Oct 1 at 12:59











          • With bash's "process substitution", you could try like . <(awk -vRS="],*" '/rootVolume:false/ deviceName/) sub (/:/, "="", $i); sub (/,$/,""", $i); print $i' file) to define the "name" and "deviceName" variables. Watch the leading dot (for "source")!
            – RudiC
            Oct 1 at 13:27

















          • Hey, this is near perfect. How can i get only the below details ? example : #awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' /tmp/a | grep deviceName: deviceName:/dev/sdb, I would like to have only /dev/sdb and make that as variable.
            – user3179298
            Oct 1 at 12:59











          • With bash's "process substitution", you could try like . <(awk -vRS="],*" '/rootVolume:false/ deviceName/) sub (/:/, "="", $i); sub (/,$/,""", $i); print $i' file) to define the "name" and "deviceName" variables. Watch the leading dot (for "source")!
            – RudiC
            Oct 1 at 13:27
















          Hey, this is near perfect. How can i get only the below details ? example : #awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' /tmp/a | grep deviceName: deviceName:/dev/sdb, I would like to have only /dev/sdb and make that as variable.
          – user3179298
          Oct 1 at 12:59





          Hey, this is near perfect. How can i get only the below details ? example : #awk -vRS="]" '/rootVolume:false/ for (i=1; i<=NF; i++) if ($i ~ /name' /tmp/a | grep deviceName: deviceName:/dev/sdb, I would like to have only /dev/sdb and make that as variable.
          – user3179298
          Oct 1 at 12:59













          With bash's "process substitution", you could try like . <(awk -vRS="],*" '/rootVolume:false/ deviceName/) sub (/:/, "="", $i); sub (/,$/,""", $i); print $i' file) to define the "name" and "deviceName" variables. Watch the leading dot (for "source")!
          – RudiC
          Oct 1 at 13:27





          With bash's "process substitution", you could try like . <(awk -vRS="],*" '/rootVolume:false/ deviceName/) sub (/:/, "="", $i); sub (/,$/,""", $i); print $i' file) to define the "name" and "deviceName" variables. Watch the leading dot (for "source")!
          – RudiC
          Oct 1 at 13:27













          up vote
          4
          down vote













          You can use the command cut something like:



          cat /tmp/volume.log | cut -d, -f14 | tr -d "]["
          rootVolume=false

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | cut -d, -f14 | tr -d "][")

          cat /tmp/volume.log | cut -d, -f3
          deviceName:/dev/sda

          cat /tmp/volume.log | cut -d, -f9
          name:/var/log/devops|40GB;/home/devops|150GB


          Or with grep



          cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,"

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,")

          cat /tmp/volume.log | grep -o "deviceName:/dev/sda"

          cat /tmp/volume.log | grep -o "name:/var/log/devops|40GB;/home/devops|150GB" | tr -d "n"


          -o, --only-matching
          Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.



          Use tr after grep to remove , ....etc from your output.






          share|improve this answer






















          • I gave you an example of the text file, but in real we might have more disk's. So I have to grep only the rootvolume=false and once the match is found. Then I need to get the false boot disk name. Then the other partition.
            – user3179298
            Oct 1 at 11:34










          • Hi @user3179298. You can change -f14 to match the information you want in the file. Does this make sense?
            – Goro
            Oct 1 at 11:35











          • Hello Gora, the Field will change server to server. Some times the field 14 will have root volume disk.
            – user3179298
            Oct 1 at 12:05










          • No worries, I will tweak it for you. I thought you have standard files as provided in your example!
            – Goro
            Oct 1 at 12:06











          • I have a logic, but not sure how to get that done. i see every disk are start and end with [ ..... ],[.....],[.....] So, i need to grep for root volume=false, then need to take that [......rootvolume=false ] as variable and use sed or cut to get the disk and other volume information's. then i will parse it to the script for LVM creation. But not sure how to :(
            – user3179298
            Oct 1 at 12:10














          up vote
          4
          down vote













          You can use the command cut something like:



          cat /tmp/volume.log | cut -d, -f14 | tr -d "]["
          rootVolume=false

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | cut -d, -f14 | tr -d "][")

          cat /tmp/volume.log | cut -d, -f3
          deviceName:/dev/sda

          cat /tmp/volume.log | cut -d, -f9
          name:/var/log/devops|40GB;/home/devops|150GB


          Or with grep



          cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,"

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,")

          cat /tmp/volume.log | grep -o "deviceName:/dev/sda"

          cat /tmp/volume.log | grep -o "name:/var/log/devops|40GB;/home/devops|150GB" | tr -d "n"


          -o, --only-matching
          Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.



          Use tr after grep to remove , ....etc from your output.






          share|improve this answer






















          • I gave you an example of the text file, but in real we might have more disk's. So I have to grep only the rootvolume=false and once the match is found. Then I need to get the false boot disk name. Then the other partition.
            – user3179298
            Oct 1 at 11:34










          • Hi @user3179298. You can change -f14 to match the information you want in the file. Does this make sense?
            – Goro
            Oct 1 at 11:35











          • Hello Gora, the Field will change server to server. Some times the field 14 will have root volume disk.
            – user3179298
            Oct 1 at 12:05










          • No worries, I will tweak it for you. I thought you have standard files as provided in your example!
            – Goro
            Oct 1 at 12:06











          • I have a logic, but not sure how to get that done. i see every disk are start and end with [ ..... ],[.....],[.....] So, i need to grep for root volume=false, then need to take that [......rootvolume=false ] as variable and use sed or cut to get the disk and other volume information's. then i will parse it to the script for LVM creation. But not sure how to :(
            – user3179298
            Oct 1 at 12:10












          up vote
          4
          down vote










          up vote
          4
          down vote









          You can use the command cut something like:



          cat /tmp/volume.log | cut -d, -f14 | tr -d "]["
          rootVolume=false

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | cut -d, -f14 | tr -d "][")

          cat /tmp/volume.log | cut -d, -f3
          deviceName:/dev/sda

          cat /tmp/volume.log | cut -d, -f9
          name:/var/log/devops|40GB;/home/devops|150GB


          Or with grep



          cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,"

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,")

          cat /tmp/volume.log | grep -o "deviceName:/dev/sda"

          cat /tmp/volume.log | grep -o "name:/var/log/devops|40GB;/home/devops|150GB" | tr -d "n"


          -o, --only-matching
          Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.



          Use tr after grep to remove , ....etc from your output.






          share|improve this answer














          You can use the command cut something like:



          cat /tmp/volume.log | cut -d, -f14 | tr -d "]["
          rootVolume=false

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | cut -d, -f14 | tr -d "][")

          cat /tmp/volume.log | cut -d, -f3
          deviceName:/dev/sda

          cat /tmp/volume.log | cut -d, -f9
          name:/var/log/devops|40GB;/home/devops|150GB


          Or with grep



          cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,"

          make it a variable:
          rootvolume=$(cat /tmp/volume.log | grep -o "rootVolume:false]]," | tr "][,")

          cat /tmp/volume.log | grep -o "deviceName:/dev/sda"

          cat /tmp/volume.log | grep -o "name:/var/log/devops|40GB;/home/devops|150GB" | tr -d "n"


          -o, --only-matching
          Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.



          Use tr after grep to remove , ....etc from your output.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 1 at 12:41

























          answered Oct 1 at 11:29









          Goro

          7,02252965




          7,02252965











          • I gave you an example of the text file, but in real we might have more disk's. So I have to grep only the rootvolume=false and once the match is found. Then I need to get the false boot disk name. Then the other partition.
            – user3179298
            Oct 1 at 11:34










          • Hi @user3179298. You can change -f14 to match the information you want in the file. Does this make sense?
            – Goro
            Oct 1 at 11:35











          • Hello Gora, the Field will change server to server. Some times the field 14 will have root volume disk.
            – user3179298
            Oct 1 at 12:05










          • No worries, I will tweak it for you. I thought you have standard files as provided in your example!
            – Goro
            Oct 1 at 12:06











          • I have a logic, but not sure how to get that done. i see every disk are start and end with [ ..... ],[.....],[.....] So, i need to grep for root volume=false, then need to take that [......rootvolume=false ] as variable and use sed or cut to get the disk and other volume information's. then i will parse it to the script for LVM creation. But not sure how to :(
            – user3179298
            Oct 1 at 12:10
















          • I gave you an example of the text file, but in real we might have more disk's. So I have to grep only the rootvolume=false and once the match is found. Then I need to get the false boot disk name. Then the other partition.
            – user3179298
            Oct 1 at 11:34










          • Hi @user3179298. You can change -f14 to match the information you want in the file. Does this make sense?
            – Goro
            Oct 1 at 11:35











          • Hello Gora, the Field will change server to server. Some times the field 14 will have root volume disk.
            – user3179298
            Oct 1 at 12:05










          • No worries, I will tweak it for you. I thought you have standard files as provided in your example!
            – Goro
            Oct 1 at 12:06











          • I have a logic, but not sure how to get that done. i see every disk are start and end with [ ..... ],[.....],[.....] So, i need to grep for root volume=false, then need to take that [......rootvolume=false ] as variable and use sed or cut to get the disk and other volume information's. then i will parse it to the script for LVM creation. But not sure how to :(
            – user3179298
            Oct 1 at 12:10















          I gave you an example of the text file, but in real we might have more disk's. So I have to grep only the rootvolume=false and once the match is found. Then I need to get the false boot disk name. Then the other partition.
          – user3179298
          Oct 1 at 11:34




          I gave you an example of the text file, but in real we might have more disk's. So I have to grep only the rootvolume=false and once the match is found. Then I need to get the false boot disk name. Then the other partition.
          – user3179298
          Oct 1 at 11:34












          Hi @user3179298. You can change -f14 to match the information you want in the file. Does this make sense?
          – Goro
          Oct 1 at 11:35





          Hi @user3179298. You can change -f14 to match the information you want in the file. Does this make sense?
          – Goro
          Oct 1 at 11:35













          Hello Gora, the Field will change server to server. Some times the field 14 will have root volume disk.
          – user3179298
          Oct 1 at 12:05




          Hello Gora, the Field will change server to server. Some times the field 14 will have root volume disk.
          – user3179298
          Oct 1 at 12:05












          No worries, I will tweak it for you. I thought you have standard files as provided in your example!
          – Goro
          Oct 1 at 12:06





          No worries, I will tweak it for you. I thought you have standard files as provided in your example!
          – Goro
          Oct 1 at 12:06













          I have a logic, but not sure how to get that done. i see every disk are start and end with [ ..... ],[.....],[.....] So, i need to grep for root volume=false, then need to take that [......rootvolume=false ] as variable and use sed or cut to get the disk and other volume information's. then i will parse it to the script for LVM creation. But not sure how to :(
          – user3179298
          Oct 1 at 12:10




          I have a logic, but not sure how to get that done. i see every disk are start and end with [ ..... ],[.....],[.....] So, i need to grep for root volume=false, then need to take that [......rootvolume=false ] as variable and use sed or cut to get the disk and other volume information's. then i will parse it to the script for LVM creation. But not sure how to :(
          – user3179298
          Oct 1 at 12:10

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472553%2fhow-to-print-the-matching-value-from-same-line-which-has-multiple-delimiter%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay