使用awk将文件拆分为多个文件,但采用日期格式 [英] Split file into multiple file using awk, but in date format
本文介绍了使用awk将文件拆分为多个文件,但采用日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将一个文件拆分为多个文件,然后以日期格式保存该文件.
I want to split a file into multiple files and save the file in date format.
为什么该命令不起作用?
Why doesn't this command work?
awk -v DATE= date '+%d%m%Y'-F"," 'NR>1 { print > "Test_" DATE ".CSV_"$1".csv"}' Testing.CSV
推荐答案
这应该有效
awk -F, -v date=$(date +%d%m%Y) 'NR>1{print > "Test_"date".CSV_"$1".csv"}' file
如果没有,请先尝试
awk -v date=$(date +%d%m%Y) 'BEGIN{print date}'
检查日期是否正确设置为awk
变量.
to check whether date is correctly set as an awk
variable.
这篇关于使用awk将文件拆分为多个文件,但采用日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文