1 |
Andrew Gaydenko schrieb: |
2 |
> ======= On Monday 31 March 2008, Etaoin Shrdlu wrote: ======= |
3 |
> |
4 |
>> On Monday 31 March 2008, 11:31, Andrew Gaydenko wrote: |
5 |
>> |
6 |
>>> I agree, my English is ugly. I'll try to explain. Saying "viewer" I |
7 |
>>> mean something like this: |
8 |
>>> |
9 |
>>> logviewer kdelibs |
10 |
>>> |
11 |
>>> will "produce" the same output as, say, |
12 |
>>> |
13 |
>>> less /usr/portage/kde-base/kdelibs/ChangeLog |
14 |
>>> |
15 |
>>> You see, it is impossible to remember all packages' dirs. Of |
16 |
>>> course, I can use 'q' or 'eix' to find a dir and then type in a |
17 |
>>> long 'less ...' command. But, well, why do all these 'eix' and 'q' |
18 |
>>> exist? I think to save some users' time. Is my intention more clear |
19 |
>>> now? :-) |
20 |
>>> |
21 |
>> Neil will surely provide an adequate answer, however, if your needs |
22 |
>> aren't too sophisticated, you could put together something like |
23 |
>> |
24 |
>> $ cat logviewer.sh |
25 |
>> #!/bin/bash |
26 |
>> |
27 |
>> if [ -z "$1" ]; then |
28 |
>> echo "Must specify package name!" >&2 |
29 |
>> exit 1 |
30 |
>> fi |
31 |
>> |
32 |
>> p=`eix --only-names -e "$1"` |
33 |
>> |
34 |
>> if [ -z "$p" ]; then |
35 |
>> echo "$1: No matches found" >&2 |
36 |
>> exit 1 |
37 |
>> else |
38 |
>> howmany=`echo "$p" | wc -l` |
39 |
>> if [ "$howmany" -gt 1 ]; then |
40 |
>> echo "Many packages with the same name, refine search string:" |
41 |
>> |
42 |
>>> &2 echo "$p" >&2 |
43 |
>>> |
44 |
>> exit 1 |
45 |
>> fi |
46 |
>> fi |
47 |
>> |
48 |
>> c="/usr/portage/${p}/ChangeLog" |
49 |
>> |
50 |
>> if [ -z "$EDITOR" ]; then |
51 |
>> EDITOR=`which vi` |
52 |
>> fi |
53 |
>> |
54 |
>> "$EDITOR" "$c" |
55 |
>> --------- |
56 |
>> |
57 |
>> You can also remove the "-e" from the eix line if you want |
58 |
>> approximate matching (that will require you to specify the category |
59 |
>> almost always though). |
60 |
>> Hope this helps. |
61 |
>> |
62 |
> |
63 |
> Thanks! I definitely must read a bash documentaton :-) |
64 |
> |
65 |
I think this will be your friend: |
66 |
|
67 |
http://tldp.org/LDP/abs/html/ |