Split file into multiple file using awk, but in date format

后端 未结 2 1278
感情败类
感情败类 2021-01-16 17:31

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\",\" \'N         


        
相关标签:
2条回答
  • 2021-01-16 18:08

    @FARAH: Try:

    awk -v DATE=$(date +%d%m%Y) -F"," 'NR>1 { print > "Test_" DATE ".CSV_"$1".csv"}'   Input_file
    

    As there is lack of information about samples and expected output so seeing that your command needs to some fine tuned, try above and let us know if this helps.

    0 讨论(0)
  • 2021-01-16 18:09

    this should work

    awk -F, -v date=$(date +%d%m%Y) 'NR>1{print > "Test_"date".CSV_"$1".csv"}' file
    

    if not, try first

    awk -v date=$(date +%d%m%Y) 'BEGIN{print date}'
    

    to check whether date is correctly set as an awk variable.

    0 讨论(0)
提交回复
热议问题