This is a discussion on Triming a filename? within the Shell scripting forums, part of the Development/Scripting category; Great website guys! Here is my problem - I've been trying to list all of the files in a bin ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Great website guys! Here is my problem - I've been trying to list all of the files in a bin directory along with their short description. Here is the command sequence I'm entering...
cd /bin find -name '*' -exec man -f {} \; Output are lines like this one: ./arch: nothing appropriate. But the list doesn't contain the descriptions. I think the problem is related to the leading "./". If this is so, how can I modify the command to remove the leading "./" before it is fed to the "man -f" command? (I looked at "cut" and "awk", but they seem to be useful for data within files.) Please help. Thank you for a great site! - LW |
| Sponsored Links | ||
|
|
|
|||
|
I'm a little closer to a solution, but haven't yet figured out how to combine the two commands. Here is what I have so far...
echo './test' | sed -e 's/\.\///' Output: test Now, if I can only properly combine this with the "man -f" in the "find" command (above). |
|
|||
|
Still a little closer as this command lists all of the filenames that I want...
find -name '*' | sed -e 's/\.\///' | sort But I just can't pass this output to the "man -f" command so as to list the short descriptions as well. Argggg!! Of course, I can simplify it further to be... ls | sed -e 's/\.\///' | sort To obtain the same output of filenames, but I'm still stumped as to passing the output to "man -f". |
|
||||
|
Well I'm late to party :P here is simple and clean code:
Code:
for f in $(ls /bin/*); do man -f $(basename $f); done
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
|
|||
|
Quote:
- LW |