I am writing shell script for embedded Linux in a small industrial box. I have a variable containing the text pid: 1234
and I want to strip first X characters from the line, so only 1234 stays. I have more variables I need to "clean", so I need to cut away X first characters and ${string:5}
doesn't work for some reason in my system.
The only thing the box seems to have is sed
.
I am trying to make the following to work:
result=$(echo "$pid" | sed 's/^.\{4\}//g')
Any ideas?
${string:5}
doesn't work then you're not using Bash or another shell that supports that syntax. What shell and version are you using? What does your shebang look like? My guess is that you're usingsh
(such asdash
) or possiblyzsh
.