As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label manpage. Show all posts

I didnt know there is a /etc/services sitting there, just like I didnt know ascii(7) before.

It is a plain ASCII files, listing network services name, port number, protocol (TCP/UDP), aliases, and comments. The list includes well-known (port number 0 through 1023) IANAs Service Name and Transport Protocol Port Number Registry, registered ports (1024-49151), as well as dynamic and/or private ports (49152-65535) on my system.

You can simply grep it to query:

% grep '\b80\b' /etc/services
http            80/tcp          www www-http    # World Wide Web HTTP
http            80/udp          www www-http

Before I stumbled on whatportis which taught me about this file, I searched for the port number in search engine whenever I saw some strange incoming transmission on a port number that I didnt recognize.

According to services(5), C library routines, such as getservbyport(3), use the services list. They parse and utilize the results.

The content of the file varies by distributions and operating systems, but the source probably all is from IANAs list or just using another distribution as upstream source.

Ive noticed there is quite some online manpage websites, but every time when I needed to refer to a certain page, its hard to choose, because I had no idea which one would be reliable.

A manual page may have different sources, for example, the sed(1) on Linux and on *BSD, they are apparently from different sources. On GNU/Linux, it will be the GNU Sed; On *BSD, it will be the BSD version, so the contents will be different as well. Also, even Linux distributions may make small changes on special occasions, for instance, gcc(1) on Gentoo, there is a couple of notes added regarding the changes were made by Gentoo developers.

Some sites, I dont have a clue who is providing those pages, and definitely no idea if it would still be accessible tomorrow. I dont want to have a dead link if I can avoid.

Even some of them I dont fear they would disappear someday, but it doesnt seem to be enough for reference. I wish someone would create one not only having the versions, but also having the anchor to specific line like VCS repository web viewing, section anchor is just not enough.

The following is the list, I split them by the systems and different features, or the tables would look squashed.

tl;dr:

man ascii(7)
man console_codes(4)  # for ANSI escape code

I was looking around and stumbled on this man ascii and I was like dumbfounded, wondering how I could not have known about this.

Why? Because I searched for the Wikipedia pages for ASCII and ANSI escape code. Maybe rarely for ASCII character codes, but quite often for the escape codes whenever I was writing a shell script that would need to move cursor or clear screen, such as blocky.sh.

How I found console_codes, since it doesnt have ANSI nor escape in the title? I searched with [manpage ansi escape code] for a manual page and found that on the first hit. I couldnt believe that I used to go to Wikipedia for those codes, when they are already on my disk all along.

Its funny to think about there is nearly everything on the Internet, the knowledge is vast if you are willing to read, but you dont have to go out to the virtual world, there already is plenty for us to digest inside our computers.

Its like human on Earth, and the universe seems without edges if you consider our knowledge, engineering, and capabilities, but the facts are that we dont even learn a fraction of the planet we are living on, the truth is that we dont even know everything about ourselves, our human body.

From man man:
man foo | col -b > foo.mantxt
It doesn't work for me, this what I got:
1mNAME0m
       bash - GNU Bourne-Again SHell

1mSYNOPSIS0m
       1mbash 22m[options] [file]

\033[ were removed but the rest of escape code still there. I am not sure why those escape code were modified by col. Anyway, col is obvious not what I need.

I don't want escape code to emphasize text. I want a really plain text output. I tried to read more about man, groff, whatever in man's manpage... I wasn't sure how a manpage being generated.

The easiest workaround is to remove escape code by myself:
man bash | sed $'s/\033\[[^m]*m//g' > bash.txt
(It's still some non-printing chars in the output, run with cat -v)

I still need: setting text width of output or no wrapping.

Updated:  This would do ( echo ".ll 11.5i"; echo ".nr LL 11.5i"; echo ".pl 1100i"; /bin/bzip2 -c -d "/usr/share/man/man1/bash.1.bz2"; echo ".\\\""; echo ".pl \n(nlu+10" ) | /usr/bin/gtbl | /usr/bin/nroff -mandoc | sed $'s/\033\[[^m]*m//g' > bash.txt
. The numbers control the width, but I don't have any idea how to calculator them from text width I need.

Since Ive learned how to compile programs, I started to not make install them onto system directory or my home directory. I often run the compiled program from its source directory. The reason I do this way is because the Makefile may not be good or not even include uninstall action. I havent seen any couldnt be run from its compiling directory.

However, there is always one thing bothering me, the manual if they provide. I dont install, therefore no manual pages installed in man page searching path. I just figured out this way to get around:

% cd /path/to/source/mandir
% ln -s . man1 # Fake a section
% man -M . name_of_manpage

At first, I was proud of myself for being able to fool man. But the joy didnt last long, because I found its silly after I read the man(1)s SEARCH PATH FOR MANUAL PAGES. To man a local man file, you only need to give a path with the manpage filename:

% cd /path/to/source/mandir
% man ./name_of_manpage.1

Because

First of all, when the name argument to man contains a slash (/), man assumes it is a file specification itself, and there is no searching involved.

I just learned after years. Once again, there is a reason for saying RTFM!