Visit Our UNIX and Linux User Community

need a help reg -d in shell

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need a help reg -d in shell
# 1  
Old 03-19-2008
need a help reg -d in shell


I am using this to get previous month

`date -d"1 month ago" "+%m"`

But will it work for january?..will it return 12?

Please advice.
# 2  
Old 03-19-2008
date "+%m" | awk '{if($1==01){print 12}else{print $1-1}}'

# 3  
Old 03-19-2008
If I run the following in march I get 12:

% date -d"3 months ago" "+%m"

So, I suppose so your command will work for you

Previous Thread | Next Thread
Test Your Knowledge in Computers #742
Difficulty: Medium
XL Fortran is the name of an open source Fortran compiler for IBM-supported environments, including Linux for big-endian distributions and AIX.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reg: Certification on Shell Scripting

Hi all, Please let me know whether any certifications are there for Shell Scripting. (Not Brainbench). If any one know pls post the details. Thanks in advnce.. (1 Reply)
Discussion started by: divya bandipotu
1 Replies

2. Shell Programming and Scripting

Reg expressions

Hi, I would like to grep for a string within a tag, can someone provide some assistance in how to do it? So I would like to use the grep command to find a string like: <tag>sometext<tag> because the sometext can be any number of characters or an type of number or lettering, what expression... (1 Reply)
Discussion started by: cyberfrog
1 Replies

3. Shell Programming and Scripting

Reg: SHELL scripting

Hi All, I am Lucky, newly joined the group. I am very new to unix, can any one provide me good PDF's on shell scirpting to learn quickly. Thanks in Advance, Lucky (3 Replies)
Discussion started by: me_lucky
3 Replies

4. Solaris


Hi Guys, I have a doubt either to Reboot the server after Replacing the disk0. I have two disks under vxvm root mirrored and i had a problem with primary disk so i replace the disk0 failed primary disk and then mirrored. After mirroring is it reboot required ? (7 Replies)
Discussion started by: kurva
7 Replies

5. UNIX for Dummies Questions & Answers


Hi all, I am trying to send a mail by using MAILX option to my YAHOO-Id. It is giving the following error. Can any one help me to find what is the problem? Do i need to get any kind of settings in my UNIX box for using MAILX? The bounce mail is as below: Message 1: From MAILER-DAEMON Tue... (2 Replies)
Discussion started by: Raamc
2 Replies

6. Shell Programming and Scripting

Reg sftp in shell script

Hi, I want to retrieve files from an sftp site and place it a directory in unix server. When I try to connect, it is asking password even if i hardcode it in the script.I want to automate the script. Could anyone tell me how to avoid password prompt. #!/bin/sh # sample automatic ftp script... (3 Replies)
Discussion started by: vidhya_vec
3 Replies

7. Shell Programming and Scripting

usage...sed/awk/reg-exp shell scripting

in shell scripting there is extensive usage of i> regular expression ii>sed iii>awk can anyone tell me the suitable contexts ...i mean which one is suitable for what kind of operation. like the reg-exp and sed seems to be doing the same job..i.e pattern matching (1 Reply)
Discussion started by: mobydick
1 Replies

8. Shell Programming and Scripting

Reg: Gzip

Hi , I want gzip a folder te55 which has got 3 files test1.test2,test3 the name of the gzipped folder should be te55.gz with the 3 files as test1,test2,test3 itself... Is it possible... thanks in advance sam (5 Replies)
Discussion started by: sam99
5 Replies

9. Shell Programming and Scripting

Reg: Shell script ran using informatica

Hi all, I am not sure whether this is the right place to ask this question...:) I am working in Informatica PowerCenter 8.1.1 tool and my server is on UNIX. I have got a shell script to copy files from one folder to another. When I run the script directly from UNIX prompt it is taking 60... (0 Replies)
Discussion started by: sam99
0 Replies

10. Shell Programming and Scripting

Awk - Using a Shell Variable in the Reg Expression

Hi all, I have a shell variable $test1 that holds a value derived from some other processing. What I need to do is use that $test1 as the input to a awk regular expression: nawk -F"," -v tester=$test1 ' /tester/{ print $0 } ' $inputFile So what I have is tester... (6 Replies)
Discussion started by: not4google
6 Replies

Featured Tech Videos