How can I apply 'date' command to specific columns, in a BASH script?
Hi everyone,
I have a situation in which I have multiple (3 at last count) date columns in a CSV file (, delim), which need to be changed from:
January 1 2017 (note, no comma after day)
to:
YYYY-MM-DD
So far, I am able to convert a date using: date --date="January 12, 1990" +%Y-%m-%d
However, I need to read a specific column in the CSV, then replace what's there with the new format. It doesn't matter which commonly used GNU utility I use, I just need to do it.
So far, I have been trying to write an AWK function in a BASH shell script to do it, but I'm completely lost.
Can anyone offer suggestions on the easiest way to accomplish this from within a BASH script? The attached sample.txt gives an idea of what the data looks like, only greatly reduced. The really data has about 3000 rows and 35 columns.
Hi all,
I want to read some specific rows & columns in the .xls file with my script to get the data to be manipulated. Now, I can read the .xls file correctly & i can go to the specific sheet that I want but i have a problem to specify the specific rows & columns. I mean, I want to get the info... (0 Replies)
I'm a newbie in AIX, i want to make a script for grep any lines with date bellow 20
PRINT0089-88615 data1 3072 Mon Dec 19 17:53:49 WITA 2011
PRINT0089-88616 data1 4096 Mon Dec 19 17:53:49 WITA 2011
PRINT0089-88618 data1 5120 Mon Dec 19... (7 Replies)
Hi
I need to find the list of files in a directory and to do some specific operations based on the type of files.
suppose in a directory am having .dat , .log, .err, .rej file types. i need to filter out .dat and .log only which are older than six months.
i used the below query but the... (2 Replies)
Hi All,
I have below perl script which writes xml from .xls file.
Now i want to add below two conditions in this script :
1. to check if the the input .xls file has ony two columns , if more tahn two columns then script should pop up an error.
2. If there are two columns , then first column... (4 Replies)
Hi All
I have a file which has five columns in each rows.
cat file.txt
a|b|c|d|e
1|2|3|4|5
a1|a2|a3|a4|a5
.
.
.
I need to make sure that there are no less than five or more than five columns (in all the rows) by mistake. I tried this :
cat file.txt | awk 'BEGIN{FS="|"};{print... (3 Replies)
In the bash below I am asking the user for a panel and reading that into bed. Then asking the user for a file and reading that into file1.Is the grep in bold the correct way to apply the selected panel to the file? I am getting a syntax error. Thank you :)
... (4 Replies)
Hello,
I have a requirement to apply hashing algorithm on flat file on one or more columns dynamically based on header
sample input file
ID|NAME|AGE|GENDER
10|ABC|30|M
20|DEF|20|F
say if i want multiple columns based on the header example id,name or id,age or name,gender and hash and... (13 Replies)
Discussion started by: mkathi
13 Replies
LEARN ABOUT REDHAT
curl_getdate
curl_getdate(3) libcurl Manual curl_getdate(3)NAME
curl_getdate - Convert an date in a ASCII string to number of seconds since January 1, 1970
SYNOPSIS
#include <curl/curl.h>
time_t curl_getdate(char *datestring, time_t *now");
DESCRIPTION
This function returns the number of seconds since January 1st 1970, for the date and time that the datestring parameter specifies. The now
parameter is there and should hold the current time to allow the datestring to specify relative dates/times. Read further in the date
string parser section below.
PARSING DATES AND TIMES
A "date" is a string, possibly empty, containing many items separated by whitespace. The whitespace may be omitted when no ambiguity
arises. The empty string means the beginning of today (i.e., midnight). Order of the items is immaterial. A date string may contain many
flavors of items:
calendar date items
This can be specified in a number of different ways. Including 1970-09-17, 70-9-17, 70-09-17, 9/17/72, 24 September 1972, 24 Sept
72, 24 Sep 72, Sep 24, 1972, 24-sep-72, 24sep72. The year can also be omitted, for example: 9/17 or "sep 17".
time of the day items
This string specifies the time on a given day. Syntax supported includes: 18:19:0, 18:19, 6:19pm, 18:19-0500 (for specifying the
time zone as well).
time zone items
Specifies international time zone. There are a few acronyms supported, but in general you should instead use the specific realtive
time compared to UTC. Supported formats include: -1200, MST, +0100.
day of the week items
Specifies a day of the week. If this is mentioned alone it means that day of the week in the future.
Days of the week may be spelled out in full: `Sunday', `Monday', etc or they may be abbreviated to their first three letters,
optionally followed by a period. The special abbreviations `Tues' for `Tuesday', `Wednes' for `Wednesday' and `Thur' or `Thurs'
for `Thursday' are also allowed.
A number may precede a day of the week item to move forward supplementary weeks. It is best used in expression like `third mon-
day'. In this context, `last DAY' or `next DAY' is also acceptable; they move one week before or after the day that DAY by itself
would represent.
relative items
A relative item adjusts a date (or the current date if none) forward or backward. Example syntax includes: "1 year", "1 year ago",
"2 days", "4 weeks".
The string `tomorrow' is worth one day in the future (equivalent to `day'), the string `yesterday' is worth one day in the past
(equivalent to `day ago').
pure numbers
If the decimal number is of the form YYYYMMDD and no other calendar date item appears before it in the date string, then YYYY is
read as the year, MM as the month number and DD as the day of the month, for the specified calendar date.
RETURN VALUE
This function returns zero when it fails to parse the date string. Otherwise it returns the number of seconds as described.
AUTHORS
Originally written by Steven M. Bellovin <smb@research.att.com> while at the University of North Carolina at Chapel Hill. Later tweaked by
a couple of people on Usenet. Completely overhauled by Rich $alz <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
SEE ALSO BUGS
Surely there are some, you tell me!
libcurl 7.0 5 March 2001 curl_getdate(3)