Hello,
There are directories named by "yyyyMMdd" format. The one directory name is given and I should find & print that directory & its previous days directory names if exist.
For example:
20080401
20080402
20080403
20080404
...
The given date: 20080403
The result:
20080403
20080401
20080402
Thanks in advance
Sounds like homework. Read the TOS.
If it's not homework, care to elaborate?
Hi,
If you have all the dates in a file called dates1 , then
awk ' $1 <= 20080403 ' dates1
20080401
20080402
20080403
Thanks penchal_boddu,
I could do it by writing few lines of code, but I wanted to do it in one line. I wrote by the following way, it works, except for new line & space character. How can I remove new line & space characters?
Thanks a lot
[testuser@localhost proc]$ find -type d
.
./20080401
./20080405
./20080404
./20080414
./20080423
./20080413
./20080415
./20080420
./20080406
./20080417
./20080418
./20080419
./20080410
./20080407
./20080412
./20080403
./20080416
./20080411
./20080408
./20080402
./20080409
[testuser@localhost proc]$ find -type d | sed "s#^.# #" | sed "s#/# #" | sort -k1 -u | awk '$1<=20080403'
20080401
20080402
20080403
Thanks all,
I found out it.
[testuser@localhost proc]$ find -type d | sed "s#^.##" | sed "s#/##" | sed '/^$/d' | sort -k1 -u | awk '$1<=20080403'
20080401
20080402
20080403