I have used a number of Unix/Linux shells over the years, but my shell of preference is the bash shell. My favorite guide to the bash shell is the Advanced Bash-Scripting Guide. This page contains snippets of bash trivia that I've found useful and don't want to forget.
For general Linux/Unix information (i.e., not specific to the bash shell), see Using Linux.
Within your .bashrc, the shell prompt is controlled using the declare -x PS1="prompt" , where prompt is what you want as your main prompt. There are three other prompt variables (PS2, PS3, PS4) controlling specific use prompts.
There are several special character sequences defined to include dynamic information or special characters into your prompt. These are:
\t | the time | \d | the date | |
\n | CRLF | \s | the name of the shell | |
\w | the current working directory | \W | the last element of PWD | |
\u | your username | \h | the hostname | |
\# | the command number of this command | \! | the history number of this command | |
\O | the character code in octal O | \\ | a backslash |
(I found this info at www.informatik.uni-frankfurt.de/doc/texi/bash_4.html, but that page no longer exists.)
For example, I have:
declare -x PS1="[\d \t \!] "
and my prompt looks like:
[Sat Aug 19 18:39:37 501]
(with a space at the end).
stdin) to upper (on stdout): tr a-z A-Z
The following reads the contents of MAKE_KML.TMP into a new array RAWDATA, one line per array element, and then reads the output of the grep command (sorted and then throwing out redundant lines) into RAWDATA2, one line of output per array element:
#!/bin/bash IFS=' ' RAWDATA=( $(< MAKE_KML.TMP) ) RAWDATA2=( $(grep SLAT *.buf | sort | uniq) )
The first two lines set newline as the field separator. You may want to set it back to space after reading the file into the array.
IFS=' '