Shell script: remove leading and trailing character








s="\"Shell scripting is interesting.\""
echo $s

# ${s%\"} will remove the suffix " (escaped with a backslash to prevent shell interpretation)
s=${s%\"}

# ${s#\"} will remove the prefix " (escaped with a backslash to prevent shell interpretation)
s=${s#\"}
echo $s



No comments:

Post a Comment