I am getting following lines as an output of some bash pipe
output
20200604_tsv
20200605_tsv
20200606_tsv
20200706_tsv
I have a date variable in YYYYMMDD format in a variable
filter_date="20200605"
I want to apply the date operation on the output lines i.e. pick lines only where line's first part (before '_') is less than equal to filter_date.
i.e. Expected output
20200604_tsv
20200605_tsv
How to achieve this filtering in bash pipe?
I have tried following (lexicographically match the string) but not able to filter and get original names.
BASH_CMD_THAT_OUTPUT_LINES | sort | awk '{name = ($1); print name <= "20200605*"}'
## Answer
1
0
0
0