UNIX Date function with -d options


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX Date function with -d options
# 1  
Old 03-04-2016
UNIX Date function with -d options

Hi ,

I couldn't understand how this program works. Can somebody please explain it to me.

Code:
DT=`date -d "1 day"`  # This part I understand
echo ${DT/ */}  # How this works
echo ${DT/* /}

# 2  
Old 03-04-2016
Hello LoneRanger,

Following is the detailed information on same.

1st: When you run command DT=`date -d "1 day"`, whose value you could see as follows.
Code:
echo $DT
Sat Mar 5 06:52:33 EST 2016

2nd: Now command echo ${DT/ */}, will remove everything from the line Sat Mar 5 06:52:33 EST 2016 from 1st space to till end of line.
3rd: Now command echo ${DT/* /}, will remove everything from the starting from line to till last occurrence of space in line.


Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 03-04-2016
Look into your shell's man page (e.g. man bash) for parameter expansion / pattern substitution.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX ls options

Hi Guys I'm new to the forums and Unix. I have my first assignment for school and i'm stuck on question 1 spent close to 4 hours on it :(. (doesn't look good). I looked the the online documentation of ls but don't really understand it yet. I need to find files whose names that are of length... (1 Reply)
Discussion started by: Stephvai
1 Replies

2. UNIX for Dummies Questions & Answers

UNIX sql options

New to the unix experience and sure love it. I do all my big sql queries using unix sas, it's great, can't complain. Also have isql on the box to work with Sybase db's if need be. Just wondering if there's any large-amt-of-data-folks round here that might suggest some other sql/data tools... (2 Replies)
Discussion started by: sas
2 Replies

3. UNIX for Dummies Questions & Answers

UNIX find command - using multiple -name options

Hi all, What am trying do is search for a directory that is owned by cm that only exists in a path that has a particular directory ex: what I'm using now is find . -user cm -name '*.rel' -type d -exec ls -dl {} \; This is giving me stuff like this ./../../foo1/../../*.rel... (2 Replies)
Discussion started by: jtmed
2 Replies

4. UNIX for Dummies Questions & Answers

What are the career options in unix apart from unix system administration?

What are the career options in unix apart from unix system administration? (2 Replies)
Discussion started by: thulasidharan2k
2 Replies

5. UNIX for Dummies Questions & Answers

Unix : About options of clear command ?

Hello everyone, My question is quite simple, even if I didn't find an answer. I would want a command (maybe clear with some options ?) that can do the following : clear completely the console, as it is when we start a console for the first time. My problem is that I sometimes display a lot... (5 Replies)
Discussion started by: Ben31400
5 Replies

6. Shell Programming and Scripting

any way to squish several date options into one line?

this obviously isnt overly important, but its a bit slow and i was wondering if i could prevent it from re-searching the file several times. i want my matches from the previous and coming three days, as well as today. this is what i have but its weighty and im having trouble finding a way to slim... (6 Replies)
Discussion started by: nomkev
6 Replies

7. Shell Programming and Scripting

Date function

I read man page for etc/shadow field.. on the 8th field, i assume that's the field to change account expire date. my question is: What value does the 8th field keep? i assume it's 13514 instead of "Date" value such as 11/10/08. on the man page, it said: " expire value = 13514 = jan 1,... (11 Replies)
Discussion started by: c00kie88
11 Replies

8. Shell Programming and Scripting

date function

hi, I have to ftp previous days file from a directory to another location. The name of the files are like "xxx20060225" (yyyymmdd format) "xxx20060226" ls -lrt xxx*| tail -2| head -1 will give me the file, but if i could get anything... (2 Replies)
Discussion started by: abey
2 Replies

9. UNIX for Dummies Questions & Answers

Unix Path Options

I am looking for the best way to move files into a directory (ie PDF_files), if the directory doesn't exist to create it. However I am passing the full filename (psfile) of the file so I will have to remove the filename from the end, which can be at different field end lengths. This is a... (2 Replies)
Discussion started by: Shakey21
2 Replies
Login or Register to Ask a Question