Go Back   The UNIX and Linux Forums > Operating Systems > Solaris
google site



Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-09-2010
Registered User
 

Join Date: Mar 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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 scottn; 03-09-2010 at 05:42 PM.. Reason: Please use code tags
Sponsored Links
  #2  
Old 03-09-2010
anbu23's Avatar
anbu23 anbu23 is offline Forum Advisor  
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,763
Thanks: 2
Thanked 17 Times in 16 Posts

Code:
 awk ' { printf "%s %s  %s\n",$1,$2,$3 } '

  #3  
Old 03-09-2010
Registered User
 

Join Date: Mar 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
I will check and thank you in 15 min :-)
  #4  
Old 03-09-2010
scottn's Avatar
scottn scottn is online now Forum Staff  
Moderator
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 2,593
Thanks: 13
Thanked 91 Times in 88 Posts
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
Registered User
 

Join Date: Mar 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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 scottn; 03-09-2010 at 06:50 PM.. Reason: Code tags, PLEASE!
  #6  
Old 03-09-2010
scottn's Avatar
scottn scottn is online now Forum Staff  
Moderator
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 2,593
Thanks: 13
Thanked 91 Times in 88 Posts
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
Registered User
 

Join Date: Mar 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot scott.. That really helped me

Regards
Arun
Sponsored Links
Reply

Bookmarks

Tags
arun

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reg str concat ilayans UNIX for Dummies Questions & Answers 4 10-31-2008 04:14 AM
concat strings melanie_pfefer Shell Programming and Scripting 1 12-04-2007 06:12 AM
concat fields markjason Shell Programming and Scripting 10 10-23-2006 02:38 PM
concat string mpang_ Shell Programming and Scripting 1 07-25-2006 06:03 AM
Concat dhananjaysk Shell Programming and Scripting 1 03-20-2006 06:42 AM



All times are GMT -4. The time now is 08:01 AM.