

A veces la ejecución o compilación de algún programa en la terminal puede indicar que algún archivo de configuración tiene algún error. Supongamos este error como ejemplo:
usuario@sistema:~ $ email -s "asunto" -c ~/email/email.conf usuario@dominio.com
email: FATAL: Variable: '�d' is not valid
email: FATAL: email.conf: Format error: Line number 28Al intentar enviar un correo desde la terminal usando el comando anterior se observa en la última línea que dice Line number error 28, lo cual quiere decir que el archivo de configuración ~/email/email.conf tiene un error en dicha línea, así que debo revisar el archivo.
Se me ocurren varias opciones a partir de aquí:
a) abrir el archivo con un editor de texto, y después ir contando cada línea hasta llegar a la 28
b) abrir el archivo con un editor de texto y ver si este puede ennumerar líneas
c) abrir el archivo con vim , ESC, ESC, :28, Enter
d) abrir el archivo con nano , CTRL+W, CTRL+T, 28, Enter
Para mí la opción más usada es c) ya que uso vim con frecuencia.
Pero no siempre quiero entrar a modificar el archivo, a veces se me ocurre que puedo enviar mi archivo de configuración a algún foro en donde otras personas puedan ayudarme a detectar el conflicto. Si mi archivo de configuración es muy grande los lectores del estarán contando línea por línea hasta llegar a la número 28, o tendrán que copiar/pegar en algún editor de texto y hacer algo similar a lo que mencioné en los incisos b) y c). Esto será menos fácil si el archivo contiene decenas o cientos de líneas, por no decir miles.
Para ayudar a una fácil identificación de las líneas yo uso el comando nl (number lines). Dicho comando, al igual que cat y less, desplegará el contenido del archivo pero ennumerando cada línea:
$ nl -ba ~/email/email.confEl parámetro -b (body-numbering) permite especificar el estilo para ennumerar las líneas del archivo, y la letra a (all) quiere decir "ennumera todas las líneas, incluso aquéllas que estén vacías". El resultado del comando anterior es:
1 # This is the DEFAULT configuration file for email.
2 #
3 # Please CHANGE THE VALUES below to suit your environment.
4 # Don't forget to set the shell environment variable EDITOR
5 ############################################################
6
7 ############################################################
8 # SMTP Server and Port number you use
9 ############################################################
10 SMTP_SERVER = '192.168.0.100'
11 SMTP_PORT = '2500000'
12
13 ############################################################
14 # If you'd rather use sendmail binary, specify it and the
15 # command line switches to use, here. If you have both
16 # this option and SMTP_SERVER set, SMTP_SERVER will be of
17 # higher priority than SENDMAIL.
18 ############################################################
19 # SENDMAIL_BIN = '/usr/lib/sendmail -t -i'
20
21 ############################################################
22 # Your email address: If you'd like To have your name to
23 # show in the from field instead of just your email address,
24 # then keep the format below and edit it to your email
25 # and name.
26 ############################################################
27 MY_NAME = 'Siddharta'
28 MY_EMAIL = 'usuario@dominio.com@dominio.com'
29 #REPLY_TO = ''
30
31 ############################################################
32 # If your mail server uses SSL or TLS in order to create
33 # a secure communication, set this to "true". Only very
34 # simple TLS is implemented at this time. In other words,
35 # there is no way to load your own certs just yet.
36 ############################################################
37 # USE_TLS = 'true'
38
39 ############################################################
40 # Signature file and settings: Where is the signature file
41 # You can comment this out if you do not like signatures
42 ############################################################
43 #SIGNATURE_FILE = '&/email.sig'
44 SIGNATURE_FILE = '~/email/dominio/email.signature'
45
46 ############################################################
47 # This is where you store your address book... If you don't
48 # want address book functionality, just comment it out and
49 # use regular email addresses.
50 ############################################################
51 #ADDRESS_BOOK = '&/email.address.template'
52 ADDRESSS_BOOK = '~/email/dominio/email.address.template'
53
54 ############################################################
55 # If you would like to have a copy Of your final email saved
56 # after it is sent, please specify a directory to save
57 # it in below... If not, just comment this field out and it
58 # won't save a sent file other wise, it will save it as
59 # email.sent in the directory below
60 ############################################################
61 SAVE_SENT_MAIL = '~/email/dominio/'
62
63 ############################################################
64 # With email, temporary files are stored with a random name
65 # Starting with .EM. You must specify which directory you
66 # would like these temporary files stored while email is in
67 # Operation... After email is done executing, it will remove
68 # Every temporary file it used. The most common storage area
69 # for temporary files system wide is the /tmp directory
70 # if TEMP_DIR is not set, you can set the environment variable
71 # TMPDIR. If that is not set, email will just use /tmp
72 ############################################################
73 # TEMP_DIR = '/tmp'
74
75 ############################################################
76 # You should put the absolute path of your GPG binary
77 # In this variable. If you do not know the absolute path
78 # just putting "gpg" will suffice if GPG is in your PATH
79 # environment variable path.
80 ############################################################
81 # GPG_BIN = '/usr/bin/gpg'
82
83 ###########################################################
84 # You can bypass email asking you for a password for gpg
85 # when you are encrypting or signing emails if you store
86 # it here. Keep this safe! Make sure that people can't
87 # read your personal ~/.email.conf file if you're storing
88 # your password here!
89 ###########################################################
90 # GPG_PASS =
91
92 ###########################################################
93 # You can use SMTP_AUTH with email. You just need to
94 # specify which type of SMTP AUTH you will use. Email
95 # support two types of SMTP AUTH: LOGIN and PLAIN.
96 # Typically, LOGIN is the most used amongst SMTP servers.
97 # If you are unsure, ask your ISP.
98 ###########################################################
99 SMTP_AUTH = 'LOGIN'
100
101 ###########################################################
102 # Setting your SMTP username is MANDITORY. Please
103 # uncomment the option below and set your username in order
104 # to use SMTP AUTH
105 ###########################################################
106 SMTP_AUTH_USER = 'usuario@dominio.com'
107
108 ###########################################################
109 # Setting your password is not manditory. If you do not
110 # set your password, then email will prompt you for one
111 # if it sees that you are trying to use SMTP_AUTH.
112 ###########################################################
113 SMTP_AUTH_PASS = 'mi-contraseña-ultrasecreta'
114
115 ###########################################################
116 # If you have a v-card, you can have it attached to each
117 # message by specifying it's location here.
118 ###########################################################
119 #VCARD = "~/dean.ldif"Así será más fácil copiar/pegar en un foro, y y los lectores podrán dar indicaciones como:
fulano: -"la línea 28 tiene repetido @dominio.com"-
zutano: -"la línea 11 está mal, porque el puerto SMTP es 25 sólamente"-
mengano: -"agrega el carácter # al inicio de la línea 113 y borra tu contraseña para que el sistema la pida siempre, y no olvides cambiarla pronto porque ya todos la vimos ;)"-
También facilita la lectura si además se envía la salida al paginador less, así uno se puede desplazar rápidamente hacia arriba/abajo y al final se presiona Q (quit):
$ nl -ba ~/email/email.conf | lessOjalá esta sugerencia sea de utilidad a quien tenga que publicar algo en algún foro, o a quien tenga necesidad de imprimir directamente desde la línea de comandos su código fuente.
______________________________________
Viorel ( http://www.kubuntu-es.org/user/2852 ) me mostró que él usa el comando cat -n para obtener un resultado similar:
$ cat -n ~/email/email.conf










Yo uso cat -n que según entiendo la única diferencia con nl son la opciones de configuración.
Información muy útil como siempre
Saludos.
¡por eso me encanta el software libre! hay tantas maneras distintas de hacer las cosas. Quizás la diferencia de nl es que permite ennumerar de varias formas y no sólo como yo lo mostré. Agregaré tu sugerencia al blog :)