As dj_segfault points out, the shell can do most of this for you. It looks like you have to retreat to something external for the bottom of the column. You have many options for this, such as perl one-liners above, etc., but I think tr is probably the easiest.
# first, strip underscores CLEAN=${STRING//_/}
The order here is somewhat important. We want to get rid of underscores, and also replace spaces with underscores, so we must definitely remove the underscores. Waiting until the end to the end, etc., we know that we only have alphanumeric and underscores, and we can be sure that we do not have spaces, so we donβt need to worry about special characters being interpreted by the shell.
Thomee Sep 18 '08 at 17:04 2008-09-18 17:04
source share