Timeline for Shell script to filter date alone from a particular column of a .csv file and save the output in another csv file
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 5, 2021 at 13:34 | comment | added | RomanPerekhrest | @Novice_Techie, In that case, you would need to 1) set the current date in correspondent format into variable -v d=<current date>; 2) split the 6th field by space to get the date part only; 3) compare the dates. Check the following topic stackoverflow.com/a/39948321/3185459 | |
| Jan 4, 2021 at 20:32 | comment | added | Novice_Techie | I know this thread is old, but what if the filter condition needs to be changed like filter rows which are 12 months older than current date | |
| Oct 11, 2017 at 18:34 | vote | accept | user8554534 | ||
| Oct 11, 2017 at 18:31 | comment | added | RomanPerekhrest | @user8554534, see my additional approach | |
| Oct 11, 2017 at 18:30 | history | edited | RomanPerekhrest | CC BY-SA 3.0 | added 129 characters in body |
| Oct 11, 2017 at 18:28 | comment | added | RomanPerekhrest | don't use date as a variable name. It's a built-in function name | |
| Oct 11, 2017 at 18:27 | comment | added | user8554534 | Like date="7/20/2017" Command should be like awk -F, -v $date '$6~date' input.csv > dates.csv | |
| Oct 11, 2017 at 18:24 | comment | added | user8554534 | thanks a lot...it works. !!! Also can you share me the awk command if the date input is given in a variable like date="7/20/2017" | |
| Oct 11, 2017 at 18:21 | comment | added | RomanPerekhrest | @user8554534, ok, it's even shorter | |
| Oct 11, 2017 at 18:20 | history | edited | RomanPerekhrest | CC BY-SA 3.0 | added 46 characters in body |
| Oct 11, 2017 at 18:20 | comment | added | user8554534 | the matching column's entire row should be moved to dates.csv. Like if i give input 7/20/2017 then output 23,54,one,tree,56,7/20/2017 17:00,23,iii,89 23,54,one,tree,56,7/20/2017 17:00,23,iii,89 should be saved in dates.csv file | |
| Oct 11, 2017 at 18:15 | history | answered | RomanPerekhrest | CC BY-SA 3.0 |