The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
substring panknil Shell Programming and Scripting 4 10-01-2007 05:12 AM
How do I Substring ?? Rigger Shell Programming and Scripting 6 04-25-2007 11:26 PM
substring alla.kishore UNIX for Dummies Questions & Answers 8 01-08-2007 11:57 PM
Getting a substring djkane Shell Programming and Scripting 3 03-21-2006 06:50 AM
substring Anika UNIX for Dummies Questions & Answers 4 09-19-2001 12:10 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-04-2002
Registered User
 

Join Date: Feb 2002
Posts: 18
Question substring of a variable

I'm working in:

#!/bin/ksh

My question:

I have a variable latest_bus_date, which in in the format YYYYMMDD. I would like to create a new variable that is in the format of MMDDYY using the data stored in latest_bus_date.

$latest_bus_date='20020304'
The new variable should have: 030402

Any ideas?

Thanks,
blt123
Reply With Quote
Forum Sponsor
  #2  
Old 03-04-2002
thekid
Guest
 

Posts: n/a
This is done in /bin/ksh on Dynix/ptx 4.4.8:

This isn't the prettiest command ever, but it works from what I can tell...

new_date="`echo $latest_bus_date |cut -c5-6``echo $latest_bus_date |cut -c7-8``echo $latest_bus_date |
cut -c3-4`"

echo $new_date
Reply With Quote
  #3  
Old 03-05-2002
Registered User
 

Join Date: Feb 2002
Posts: 18
Thumbs up substring of a variable

Thank you - it works!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0