0

unix script to grep text with dates 30 days older than current date within a file and move to another file without having to manually input the current date should be the system date automatically in the format yy/mm/dd similar to $ awk '$NF <= "2018-05-01"' ip.txt

  • Unclear: "Move to another file"? Do you want to move the lines or do you want to move the file? Is the issue getting the current date on a particular format? Have you searched the site for similar questions (there are lots), for example the combination of these two Grep for dates older than 14 days in a file and Grep command to find files containing text string and move them – Kusalananda Dec 19 '18 at 8:06
  • I want to move the lines to another file but the commands available are form manually inputting the date want to do it automatically from the system current date minus 30 days – Kasiiku Mark Dec 19 '18 at 8:37
  • That is done differently depending on what date implementation you are using. With GNU date you could just do date -d '30 days ago'. Please update your questions with all information. Don't add information that is relevant to tho question in comments. – Kusalananda Dec 19 '18 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.