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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parse String from a Variable racbern Shell Programming and Scripting 3 04-07-2008 01:04 PM
How do you parse a variable in a bash script? vertical98 Shell Programming and Scripting 3 03-18-2008 04:30 PM
parse a string variable methos Shell Programming and Scripting 3 10-18-2005 05:18 PM
How to parse.. natter Shell Programming and Scripting 8 05-22-2003 10:11 AM
Parse nguda Shell Programming and Scripting 7 05-16-2002 10:10 AM

Closed Thread
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 01-03-2007
mpang_ mpang_ is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 89
parse variable

I have a variable (it is a date actually -> 2007-01-03) which
would be passed in as parameter, what I want is to parse in and put
year, month, and day in separate variables, I have tried the following
but doesn't work

echo $dt | awk -F- '{print $1 $2 $3}' | read y m d

Thanks in advance
  #2 (permalink)  
Old 01-03-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398

Code:
var1=$( echo $dt | cut -d"-" -f1 )

  #3 (permalink)  
Old 01-03-2007
vino's Avatar
vino vino is online now Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Without awk or cut...


Code:
echo "$dt" | while IFS="-" read y m d
do
echo $y
echo $m
echo $d
done

Closed Thread

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 02:46 AM.


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