Jaime Frutos Morales's blog

20/10/2009

BASH 3 startup files

Filed under: Shell scripting, SysAdmin — acidborg @ 17:54

Before explaining the Bourne Again SHell (BASH) 3 default startup files order, here are some needed definitions:

  • Login shell: its first character of argument zero is a or it’s started with the -l option.
  • Interactive shell: it’s started without non-option arguments and without the -c option and its standard input and error are both connected to terminals. It can be started with the -i option.

Now that we know the differences between them, let’s explain the default startup process for each kind of shell in BASH 3:

  • Login shell:
    1. It reads and executes /etc/profile (if it exists)
    2. It reads one (and only one) of the following files and executes it. The order of checking is:
      1. ~/.bash_profile
      2. ~/.bash_login
      3. ~/.profile
  • Interactive shell:
    1. It reads and executes /etc/bash.bashrc (if it exists)
    2. It reads and executes ~/.bashrc (if it exists)

Additionally, login shells reads and executes ~/.bash_logout (if it exists) on exit.

16/04/2008

Always UTF-8

Filed under: Shell scripting — acidborg @ 21:24

Today, fed up with having to convert all subtitle files from ISO-8859-15 to UTF-8, I’ve coded a simple bash script to do it for me. It can be downloaded from here (GPLv3 licensed).

It uses iconv to make the conversion. The input and output encodings aren’t hard-typed, so if you need to make different encoding conversions, just change that values.

Create a free website or blog at WordPress.com.