date command option e Help needed please!!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers date command option e Help needed please!!
# 1  
Old 02-02-2012
date command option e Help needed please!!

Hi All,

I was trying to get the date in format "Feb2" I tried
Quote:
1)
`date +'%b%e'`
output: Feb 2
2)
`date +'%b%d'`
output: Feb02
3)
`date +'%h%e'`
output: Feb 2
option "e" giving me a padded space and getting the result as "Feb 2". Though its working fine for dates 10 to 31.

Please suggest me how to get rid of this space before date.

Thanks
Olivia
# 2  
Old 02-02-2012
What's your system?

What's your shell?

In BASH and new KSH you can do:

Code:
VAR=`date +'%b%e`
# Strip out spaces
VAR="${VAR// }"

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-02-2012
Code:
date +%b%-d

These 3 Users Gave Thanks to binlib For This Post:
# 4  
Old 02-02-2012
:-( ksh93 on Solaris. What am I missing?

Code:
$ date +%b%-d
Feb%-d
$

This User Gave Thanks to gary_w For This Post:
# 5  
Old 02-03-2012
Quote:
Originally Posted by Corona688
What's your system?

What's your shell?

In BASH and new KSH you can do:

Code:
VAR=`date +'%b%e`
# Strip out spaces
VAR="${VAR// }"

I really appreciate your help, thanks a lot. It worked for me Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Needed for creating the folder by checking today's date and, take backup using rsync command

How to create a shell script to create a folder by using the today's date to take backup using rsync command on every evening around 7 pm. Kindly help. Thanks. To be more precise, I want to create a script which matches the today's date with server's date format, if matches then creates the... (2 Replies)
Discussion started by: bakula10
2 Replies

2. 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

3. Shell Programming and Scripting

Help needed with date compare

Hello, I have this unix script which selects rows from DB where current time is greater than expired time (column). So this will give all the records that are expired 1 day ago, 2 days ago, 3 days ago, etc.. I need help modifying in such that it should give records that are only expired 1 day... (5 Replies)
Discussion started by: jakSun8
5 Replies

4. UNIX for Dummies Questions & Answers

find with prune option help needed

Hello, I am using ksh93 (/usr/dt/bin/dtksh) on Solaris and am stuck when trying to use find with the -prune option. I need to search a directory (supplied in a variable) for files matching a certain pattern, but ignore any sub-directories. I have tried: find ${full_path_to_dir_to_search}... (9 Replies)
Discussion started by: gary_w
9 Replies

5. 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

6. 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

7. Solaris

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. ... (6 Replies)
Discussion started by: linuxgeek
6 Replies

8. UNIX for Dummies Questions & Answers

Help needed with date

How can i assign a variable by the name of CUTDATE= today date - 90 days? i have something like this right now :- today=`date '+%Y%m%d'` #cutdate = this is where i am having problem. i need today - 90 days How can i accomplish this? After that i need to do delete the data which are more... (16 Replies)
Discussion started by: chris1234
16 Replies

9. Shell Programming and Scripting

awk system date with -d option

Hi I get problems when using the following command : cat logs | awk -F";" '{ system("date -d "1970-01-01 UTC+0100 $1 seconds""); }' date: date invalide `1968641199401200' date: date invalide `1968641199381709' this is what i have in my log file : cat logs 1199401200;a... (3 Replies)
Discussion started by: arag0rn
3 Replies

10. Shell Programming and Scripting

Help needed on Date command

Hi, I am facing one problem with date command.Actually I want to use this command to get the last month,not the current month..OK,I can do current month - 1 and give special condition for january,But this time i need last month as strings like January,februaury,march etc... There is option... (5 Replies)
Discussion started by: nikunj
5 Replies
Login or Register to Ask a Question