date -d illegal option in Solaris


 
Thread Tools Search this Thread
Operating Systems Solaris date -d illegal option in Solaris
# 1  
Old 11-24-2009
date -d illegal option in Solaris

Hi All,

Is it possible to run date -d option in Solaris?
Do we have a work around so that -d option will be recognized
by solaris as it is recognized by linux.

I need this since i am using this in scripting and it works in Linux box. my problem is
it doesn't work in solaris box.

QUERY="rpm -qa --queryformat '%{installtime} %{name}-%{version}-%{release}-%{arch} \n'|
awk '{ if ( \$1 > '`date -d "1 week ago" +%s`') print \$2 }'"

Anyone can help me on this please ?

---------- Post updated at 02:46 PM ---------- Previous update was at 02:31 PM ----------

-Or-

Do we have equivalent commands for `date -d "1 week ago" +%s` in Solaris ?
# 2  
Old 11-24-2009
"date" command has only `-u` or `-a` options
# 3  
Old 11-24-2009
You are think of the GNU date implementation. POSIX date does not support those options. GNU unix tools are available as an add-on to Solaris.
# 4  
Old 11-24-2009
one question

how to update system date and time
# 5  
Old 11-24-2009
If you are using a recent enough Solaris release, Gnu date might already be there:
Code:
$ uname -a 
SunOS pcjll 5.11 snv_128 i86pc i386 i86pc
$ /usr/gnu/bin/date -d "now -7 days" "+%s"
1258453453

otherwise, you have these nawk and perl solutions:
Code:
$ nawk 'BEGIN{print srand()-(7*24*60*60)}'
1258453618
$ perl -e 'printf("%s\n",time-(7*24*60*60));'
1258453627

# 6  
Old 11-24-2009
thanks jigi
# 7  
Old 11-25-2009
Thank guys for all your post..

God Bless you all!
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies

2. Shell Programming and Scripting

Read: line 6: illegal option -e

For some reason read -e isn't working in my script. I need a directory as input from a user and I'd like for them to be able to use tab complete which is why I'm using -e. When the script is run, I get: read: line 6: illegal option -e In order to just figure out what is going on with the -e... (4 Replies)
Discussion started by: orangeSunshine
4 Replies

3. Shell Programming and Scripting

stat -c illegal option

I'm trying to get the size of each file, but when I try to use stat -c %s <file> I get the message stat: illegal option -- c Also, the man page for stat shows readlink,stat. It doesn't seem to match the man pages I've seen online. what is going on here? (6 Replies)
Discussion started by: nextyoyoma
6 Replies

4. Shell Programming and Scripting

date: illegal option -- d in sun solaris

Hi all, I am trying to execute the following command in a sun solaris machine and getting the error as below. bash-2.03$ date -d "1 day ago" +%Y%m%d date: illegal option -- d bash-2.03$ uname -a SunOS gtrd02 5.8 Generic_117350-55 sun4u sparc SUNW,Sun-Fire-V440 Can anybody help me to... (1 Reply)
Discussion started by: Tuxidow
1 Replies

5. Shell Programming and Scripting

Help needed sed: illegal option -- i

hello. i have a script, but in solaris i get this message sed: illegal option -- i whats wrong? With Ubuntu there is no problem. Thanks for help. #!/bin/bash for file in $(find /directory..../Test/*.txt -type f) do head -n 1 $file | egrep '^#!' if then sed -i '2i\Headertext'... (3 Replies)
Discussion started by: fertchen
3 Replies

6. Solaris

Please help --setfacl: illegal option -- R

when i am executing setfacl -Rm u:ggoyal2:rwx,m:rwx dir i am getting error bash-3.00# setfacl -Rm u:ggoyal2:rwx,m:rwx dir setfacl: illegal option -- R usage: setfacl -f aclfile file ... setfacl -d acl_entries file ... setfacl -m acl_entries file ... setfacl -s acl_entries file... (2 Replies)
Discussion started by: manoj_dahiya22
2 Replies
Login or Register to Ask a Question