Push-Nachrichten von MacTechNews.de
Würden Sie gerne aktuelle Nachrichten aus der Apple-Welt direkt über Push-Nachrichten erhalten?
Forum>Entwickler>whatis command - zu viel Text

whatis command - zu viel Text

marm08.03.2310:41
In der Diskussion zu Mac-Terminal tauchte das whatis-Kommando auf, um eine Beschreibung von Befehlen zu erhalten.
for i in $(ls /bin /usr/bin /usr/sbin); do whatis "$i"; done | uniq  
Als ich das damals eingab, bekam ich eine hilfreiche Liste. Mittlerweile ist dort viel zu viel Text.
Laut IBM-Seite ergibt
whatis ls
das Ergebnis
ls(1)  -Displays the contents of a directory.
Bei mir ist das
git-ls-files(1)          - Show information about files in the index and the working tree
git-ls-remote(1)         - List references in a remote repository
git-ls-tree(1)           - List the contents of a tree object
git-mktree(1)            - Build a tree-object from ls-tree formatted text
gdircolors(1), dircolors(1) - color setup for ls
gls(1), ls(1)            - list directory contents
npm-ls(1)                - List installed packages
builtin(1), !(1), %(1), .(1), :(1), @(1), [(1), {(1), }(1), alias(1), alloc(1), bg(1), bind(1), bindkey(1), break(1), breaksw(1), builtins(1), case(1), cd(1), chdir(1), command(1), complete(1), continue(1), default(1), dirs(1), do(1), done(1), echo(1), echotc(1), elif(1), else(1), end(1), endif(1), endsw(1), esac(1), eval(1), exec(1), exit(1), export(1), false(1), fc(1), fg(1), filetest(1), fi(1), for(1), foreach(1), getopts(1), glob(1), goto(1), hash(1), hashstat(1), history(1), hup(1), if(1), jobid(1), jobs(1), kill(1), limit(1), local(1), log(1), login(1), logout(1), ls-F(1), nice(1), nohup(1), notify(1), onintr(1), popd(1), printenv(1), printf(1), pushd(1), pwd(1), read(1), readonly(1), rehash(1), repeat(1), return(1), sched(1), set(1), setenv(1), settc(1), setty(1), setvar(1), shift(1), source(1), stop(1), suspend(1), switch(1), telltc(1), test(1), then(1), time(1), times(1), trap(1), true(1), type(1), ulimit(1), umask(1), unalias(1), uncomplete(1), unhash(1), unlimit(1), unset(1), unsetenv(1), until(1), wait(1), where(1), which(1), while(1) - shell built-in commands
ls(1)                    - list directory contents
DateTime::Locale::en_LS(3pm) - Locale data examples for the English Lesotho (en-LS) locale
builtin(1), !(1), %(1), .(1), :(1), @(1), [(1), {(1), }(1), alias(1), alloc(1), bg(1), bind(1), bindkey(1), break(1), breaksw(1), builtins(1), case(1), cd(1), chdir(1), command(1), complete(1), continue(1), default(1), dirs(1), do(1), done(1), echo(1), echotc(1), elif(1), else(1), end(1), endif(1), endsw(1), esac(1), eval(1), exec(1), exit(1), export(1), false(1), fc(1), fg(1), filetest(1), fi(1), for(1), foreach(1), getopts(1), glob(1), goto(1), hash(1), hashstat(1), history(1), hup(1), if(1), jobid(1), jobs(1), kill(1), limit(1), local(1), log(1), login(1), logout(1), ls-F(1), nice(1), nohup(1), notify(1), onintr(1), popd(1), printenv(1), printf(1), pushd(1), pwd(1), read(1), readonly(1), rehash(1), repeat(1), return(1), sched(1), set(1), setenv(1), settc(1), setty(1), setvar(1), shift(1), source(1), stop(1), suspend(1), switch(1), telltc(1), test(1), then(1), time(1), times(1), trap(1), true(1), type(1), ulimit(1), umask(1), unalias(1), uncomplete(1), unhash(1), unlimit(1), unset(1), unsetenv(1), until(1), wait(1), where(1), which(1), while(1) - shell built-in commands
ls(1)                    - list directory contents

Was ist da auf meinem Mac nicht in Ordnung? Wie bekomme ich die schlanken Ergebnisse? Whatis durchsucht auch die Beschreibungen zu den Kommandos statt nur die Namen der Kommandos.
0

Kommentare

micheee08.03.2311:21
Hi marm,
mit deinem Mac ist alles in Ordnung

Die man-Datenbank wird von den Tools selbst gefüttert, das heißt, wenn du jetzt z.B. Tools installiert hast, die unter dem Stichwort `date` Informationen zurückliefern, dann kann die Liste recht lang werden.

Dein kleines Snippet macht ja Folgendes:

Es listet die Dateien im Ordner `/bin /usr/bin /usr/sbin` auf.
Für jedes $i aus Dateien ruft es dann "whatis $i" auf — wenn du jetzt z.B. ein $i namens "date" hast, dann sucht er im Manual nach dem Stichwort "date" und deswegen kommt eine lange Liste raus.

Was du vielleicht relativ leicht ändern kannst ist, nur in Sektion 1 ("General Commands"), mit -s 1, zu suchen:

for i in $(ls /bin /usr/bin /usr/sbin); do echo "$i": $(whatis -s 1 "$i"); done

Oder wenn du es etwas netter haben willst:

for i in $(ls /bin /usr/bin /usr/sbin); do echo "$i":  $(man "$i" | col -bx | awk '/^NAME/{getline; print; exit}' | head -n 1); done

Ist bisschen hacky, ruft die manpage für den Befehl auf, sucht also nicht nach dem Stichwort, und gibt dir die erste Zeile nach "NAME" aus:

No manual entry for /bin:
/bin::
[: test, [ – condition evaluation utility
bash: bash - GNU Bourne-Again SHell
cat: cat – concatenate and print files
chmod: chmod – change file modes or Access Control Lists
cp: cp – copy files
csh: tcsh - C shell with file name completion and command line editing
dash: dash – command interpreter (shell)
date: date – display or set date and time
dd: dd – convert and copy a file
df: df – display free disk space
echo: echo – write arguments to the standard output
ed: ed, red – text editor
+1
marm08.03.2311:22
Als Hinweis würde mir schon helfen, was bei Euch das Ergebnis von
whatis ls
ist.
Bei mir läuft übrigens aktuelles Ventura.
0
Marcel Bresink08.03.2311:30
Da kommt bei Jedem, der macOS Ventura nutzt, das Gleiche raus, nämlich das, was Du oben aufgeführt hast.

Was Du von IBM zitierst, gilt nur für das Betriebssystem AIX 7.1.
+3
micheee08.03.2311:33
Das kommt bei mir raus...
bash-3.2$ whatis ls
exa(1)                   - [em] a modern replacement for ls
git-lfs-ls-files(1)      - Show information about Git LFS files in the index and working tree
npm-ls(1)                - List installed packages
builtin(1), !(1), %(1), .(1), :(1), @(1), [(1), {(1), }(1), alias(1), alloc(1), bg(1), bind(1), bindkey(1), break(1), breaksw(1), builtins(1), case(1), cd(1), chdir(1), command(1), complete(1), continue(1), default(1), dirs(1), do(1), done(1), echo(1), echotc(1), elif(1), else(1), end(1), endif(1), endsw(1), esac(1), eval(1), exec(1), exit(1), export(1), false(1), fc(1), fg(1), filetest(1), fi(1), for(1), foreach(1), getopts(1), glob(1), goto(1), hash(1), hashstat(1), history(1), hup(1), if(1), jobid(1), jobs(1), kill(1), limit(1), local(1), log(1), login(1), logout(1), ls-F(1), nice(1), nohup(1), notify(1), onintr(1), popd(1), printenv(1), printf(1), pushd(1), pwd(1), read(1), readonly(1), rehash(1), repeat(1), return(1), sched(1), set(1), setenv(1), settc(1), setty(1), setvar(1), shift(1), source(1), stop(1), suspend(1), switch(1), telltc(1), test(1), then(1), time(1), times(1), trap(1), true(1), type(1), ulimit(1), umask(1), unalias(1), uncomplete(1), unhash(1), unlimit(1), unset(1), unsetenv(1), until(1), wait(1), where(1), which(1), while(1) - shell built-in commands
ls(1)                    - list directory contents
DateTime::Locale::en_LS(3pm) - Locale data examples for the English Lesotho (en-LS) locale
builtin(1), !(1), %(1), .(1), :(1), @(1), [(1), {(1), }(1), alias(1), alloc(1), bg(1), bind(1), bindkey(1), break(1), breaksw(1), builtins(1), case(1), cd(1), chdir(1), command(1), complete(1), continue(1), default(1), dirs(1), do(1), done(1), echo(1), echotc(1), elif(1), else(1), end(1), endif(1), endsw(1), esac(1), eval(1), exec(1), exit(1), export(1), false(1), fc(1), fg(1), filetest(1), fi(1), for(1), foreach(1), getopts(1), glob(1), goto(1), hash(1), hashstat(1), history(1), hup(1), if(1), jobid(1), jobs(1), kill(1), limit(1), local(1), log(1), login(1), logout(1), ls-F(1), nice(1), nohup(1), notify(1), onintr(1), popd(1), printenv(1), printf(1), pushd(1), pwd(1), read(1), readonly(1), rehash(1), repeat(1), return(1), sched(1), set(1), setenv(1), settc(1), setty(1), setvar(1), shift(1), source(1), stop(1), suspend(1), switch(1), telltc(1), test(1), then(1), time(1), times(1), trap(1), true(1), type(1), ulimit(1), umask(1), unalias(1), uncomplete(1), unhash(1), unlimit(1), unset(1), unsetenv(1), until(1), wait(1), where(1), which(1), while(1) - shell built-in commands
ls(1)                    - list directory contents
git-ls-files(1)          - Show information about files in the index and the working tree
git-ls-remote(1)         - List references in a remote repository
git-ls-tree(1)           - List the contents of a tree object
git-mktree(1)            - Build a tree-object from ls-tree formatted text
bash-3.2$
Aber wie Marcel schon geschrieben hat, der größte Teil sollte identisch sein.
0
marm08.03.2311:47
Vielen Dank für Eure Rückmeldung!
micheee
Noch ergibt "-s 1" bei mir auch zu viel Text. Aber das schaue ich mir mal genauer an, wenn ich etwas mehr Zeit habe.
0
micheee08.03.2311:51
marm
Vielen Dank für Eure Rückmeldung!
micheee
Noch ergibt "-s 1" bei mir auch zu viel Text. Aber das schaue ich mir mal genauer an, wenn ich etwas mehr Zeit habe.

ich würde Dir direkt mein zweites Snippet empfehlen, ich denke, das ist näher am gewünschten Ergebnis
0
marm08.03.2311:54
micheee
ich würde Dir direkt mein zweites Snippet empfehlen, ich denke, das ist näher am gewünschten Ergebnis
Da rattert bei mir leider eine endlose Liste von
Unknown locale, assuming C
filtercalltree: filtercalltree – Filter or prune a call tree file generated by sample or
Unknown locale, assuming C
find: find – walk a file hierarchy
Unknown locale, assuming C
findrule: findrule - command line wrapper to File::Find::Rule
Unknown locale, assuming C
findrule5.30: findrule - command line wrapper to File::Find::Rule
Unknown locale, assuming C
finger: finger – user information lookup program
Unknown locale, assuming C
fixproc: fixproc - Fixes a process by performing the specified action.
Unknown locale, assuming C
flex: flex - the fast lexical analyser generator
Unknown locale, assuming C
flex++: flex - the fast lexical analyser generator
Daher muss ich mich mal reindenken, was Du hier gebaut hast, um das so zu korrigieren, dass es bei mir ebenfalls läuft.
0
micheee08.03.2312:20
Was für eine locale hast du denn gesetzt? Das Problem ist, dass dein Terminal nicht weiß, in welcher Lokalisierung deine Kommandos arbeiten. Vielleicht hilft dir das hier weiter:

https://apple.stackexchange.com/questions/451014/unknown-locale-assuming-c-error-message-in-terminal
+1
marm08.03.2312:27
micheee
Was für eine locale hast du denn gesetzt? Das Problem ist, dass dein Terminal nicht weiß, in welcher Lokalisierung deine Kommandos arbeiten. Vielleicht hilft dir das hier weiter:

https://apple.stackexchange.com/questions/451014/unknown-locale-assuming-c-error-message-in-terminal
Danke, der Hinweis "dein Terminal" war's. Ich hatte das mit Warp ausprobiert.
Mit iTerm2 funktioniert dein Snippet
Ziemlich hilfreich um mal zu wissen, was da mittlerweile alles in opt/homebrew/bin ist ...
+1
micheee08.03.2312:36
…top, mit warp sollte es auch klappen, wenn du die korrekte LANG setzt:

LANG="de_DE.UTF-8";  for i in $(ls /bin /usr/bin /usr/sbin); do echo "$i":  $(man "$i" | col -bx | awk '/^NAME/{getline; print; exit}' | head -n 1); done
+2
marm08.03.2312:55
micheee
…top, mit warp sollte es auch klappen, wenn du die korrekte LANG setzt:
Leider nicht. Gerade habe ich mal Internet, Settings und die Dokumentation von Warp durchsucht, wo ich die Lokalisierung einstellen kann. Noch bin ich nicht fündig geworden. In iTerm wird das Snippet wieder akzeptiert.
0
marm08.03.2313:09
Geschafft und wieder was gelernt.
Mit
export LANG="de_DE.UTF8"
kann ich die Lokalisierung setzen und nun läuft alles wie es soll auch in Warp
+1

Kommentieren

Diese Diskussion ist bereits mehr als 3 Monate alt und kann daher nicht mehr kommentiert werden.