bash

Forum discussion tagged with bash.
  1. C

    [SOLVED] How to only get certain parts from the output of a command

    I have a script I am working on that I need to cut out part of the output from a command. For example: #! /bin/bash blkid read -p "Enter the drive from the list above (example: /dev/sda1): " drive blkid | grep $drive # <-- This is where I am stuck. I want to sort out the UUID, PARTUUID, and...
  2. AlvinSeville

    Question How to correctly remove first pattern match from string?

    Hello everyone! I have the task to remove first pattern match from string. Now my code is: #!/bin/bash function removeFirstMatch() { local string="$1" local pattern="$2" left=${string%%$pattern*} right=${string#*$pattern} echo "$left$right" } echo $(removeFirstMatch 'a\b\c' '\') #...