Concat strings in Sun Solaris


 
Thread Tools Search this Thread
Operating Systems Solaris Concat strings in Sun Solaris
# 1  
Old 03-09-2010
Concat strings in Sun Solaris

Hi I am using solaris 10
Code:
#!/bin/ksh
today=`date`
GrepDate=`echo $today | awk '{print $1,$2,$3}'`
echo $GrepDate
output is "Mon Mar 8"

But i need to get output like "Mon Mar 8"(two spaces b/w Mar & 8)

Please help

Regards
Arun

Last edited by Scott; 03-09-2010 at 06:42 PM.. Reason: Please use code tags
# 2  
Old 03-09-2010
Code:
 awk ' { printf "%s %s  %s\n",$1,$2,$3 } '

# 3  
Old 03-09-2010
I will check and thank you in 15 min :-)
# 4  
Old 03-09-2010
Beat me to it, but taking what you have already...

Code:
#!/bin/ksh
today=$(date)
GrepDate=$(echo "$today" | awk '{print $1,$2 "  " $3}')
echo "$GrepDate"

(important is the quotes in the final echo)
# 5  
Old 03-09-2010
That didnt work out for me..
I will post the full code here

Code:
TotalEntry=`cat /d002/oracle/ORAJDETS/dumpb/alert_ORAJDETS.log|wc -l`

echo $TotalEntry
Yesterday=`perl -e 'print localtime(time() - 86400) . "\n" '`
echo $Yesterday
GrepDate=`echo "$Yesterday" | awk '{printf "%s %s  %s\n", $1,$2,$3}'`
echo $GrepDate
PreviousdayEntry=`cat -n /d002/oracle/ORAJDETS/dumpb/alert_ORAJDETS.log |grep '$GrepDate'|head -1 |awk '{print $1}'`
echo $PreviousdayEntry

Out put vil be
Code:
22059
Mon Mar 8 17:46:33 2010
Mon Mar 8

Please help

Last edited by Scott; 03-09-2010 at 07:50 PM.. Reason: Code tags, PLEASE!
# 6  
Old 03-09-2010
You must quote your variables when they contain whitespace...

i.e.
Code:
$ X="1    2 3" 
$ echo $X
1 2 3
$ echo "$X"
1    2 3

# 7  
Old 03-10-2010
Thanks a lot scott.. That really helped me

Regards
Arun
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Patching Procedure in Solaris 10 with sun cluster having Solaris zone

Hi Gurus I am not able to find the patching procedure for solaris 10 ( sol10 u11) to latest patchset with sun cluster having failover zones so that same I should follow. Take an instance, there are sol1 and sol2 nodes and having two failover zones like sozone1-rg and sozone2-rg and currently... (1 Reply)
Discussion started by: nick101
1 Replies

2. Shell Programming and Scripting

Concat strings without spaces...

Hello, I have a very travial question....when i run the below script...how can i change my script that will give me an output pf "this is log_vp1" ....i dont want any spaces between log_vp and 1 or any other character...i know i can set a variable for 1(lets say num is the var) and then do... (2 Replies)
Discussion started by: crazy_max
2 Replies

3. Solaris

Sun Solaris not able to ping Sun Solaris

I have a Sun Blade 2500 with SUN 5.9 OS installed. I can ping other machines(windowsXP/2003) from my SUN machines but not able to ping each other SUN machines which i have newly installed. (7 Replies)
Discussion started by: z_haseeb
7 Replies

4. Solaris

useful links and help resources for Sun's products and Sun's Solaris

Hi all, Those links might help anyone Knowledge base Video tutorials (0 Replies)
Discussion started by: h@foorsa.biz
0 Replies

5. Solaris

Sun Fire 280R Sun Solaris CRT/Monitor requirements

I am new to Sun. I brought Sun Fire 280R to practice UNIX. What are the requirements for the monitor/CRT? Will it burn out old non-Sun CRTs? Does it need LCD monitor? Thanks. (3 Replies)
Discussion started by: bramptonmt
3 Replies

6. Shell Programming and Scripting

concat strings

Hello, I have a list of tablespaces in oracle and I want to concatenate 'drop tablespace' on the left of each line and 'INCLUDING CONTENTS AND DATAFILES' on the right of each line. Any idea how to do that? many thanks. PS: I tried to use excel and copy/paste it to vi. But I noticed many... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

7. UNIX for Dummies Questions & Answers

Sun Solaris 10: How do I create a bootup disc? The Sun website confuses me

Hey there, I am starting a Computer Science Foundation year at the end of this month and am trying to get a little bit ahead of the game. I have always wanted to learn Unix and am currently struggling with creating a boot disc to run Solaris (I have chosen to study this) from as opposed to... (0 Replies)
Discussion started by: Jupiter
0 Replies

8. Solaris

Sun Solaris Sun Java Desktop

Ok I a n00b, not gunna hide it so here goes - Sun Solaris, V.10 i386 - during the setup, I can choose a screen resolution that looks great with 65k colors and all. However, when all is said and done 4 disks and a reboot later, I get hanious 640x480 @ 256 only. If I choose the Sun Java Desktop... (20 Replies)
Discussion started by: Spooky
20 Replies
Login or Register to Ask a Question