Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, Would like to know how this substitution works? Code: Would like to know how these substitution works?? Code: FINISHED="Done" x=126 COLS=$((${x} -${#FINISHED} - 5)) here does the #FINISHED ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    20

    how does this substition work?

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

    Code:
    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. #2
    Linux Engineer khafa's Avatar
    Join Date
    Apr 2008
    Location
    Tokyo, Japan
    Posts
    858
    hi



    here is how it works.
    1) first bash calculates ${#FINISHED} and that yields 4 ( ${#FINISHED} is the length of the variable FINISHED which contains 4 characters( "Done")) .
    2) then it calculates 126 - 4 - 5 = 117
    3) then it puts it in COLS
    Linux and me it's a love story

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...