The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Reading variable from file variable values sagii Shell Programming and Scripting 5 06-27-2009 01:06 PM
calculate number of strings in a variable felixmat1 Shell Programming and Scripting 9 01-02-2009 12:13 AM
How to check if two variable are empty strings at once? (bash) ph0enix Shell Programming and Scripting 4 10-24-2008 02:18 PM
appending strings to variable finalight Shell Programming and Scripting 1 05-20-2008 03:50 AM
Help deciphering script bbbngowc Shell Programming and Scripting 3 01-16-2008 01:57 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-27-2009
cyberfrog cyberfrog is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 15
Deciphering strings or variable values

Hi,

I have a script at the moment of which reads in simply what the latest version is within a folder i.e. v001, v002, v003 etc and then stores this latest version in a variable i.e. $LATEST would echo v003. I have then cut this string so that I only consider the 003 part. I would then like to increment this to 004 and then put the v back in front of it again i.e. v004. What is the easiest way of doing this?

Cheers

CF
  #2 (permalink)  
Old 08-27-2009
chipcmc chipcmc is offline
Registered User
  
 

Join Date: Aug 2009
Location: spain
Posts: 93
Example:
Code:
valor=0003
aux=`printf %.4d $(expr $valor + 1)`
echo "[$aux]"
i supose you want 4 digits for this motiv is .4d
  #3 (permalink)  
Old 08-27-2009
cyberfrog cyberfrog is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 15
Great it worked and how do you then append a letter in front of it so valor = v00004?
  #4 (permalink)  
Old 08-27-2009
chipcmc chipcmc is offline
Registered User
  
 

Join Date: Aug 2009
Location: spain
Posts: 93
change this line
Code:
aux=`printf v%.4d $(expr $valor + 1)`
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0