How to remove a character (slash) from string

Need help with C, C++, perl, python, etc?

How to remove a character (slash) from string

Postby JPerkins » 2006-09-04 00:56

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
JPerkins
 
Posts: 41
Joined: 2005-12-29 01:42
Location: Nashville, Tennessee

Postby greenhat » 2006-09-04 06:26

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
$
greenhat
 
Posts: 170
Joined: 2006-06-03 17:32

Postby JPerkins » 2006-09-04 11:31

Thanks, worked like a charm.
JPerkins
 
Posts: 41
Joined: 2005-12-29 01:42
Location: Nashville, Tennessee


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable