在bash中的X个字符后切断变量

时间:2019-02-25 15:06:58

标签: bash

我有一个bash脚本,其中包含以下if语句。我希望能够回显变量PanoramaRaw的前12个字符,以便可以将其转换为仅包含前12个字符的变量。看来我的方法行不通,我愿意接受建议。

**Feature:** Data Extract List Page

    In order to test DataHub UI, 

    I want to specify the features of Extract History Page



**Scenario:** User logs in to prama datahub website 

    Given the User opens the PRAMA Datahub website

When the User types in userId "pnutala" and pacman passcode "98hgdPwYxze"

  And the User clicks submit button

Then the User lands on page "Datahub"



 **#Scenario:Navigate to Extract History page from the Extract List page**

   **#Given User logs in to prama datahub website**

      When status column-cell has status "Ready" value

      And last run column-cell has userid and date populated

      And the User clicks on last run column cell of first extract record

      Then the User is navigated to the Execution History 
      "execution_history" page



      When the execution history page shows "completed" status

      And the User clicks on extract record header

      Then verify number of records greater than zero

      And file name is a valid string

`

1 个答案:

答案 0 :(得分:0)

这对我有用,它只捕获行中前12个字符。

$ s='12345678901112'
$ echo $s | egrep -o '^.{12}'
123456789011