I think the headline could be self explaining ....
Another thing would be the print or selection of single items of a string :
for example
if I have STR="aBcDEFghIjK?!()} { |\/>.,; " ' 123"
Until now I can only ' elofSTR="`expr length $STR`" '
What is the right syntax for these two questions ?
How to translate tr '[a-z]' '[ a- z]'
Karl Godt
I found this snip http://www.unix.com/shell-programming-s ... cters.html
you have spaces to start with in your string so enclose the original string with single quotes first then
echo "$STR" | sed 's/./ &/g;s/^ //'
Joe
I found this snip http://www.unix.com/shell-programming-s ... cters.html
you have spaces to start with in your string so enclose the original string with single quotes first then
echo "$STR" | sed 's/./ &/g;s/^ //'
Code: Select all
STR='what #%$][ % {} you want to say :D '
echo "$STR" | sed 's/./ &/g;s/^ //'
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
damn just the other day I did this by accident when I was trying to do something else with sed - can't remember, but it was really short and contained *
you can get the length of a string with
${#VAR}
here is an example usage:
you can get the length of a string with
${#VAR}
here is an example usage:
Code: Select all
#keeps adding the "9" character to the end of the string NEWVER
# until it is the same length as the string VER
while [ "${#NEWVER}" -lt "${#VER}" ]
do
NEWVER=${NEWVER}9
done
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
get string length
here's an easy one to read
the output is 25
the bold part is the format to use
${#any_variable}
Joe
here's an easy one to read
Code: Select all
any_variable="some big string goes here"
echo ${#any_variable}
the bold part is the format to use
${#any_variable}
Joe