?
Solved

get the specific variable of length

Posted on 2010-01-04
4
Medium Priority
?
254 Views
Last Modified: 2013-12-25
How to get the length from different size?
for example:-
aaa=expert exchange idea  
bbb=new Zealand

the result i wan to get is
aaa=expert exchange ide
bbb=new Zealan

I need the command

Thank you so much
0
Comment
Question by:ryanW
  • 2
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 26178149
#!/bin/bash
aaa='expert exchange idea'
bbb='new Zealand'
aaa=${aaa:0:${#aaa}-1}
bbb=${bbb%?}
echo aaa=$aaa
echo bbb=$bbb
0
 

Author Comment

by:ryanW
ID: 26178219
Thank you for ur help.. it is working...
but i got a question need to ask u..
is it possible to control the size that i wan to get..

like... "AAA SSS CCC"

i want to get 6 character
so.. it will be "AAA SS"

like "GGGG AAA XXXXXX VVVVVV"
size of 11
so..it will be "GGGG AAA XX"

can u help  me?
thank you



0
 
LVL 85

Expert Comment

by:ozo
ID: 26178258
#!/bin/bash
aaa="AAA SSS CCC"
echo ${aaa:0:6}
0
 

Author Comment

by:ryanW
ID: 26178273
yaya...i try myself already... can work also..
thank you so  much... xie xie
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question