Sponsored Content
Top Forums Shell Programming and Scripting Getting a Date value based on day Post 303015842 by Don Cragun on Friday 13th of April 2018 02:33:11 PM
Old 04-13-2018
What operating system are you using (including release number)?

What shell are you using (including version number)?

If you have a filename like FILE_NAME_20180410, what date do you want? 20180410 or 20180403?

What have you tried to solve this problem on your own?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting day from a date...

Hi, I have a date input in MMDDYYYY format.. I have to give the day (whether that DD is sunday/monday...) Is there any command for it... Or do I have to write a script for that... Thanks in Advance Yeheya (1 Reply)
Discussion started by: yeheyaansari
1 Replies

2. UNIX for Dummies Questions & Answers

Add a day to a given date

Hi, I have a date field which is a variable field being passed to the script from outside. I need to know how i can add 1 day to it. I have seen example of date subtraction but while adding each time date reaches 31 or 30 i have to put if else condition. Or for leap year also. Kindly let... (4 Replies)
Discussion started by: pallet
4 Replies

3. UNIX for Dummies Questions & Answers

date - 1 day

Hi, I have been trying just about every unix command to come up with yesterday's date (today's date - 1). I have seen all of the help on this forum, and none of it seems to work for me here. We are using Sun Solaris 9 Unix. I am using this script to create a .txt file with ftp commands that I will... (2 Replies)
Discussion started by: sfedak
2 Replies

4. Shell Programming and Scripting

value of variable based on time of the day

i would need some help in setting the value of a variable (TIME_NOW) depending on the time of the day ...e.g. if today's date is 12th April 2009 and if the current time is between midnight and 16:59:59 hrs then the TIME_NOW should be yesterday's date i.e. TIME_NOW=11 else if the current time... (3 Replies)
Discussion started by: zainravi
3 Replies

5. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. UNIX for Dummies Questions & Answers

Getting date -1 day not using GNU date

It's easy as pie to get the date minus one day on opensolaris: date -d "-1 day" +"%Y%m%d"run this command on our crappy Solaris 10 machines however (which I'm guessing doesn't have GNU date running on it) and you get: date: illegal option -- d date: illegal option -- 1 date: illegal option --... (5 Replies)
Discussion started by: rich@ardz
5 Replies

7. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

8. AIX

Need to get the next day's date of the user entered date

I need to get the next day's date of the user entered date for example: Enter date (yyyy/mm/yy): 2013/10/08I need to get the next day's date of the user entered date Desired Output: 2013/10/09Though there are ways to achieve this is Linux or Unix environment (date command) ,I need to... (1 Reply)
Discussion started by: rpm120
1 Replies

9. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

10. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies
NL_LANGINFO(3)						   BSD Library Functions Manual 					    NL_LANGINFO(3)

NAME
nl_langinfo -- get locale information LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <langinfo.h> char * nl_langinfo(nl_item item); DESCRIPTION
The nl_langinfo() function returns a pointer to a string containing information set by the program's locale. The names and values of item are defined in <langinfo.h>. The entries under Category indicate in which setlocale(3) category each item is defined. Constant Category Meaning CODESET LC_CTYPE Codeset name D_T_FMT LC_TIME String for formatting date and time D_FMT LC_TIME Date format string T_FMT LC_TIME Time format string T_FMT_AMPM LC_TIME A.M. or P.M. time format string AM_STR LC_TIME Ante-meridiem affix PM_STR LC_TIME Post-meridiem affix DAY_1 LC_TIME Name of the first day of the week (e.g.: Sunday) DAY_2 LC_TIME Name of the second day of the week (e.g.: Monday) DAY_3 LC_TIME Name of the third day of the week (e.g.: Tuesday) DAY_4 LC_TIME Name of the fourth day of the week (e.g.: Wednesday) DAY_5 LC_TIME Name of the fifth day of the week (e.g.: Thursday) DAY_6 LC_TIME Name of the sixth day of the week (e.g.: Friday) DAY_7 LC_TIME Name of the seventh day of the week (e.g.: Saturday) ABDAY_1 LC_TIME Abbreviated name of the first day of the week ABDAY_2 LC_TIME Abbreviated name of the second day of the week ABDAY_3 LC_TIME Abbreviated name of the third day of the week ABDAY_4 LC_TIME Abbreviated name of the fourth day of the week ABDAY_5 LC_TIME Abbreviated name of the fifth day of the week ABDAY_6 LC_TIME Abbreviated name of the sixth day of the week ABDAY_7 LC_TIME Abbreviated name of the seventh day of the week MON_1 LC_TIME Name of the first month of the year MON_2 LC_TIME Name of the second month MON_3 LC_TIME Name of the third month MON_4 LC_TIME Name of the fourth month MON_5 LC_TIME Name of the fifth month MON_6 LC_TIME Name of the sixth month MON_7 LC_TIME Name of the seventh month MON_8 LC_TIME Name of the eighth month MON_9 LC_TIME Name of the ninth month MON_10 LC_TIME Name of the tenth month MON_11 LC_TIME Name of the eleventh month MON_12 LC_TIME Name of the twelfth month ABMON_1 LC_TIME Abbreviated name of the first month ABMON_2 LC_TIME Abbreviated name of the second month ABMON_3 LC_TIME Abbreviated name of the third month ABMON_4 LC_TIME Abbreviated name of the fourth month ABMON_5 LC_TIME Abbreviated name of the fifth month ABMON_6 LC_TIME Abbreviated name of the sixth month ABMON_7 LC_TIME Abbreviated name of the seventh month ABMON_8 LC_TIME Abbreviated name of the eighth month ABMON_9 LC_TIME Abbreviated name of the ninth month ABMON_10 LC_TIME Abbreviated name of the tenth month ABMON_11 LC_TIME Abbreviated name of the eleventh month ABMON_12 LC_TIME Abbreviated name of the twelfth month ERA LC_TIME Era description segments ERA_D_FMT LC_TIME Era date format string ERA_D_T_FMT LC_TIME Era date and time format string ERA_T_FMT LC_TIME Era time format string ALT_DIGITS LC_TIME Alternative symbols for digits RADIXCHAR LC_NUMERIC Radix character THOUSEP LC_NUMERIC Separator for thousands YESEXPR LC_MESSAGES Affirmative response expression NOEXPR LC_MESSAGES Negative response expression RETURN VALUES
nl_langinfo() returns a pointer to an empty string if item is invalid. EXAMPLES
The following example uses nl_langinfo() to obtain the date and time format for the current locale: #include <time.h> #include <langinfo.h> #include <locale.h> int main(void) { char datestring[100]; struct tm *tm; time_t t; char *ptr; t = time(NULL); tm = localtime(&t); (void)setlocale(LC_ALL, ""); ptr = nl_langinfo(D_T_FMT); strftime(datestring, sizeof(datestring), ptr, tm); printf("%s ", datestring); return (0); } SEE ALSO
setlocale(3), tm(3), nls(7) STANDARDS
The nl_langinfo() function conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The nl_langinfo() function appeared in NetBSD 1.0. BSD
April 14, 2011 BSD
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy