The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-23-2008
Registered User
 

Join Date: Jan 2007
Location: UB, Mongolia
Posts: 31
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
Thanks in advance
Reply With Quote
Forum Sponsor
  #2  
Old 04-24-2008
Dave Miller's Avatar
Registered User
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 150
Sounds like homework. Read the TOS.

If it's not homework, care to elaborate?
Reply With Quote
  #3  
Old 04-24-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 123
Hi,

If you have all the dates in a file called dates1 , then

awk ' $1 <= 20080403 ' dates1

20080401
20080402
20080403
Reply With Quote
  #4  
Old 04-24-2008
Registered User
 

Join Date: Jan 2007
Location: UB, Mongolia
Posts: 31
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
Reply With Quote
  #5  
Old 04-24-2008
Registered User
 

Join Date: Jan 2007
Location: UB, Mongolia
Posts: 31
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0