Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to remove a character (slash) from string

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
JPerkins
Posts: 41
Joined: 2005-12-29 01:42
Location: Nashville, Tennessee

How to remove a character (slash) from string

#1 Post by JPerkins »

I know this is simple, but I can not figure it out.
I need to remove the first character (a slash) of a variable:
What I have is this, which will not work.

TESTSTRING="/var"
NEWSTRING=$TESTSTRING | colrm 1 2
echo $NEWSTRING
var

greenhat
Posts: 170
Joined: 2006-06-03 17:32

#2 Post by greenhat »

here's one way of doing it...

Code: Select all

TESTSTRING="/var"
NEWSTRING=`echo "$TESTSTRING" | colrm 1 1`
echo "$TESTSTRING"
echo "$NEWSTRING"

$ bash test_script
/var
var
$

JPerkins
Posts: 41
Joined: 2005-12-29 01:42
Location: Nashville, Tennessee

#3 Post by JPerkins »

Thanks, worked like a charm.

Post Reply