![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To call/execute a shell script from a shell script | konark | UNIX for Dummies Questions & Answers | 1 | 10-26-2007 02:16 PM |
| How to pass a parameter from one Shell-script to another Shell-script | subodhbansal | Shell Programming and Scripting | 2 | 09-22-2007 02:19 AM |
| How to Run a shell script from Perl script in Parent shell? | hifake | Shell Programming and Scripting | 16 | 08-28-2007 05:42 PM |
| Accessing variables of one shell script in another shell script | rsendhilmani | Shell Programming and Scripting | 1 | 04-30-2007 05:43 AM |
| Have a shell script call another shell script and exit | heprox | Shell Programming and Scripting | 2 | 11-20-2006 05:17 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Help in this shell script
Hi ,
I am trying to do following. Problem - " Take out today's day from date and then based on day echo some thing. But some how the control is not going in case switch" Code - here is code ++++++++++++++++++++++++ DAY= date | cut -f 1 -d ' ' echo "$DAY---- is X" case $DAY in 'Wed') echo "Today is $DAY - day" ;; *) echo "Kya ho raha hai" ;; esac +++++++++++++++ So I checked that the cut command is returning me "Wed" with a new line character. So out put of running above code is ======= % sh dr.sh Wed ---- is X Kya ho raha hai ======= So you can see extra newline character comin in play !!!! So can any one help how to truncate all the extra spaces while using cut command ? ANd how can I maeke case run fine here? thanks in advance |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
This line:
DAY= date | cut -f 1 -d ' ' does not set the variable DAY to anything. It is basicly the same as: date | cut -f 1 -d ' ' And then the next line just prints an empty $DAY variable. You want something like: DAY=`date | cut -f 1 -d ' '` Next time please tell which shell you are using. Also which version of unix. |
|
#3
|
|||
|
|||
|
Hi,
I agree I was making a mistake by putting 'space' between + and statement. But still I am not able to assign the day to variable. I tried using excape character also i.e \' \' ' but no use. Now my command looks like DAY='date | cut -f 1 -d \' \'' I am using ksh. and on SUn SOlaris. thanks Himanshu |
|
#4
|
||||
|
||||
|
Cut and paste my statement. The syntax must be exact.
` = back quote ' = single quote " = double quote all very different. |
|
#5
|
|||
|
|||
|
Thanks it worked
Hi
thanks a lot for clearing up the thing. I got it. tht is " ` " (graveascent) to be used when to execute unix command in Shell script. this thing worked `date | cut -f 1 -d ' ' ` Thanks again a lot |
|||
| Google The UNIX and Linux Forums |