Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I come up with a solution to this problem,write a piece of script call readme who internal call the less with the current directory readme-alike txt file.

Is there any software to do so?I do not want to reinvent the wheel.

thanks.

share|improve this question
1  
The effort sounds so short that it would not matter if you write it from scratch. –  nik Nov 4 '09 at 10:13
    
Sorry for that,so you could think I'm just looking for that script. –  Jichao Nov 4 '09 at 10:26
add comment

1 Answer 1

up vote 1 down vote accepted

Do you mean you want to not have to know the filename specifically to open any given, case-insensitive 'readme' files?

Something like this perhaps (but it will fail on filenames with spaces):

alias readme='ls -1 | grep -i read | grep -i me | xargs less'

From @~Quack's comment, if you want to handle spaces, too:

alias readme='find . -maxdepth 1 -iname '*read*me*' -print0 | xargs -0 less'
share|improve this answer
1  
i think this will work for "README" "readme" and "read_me" but break on "Read Me". maybe find . -maxdepth 1 -iname '*read*me*' -print0 | xargs -0 less –  quack quixote Nov 4 '09 at 10:33
    
and it may not get newlines properly - depends on how ls formats.. –  warren Nov 4 '09 at 12:08
    
you're right, if it has a space it doesn't work –  warren Nov 4 '09 at 12:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.