bash while string is not empty

18,794

Solution 1

It is not ending because the sed expression is not correct. It expects minimum 15 characters and does not work for anything less than 15 chars. Try this:

RAW=$(echo $RAW| sed -r 's/^.{0,15}//')

Solution 2

Maybe you just want this:

#!/bin/bash
RAW=012345678901234567890
.
.
.
RAW=${RAW:15}
echo $RAW
567890
Share:
18,794
dreadiscool
Author by

dreadiscool

Updated on June 27, 2022

Comments

  • dreadiscool
    dreadiscool almost 2 years

    I'm trying to set up a script that parses a string.

    My loop is currently

    while [ -n "$RAW" ]; do
        // do some processing here
        RAW=$(echo $RAW| sed -r 's/^.{15}//')
    done
    

    However, the script never seems to end