how does this substition work?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how does this substition work?
# 1  
Old 05-31-2008
how does this substition work?

Hi all,
Would like to know how these substitution works??

Code:
FINISHED="Done"
x=126
COLS=$((${x} -${#FINISHED} - 5))

here does the #FINISHED give the ascii value of "done" ,or how does it work?

Thanks
# 2  
Old 05-31-2008
That's a standard bash/ksh variable expansion:
Code:
       ${#parameter}
              The length in characters of the value of  parameter  is  substi‐
              tuted.   If  parameter  is  * or @, the value substituted is the
              number of positional parameters.  If parameter is an array  name
              subscripted  by  *  or @, the value substituted is the number of
              elements in the array.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Discussion at work, would a router work pluging a cable in wan1 and lan1?

hi all. and sorry for the random question, but this sparkled a raging flame-war at work and i want more points of view situation a router, with linux of some sort, dhcp client requesting for ip in wan1 (as usual with wan ports) dhcp server listening in lan1, and assigning ip (as usual... (9 Replies)
Discussion started by: broli
9 Replies

2. Shell Programming and Scripting

sed substition within XML tag

Hi all, I basically want to remove certain characters from within a certain XML tag: From: <mytagone>hello 1-2-3 world</mytagone> <mytagtwo>hello 1-2-3 world</mytagtwo> To: <mytagone>hello 1 2 3 world</mytagone> <mytagtwo>hello 1-2-3 world</mytagtwo> Is this possible using sed... (6 Replies)
Discussion started by: Jedimark
6 Replies

3. Shell Programming and Scripting

My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os. my script. logFiles="sentLog1.log sentLog2.log" intial_time="0 0" logLocation="/usr/local/tomcat/logs/" sleepTime=600 failMessage=":: $(tput bold)Log not update$(tput rmso) = " successMessage="OK" arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies

4. IP Networking

NIC will not work, but it did work.

I have a client machine that was built and loaded with SCO UNIX 2.1.3, (yes it is old). The machine worked fine on the closed network that I tested on in my shop. I then had to change it to the network that it would be connected to. Below is the host file, router and subnet mask file that I usually... (0 Replies)
Discussion started by: NC user
0 Replies

5. UNIX for Dummies Questions & Answers

Help with variable substition in sed

Hi, I'm a bit stuck trying to get my sed syntax quite right for what I'm trying to do. I have a list of directories in a file and am trying to remove some of them using sed. I can do it if I specify the directory I want to remove in the sed command and escape the "/"s like so: say I... (2 Replies)
Discussion started by: derndingle
2 Replies

6. UNIX for Advanced & Expert Users

Regular expression / regex substition on Unicode text

I have a large file encoded in Unicode that I need to convert to CSV. In general, I know how to do this by regular expression substitutions using sed or Perl, but one problem I am having is that I need to put a quotation mark at the end of each line to protect the last field. The usual regex... (1 Reply)
Discussion started by: thomas.hedden
1 Replies

7. Shell Programming and Scripting

Command substition with KSH

$var=`command <arg> <arg>` I thought there was another method $var=$(command <arg> <arg>) I thought I read saw the second example. It doesnt work (2 Replies)
Discussion started by: popeye
2 Replies

8. UNIX for Dummies Questions & Answers

Perl Substition with multiple conditions

I have a text file that contains lines similar to the following: ----------------------------------------------------------- fall for setup CSHRC0 'gnd'; CSHR0 'gnd'; rise for setup rise for hold CSHRC0 'gnd'; CSHR0 'gnd'; fall for hold ... (4 Replies)
Discussion started by: EDALBNUG
4 Replies

9. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

10. Shell Programming and Scripting

Will this work?

I'm trying to check if files already exist in a directory. They have the same basename (exsyctr1), but 4 different extensions. If the files exist, then I make backups of them, then copy them from another directory ($livecomp/data) to the current one ($copycomp/data). If they don't exist, just... (5 Replies)
Discussion started by: Ypnos
5 Replies
Login or Register to Ask a Question