How to add date in the last column in csv file in Unix? [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I have to add date values in last columns in the csv file in Unix
how to do that ?
text-processing csv
closed as unclear what you're asking by G-Man, Kusalananda, Isaac, Jeff Schaller, ñÃÂsýù÷ May 29 at 14:38
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |Â
up vote
-1
down vote
favorite
I have to add date values in last columns in the csv file in Unix
how to do that ?
text-processing csv
closed as unclear what you're asking by G-Man, Kusalananda, Isaac, Jeff Schaller, ñÃÂsýù÷ May 29 at 14:38
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Do you want to append them to the last column, or do you want to add them as new columns at the end of each line? What dates do you want to add? Do you want multiple dates on each line or just a single date per line?
â Kusalananda
May 29 at 5:24
@Kusalananda new columns at the end of each line.. because thats what a column is. Otherwise it'd be a row.
â jdwolf
May 29 at 5:39
1
@jdwolf No. There's a difference between changing1,2,3
into1,2,3-20180529
("adding a date to the last column") and changing it into1,2,3,20180529
("adding a new column with a date"). I asked since the interpretation of "adding dates in the last column" is clearly ambiguous. Also "adding dates" could mean adding multiple dates to each record. It's unclear what is meant, and what dates should be added (today's date, or depending on some files' timestamp, or depending on some other data in the file, or incrementing by one day throughout the file starting at some particular date).
â Kusalananda
May 29 at 5:44
@Kusalananda Agreed on all your points pretty much. I just like how you've worded it now is much clearly on what the OP needs to specify~ ty.
â jdwolf
May 29 at 6:27
@aakansha please do edit and update your question to clarify what exactly you want your file be by providing a fragmented input/output samples.
â Ã±ÃÂsýù÷
May 29 at 7:29
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have to add date values in last columns in the csv file in Unix
how to do that ?
text-processing csv
I have to add date values in last columns in the csv file in Unix
how to do that ?
text-processing csv
edited May 29 at 5:18
ñÃÂsýù÷
14.7k82361
14.7k82361
asked May 29 at 4:55
aakansha
1
1
closed as unclear what you're asking by G-Man, Kusalananda, Isaac, Jeff Schaller, ñÃÂsýù÷ May 29 at 14:38
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by G-Man, Kusalananda, Isaac, Jeff Schaller, ñÃÂsýù÷ May 29 at 14:38
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Do you want to append them to the last column, or do you want to add them as new columns at the end of each line? What dates do you want to add? Do you want multiple dates on each line or just a single date per line?
â Kusalananda
May 29 at 5:24
@Kusalananda new columns at the end of each line.. because thats what a column is. Otherwise it'd be a row.
â jdwolf
May 29 at 5:39
1
@jdwolf No. There's a difference between changing1,2,3
into1,2,3-20180529
("adding a date to the last column") and changing it into1,2,3,20180529
("adding a new column with a date"). I asked since the interpretation of "adding dates in the last column" is clearly ambiguous. Also "adding dates" could mean adding multiple dates to each record. It's unclear what is meant, and what dates should be added (today's date, or depending on some files' timestamp, or depending on some other data in the file, or incrementing by one day throughout the file starting at some particular date).
â Kusalananda
May 29 at 5:44
@Kusalananda Agreed on all your points pretty much. I just like how you've worded it now is much clearly on what the OP needs to specify~ ty.
â jdwolf
May 29 at 6:27
@aakansha please do edit and update your question to clarify what exactly you want your file be by providing a fragmented input/output samples.
â Ã±ÃÂsýù÷
May 29 at 7:29
add a comment |Â
Do you want to append them to the last column, or do you want to add them as new columns at the end of each line? What dates do you want to add? Do you want multiple dates on each line or just a single date per line?
â Kusalananda
May 29 at 5:24
@Kusalananda new columns at the end of each line.. because thats what a column is. Otherwise it'd be a row.
â jdwolf
May 29 at 5:39
1
@jdwolf No. There's a difference between changing1,2,3
into1,2,3-20180529
("adding a date to the last column") and changing it into1,2,3,20180529
("adding a new column with a date"). I asked since the interpretation of "adding dates in the last column" is clearly ambiguous. Also "adding dates" could mean adding multiple dates to each record. It's unclear what is meant, and what dates should be added (today's date, or depending on some files' timestamp, or depending on some other data in the file, or incrementing by one day throughout the file starting at some particular date).
â Kusalananda
May 29 at 5:44
@Kusalananda Agreed on all your points pretty much. I just like how you've worded it now is much clearly on what the OP needs to specify~ ty.
â jdwolf
May 29 at 6:27
@aakansha please do edit and update your question to clarify what exactly you want your file be by providing a fragmented input/output samples.
â Ã±ÃÂsýù÷
May 29 at 7:29
Do you want to append them to the last column, or do you want to add them as new columns at the end of each line? What dates do you want to add? Do you want multiple dates on each line or just a single date per line?
â Kusalananda
May 29 at 5:24
Do you want to append them to the last column, or do you want to add them as new columns at the end of each line? What dates do you want to add? Do you want multiple dates on each line or just a single date per line?
â Kusalananda
May 29 at 5:24
@Kusalananda new columns at the end of each line.. because thats what a column is. Otherwise it'd be a row.
â jdwolf
May 29 at 5:39
@Kusalananda new columns at the end of each line.. because thats what a column is. Otherwise it'd be a row.
â jdwolf
May 29 at 5:39
1
1
@jdwolf No. There's a difference between changing
1,2,3
into 1,2,3-20180529
("adding a date to the last column") and changing it into 1,2,3,20180529
("adding a new column with a date"). I asked since the interpretation of "adding dates in the last column" is clearly ambiguous. Also "adding dates" could mean adding multiple dates to each record. It's unclear what is meant, and what dates should be added (today's date, or depending on some files' timestamp, or depending on some other data in the file, or incrementing by one day throughout the file starting at some particular date).â Kusalananda
May 29 at 5:44
@jdwolf No. There's a difference between changing
1,2,3
into 1,2,3-20180529
("adding a date to the last column") and changing it into 1,2,3,20180529
("adding a new column with a date"). I asked since the interpretation of "adding dates in the last column" is clearly ambiguous. Also "adding dates" could mean adding multiple dates to each record. It's unclear what is meant, and what dates should be added (today's date, or depending on some files' timestamp, or depending on some other data in the file, or incrementing by one day throughout the file starting at some particular date).â Kusalananda
May 29 at 5:44
@Kusalananda Agreed on all your points pretty much. I just like how you've worded it now is much clearly on what the OP needs to specify~ ty.
â jdwolf
May 29 at 6:27
@Kusalananda Agreed on all your points pretty much. I just like how you've worded it now is much clearly on what the OP needs to specify~ ty.
â jdwolf
May 29 at 6:27
@aakansha please do edit and update your question to clarify what exactly you want your file be by providing a fragmented input/output samples.
â Ã±ÃÂsýù÷
May 29 at 7:29
@aakansha please do edit and update your question to clarify what exactly you want your file be by providing a fragmented input/output samples.
â Ã±ÃÂsýù÷
May 29 at 7:29
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
Simply use sed
:
sed "s/$/,$(date)/" infile.csv
With formatting:
sed "s/$/,$(date +'%F %T')/" infile
- the
$
ins/$/.../
is pointing anchor to the end of line. - we used double-quotes to expand the command-substitution
$(...)
output. - this adds date as a new column. remove comma
,
before,$(...)
to append to the last column. use
-i
option of sed to in-place change in file itself or take a backup in addition:sed -i.bak "s/$/,$(date +'%F %T')/" infile
see for more formatting options in man date
under "FORMAT controls" section.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Simply use sed
:
sed "s/$/,$(date)/" infile.csv
With formatting:
sed "s/$/,$(date +'%F %T')/" infile
- the
$
ins/$/.../
is pointing anchor to the end of line. - we used double-quotes to expand the command-substitution
$(...)
output. - this adds date as a new column. remove comma
,
before,$(...)
to append to the last column. use
-i
option of sed to in-place change in file itself or take a backup in addition:sed -i.bak "s/$/,$(date +'%F %T')/" infile
see for more formatting options in man date
under "FORMAT controls" section.
add a comment |Â
up vote
1
down vote
Simply use sed
:
sed "s/$/,$(date)/" infile.csv
With formatting:
sed "s/$/,$(date +'%F %T')/" infile
- the
$
ins/$/.../
is pointing anchor to the end of line. - we used double-quotes to expand the command-substitution
$(...)
output. - this adds date as a new column. remove comma
,
before,$(...)
to append to the last column. use
-i
option of sed to in-place change in file itself or take a backup in addition:sed -i.bak "s/$/,$(date +'%F %T')/" infile
see for more formatting options in man date
under "FORMAT controls" section.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Simply use sed
:
sed "s/$/,$(date)/" infile.csv
With formatting:
sed "s/$/,$(date +'%F %T')/" infile
- the
$
ins/$/.../
is pointing anchor to the end of line. - we used double-quotes to expand the command-substitution
$(...)
output. - this adds date as a new column. remove comma
,
before,$(...)
to append to the last column. use
-i
option of sed to in-place change in file itself or take a backup in addition:sed -i.bak "s/$/,$(date +'%F %T')/" infile
see for more formatting options in man date
under "FORMAT controls" section.
Simply use sed
:
sed "s/$/,$(date)/" infile.csv
With formatting:
sed "s/$/,$(date +'%F %T')/" infile
- the
$
ins/$/.../
is pointing anchor to the end of line. - we used double-quotes to expand the command-substitution
$(...)
output. - this adds date as a new column. remove comma
,
before,$(...)
to append to the last column. use
-i
option of sed to in-place change in file itself or take a backup in addition:sed -i.bak "s/$/,$(date +'%F %T')/" infile
see for more formatting options in man date
under "FORMAT controls" section.
edited May 29 at 5:51
answered May 29 at 5:03
ñÃÂsýù÷
14.7k82361
14.7k82361
add a comment |Â
add a comment |Â
Do you want to append them to the last column, or do you want to add them as new columns at the end of each line? What dates do you want to add? Do you want multiple dates on each line or just a single date per line?
â Kusalananda
May 29 at 5:24
@Kusalananda new columns at the end of each line.. because thats what a column is. Otherwise it'd be a row.
â jdwolf
May 29 at 5:39
1
@jdwolf No. There's a difference between changing
1,2,3
into1,2,3-20180529
("adding a date to the last column") and changing it into1,2,3,20180529
("adding a new column with a date"). I asked since the interpretation of "adding dates in the last column" is clearly ambiguous. Also "adding dates" could mean adding multiple dates to each record. It's unclear what is meant, and what dates should be added (today's date, or depending on some files' timestamp, or depending on some other data in the file, or incrementing by one day throughout the file starting at some particular date).â Kusalananda
May 29 at 5:44
@Kusalananda Agreed on all your points pretty much. I just like how you've worded it now is much clearly on what the OP needs to specify~ ty.
â jdwolf
May 29 at 6:27
@aakansha please do edit and update your question to clarify what exactly you want your file be by providing a fragmented input/output samples.
â Ã±ÃÂsýù÷
May 29 at 7:29