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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
after grep i want to redirect it to some variable mail2sant Shell Programming and Scripting 2 04-07-2008 09:26 AM
awk redirect output to shell variable dhinge Shell Programming and Scripting 3 12-09-2006 12:11 PM
Redirect Output In Variable ZINGARO UNIX for Dummies Questions & Answers 1 08-02-2006 06:56 AM
redirect command output to variable hugow UNIX for Dummies Questions & Answers 1 06-22-2005 06:43 AM
please help: how to redirect input into a variable artur80 Shell Programming and Scripting 2 11-17-2002 10:18 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-07-2007
MrAd MrAd is offline
Registered User
  
 

Join Date: May 2007
Posts: 6
Redirect to variable

how do you redirect stdout into a variable. whenever I try I get an ambiguous redirect error I am trying to validate some user input and failing miserably.

cal $MONTH $YEAR | grep -c "$DAY"

if the above is 1 then it is valid if 0 then not valid. I have been trying to redirect the output into a variable but get the error. Any ideas?

Many Thanks.
  #2 (permalink)  
Old 05-07-2007
jgt jgt is offline
Registered User
  
 

Join Date: Apr 2007
Location: 44.21.48N 80.50.15W
Posts: 439
Backtick operator

Try:

X=`cal $month $year |grep -c $day`

The ` character is usually the lower case of the ~ character, and is located just to the left of the '1' or above the tab key on most keyboards.
  #3 (permalink)  
Old 05-07-2007
kapilraj kapilraj is offline
Registered User
  
 

Join Date: Dec 2006
Location: Maryland
Posts: 162
Or

cal $MONTH $YEAR | grep -c "$DAY" | read VAR1


Regards,

Kaps
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 06:28 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