|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| 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. |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
Code:
awk ' { printf "%s %s %s\n",$1,$2,$3 } ' |
|
#3
|
|||
|
|||
|
I will check and thank you in 15 min :-)
|
|
#4
|
||||
|
||||
|
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
|
|||
|
|||
|
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 $PreviousdayEntryOut 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
|
||||
|
||||
|
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
|
|||
|
|||
|
Thanks a lot scott.. That really helped me
Regards Arun |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| arun |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |