Results 1 to 3 of 3
Hi everyone,
I 'm writing a script these days and I need to use the command: string
link=*ttp://linux.about.com/library/cmd/blcmdln_string.htm ( I am a newbie so the forum doesn't allow to post ...
- 06-27-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 2
Add a new command in bash
Hi everyone,
I 'm writing a script these days and I need to use the command: string
link=*ttp://linux.about.com/library/cmd/blcmdln_string.htm ( I am a newbie so the forum doesn't allow to post URLs yet
)
The bash, however, answers: command not found...
I tried: "yum install string", but it didn't work.
Any suggestions?
- 06-28-2011 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Yes, the link does make string seem like a useful command. However, if you look carefully, you will notice references to tcl in places.
This identifies it as a tcl command. It is not a command available directly through a shell like bash. The page does not do a good job of making that clear.
Look at the man pages for bash or expr for some string manipulation features.
Below is an example of string being used in a tclsh script with an example from the link you posted.
Best wishes ... cheers, drl
producing:Code:#!/usr/bin/env tclsh # @(#) tcl2 Demonstrate tclsh feature: "string" command. set version [ info tclversion ] set message " Hello, world from tclsh ($version)" puts stdout $message puts stdout "" set v1 [ string first a 0a23456789abcdef 5 ] puts stdout [ join [ list " variable v1 is " $v1 ] ] exit 0
Code:% ./tcl2 Hello, world from tclsh (8.4) variable v1 is 10
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 06-28-2011 #3Just Joined!
- Join Date
- Jun 2011
- Posts
- 2
Found it!!!

I needed
where mystring="###123", in order to put 123 in a variable...Code:string range $mystring 3 end
But,
works fine in bash.Code:len=`expr length $mystring` var=`expr substr $line 4 $len`
Thanks for your help.


Reply With Quote