![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare 2 files and output result in pop up window | hongsh | UNIX for Dummies Questions & Answers | 2 | 05-23-2008 06:50 AM |
| append a string to a grep result | melanie_pfefer | Shell Programming and Scripting | 8 | 03-19-2008 04:19 AM |
| String compare | sbasetty | Shell Programming and Scripting | 14 | 02-07-2007 02:24 AM |
| Compare Char to String | Phobos | High Level Programming | 3 | 04-09-2005 08:01 AM |
| string compare | gundu | Shell Programming and Scripting | 3 | 03-23-2005 01:42 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
While finding compare the result with given string
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. Code:
For example: 20080401 20080402 20080403 20080404 ... The given date: 20080403 The result: 20080403 20080401 20080402 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Sounds like homework. Read the TOS.
If it's not homework, care to elaborate? |
|
#3
|
|||
|
|||
|
Hi,
If you have all the dates in a file called dates1 , then awk ' $1 <= 20080403 ' dates1 20080401 20080402 20080403 |
|
#4
|
|||
|
|||
|
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 Code:
[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 |
|
#5
|
|||
|
|||
|
Thanks all,
I found out it. Code:
[testuser@localhost proc]$ find -type d | sed "s#^.##" | sed "s#/##" | sed '/^$/d' | sort -k1 -u | awk '$1<=20080403' 20080401 20080402 20080403 |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|