小编san*_*a16的帖子

Transform an entire column using "date" command

Here is a dummy CSV file with 3 rows. The actual file has 7 million rows.

testdates.csv:

y_m_d
1997-01-01
1985-06-09
1943-07-14
Run Code Online (Sandbox Code Playgroud)

The date tool can usually be formatted as such , to get the 'day' :

date -d "25 JUN 2011" +%A
Run Code Online (Sandbox Code Playgroud)

=> output: Saturday

Query: How to provide an entire column as input for the date +%A transformation?

The resulting output should be appended to the end of the input file.

Intended output:

y_m_d, Day
1997-01-01, Thursday
1985-06-09, …
Run Code Online (Sandbox Code Playgroud)

linux bash awk date sed

1
推荐指数
1
解决办法
67
查看次数

标签 统计

awk ×1

bash ×1

date ×1

linux ×1

sed ×1