Bash Scripting

 Bash Scriping:

Entire course: here

Types of shells in linux -> here
Use of she-bang -> here
echo and escape characters -> here
Array basics -> here and here
loops == for -> here while -> here
functions in bash -> here
IFS -> here
Grep -> here
Awk -> here loops in awqk -> here condtional statements-> here
grep vs sed vs awk -> here
shell parameter expansion -> here
printf -> here

AWK series by tecmint:






Important points:

1.By default, read interprets the backslash as an escape character, which sometimes may cause unexpected behavior. To disable backslash escaping, invoke the command with the -r option.

Below is an example showing how read works when invoked with and without the -r option:



2.echo by itself displays a line of text. It will take any thing within the following "..." two quotation marks, literally, and just print out as it is. However with echo -e you're making echo to enable interpret backslash escapes. So with this in mind here are some examples

INPUT: echo "abc\n def \nghi" 
OUTPUT:abc\n def \nghi

INPUT: echo -e "abc\n def \nghi"
OUTPUT:abc
 def 
ghi
Note: \n is new line, ie a carriage return. If you want to know what other sequences are recognized by echo -e type in man echo to your terminal.

3.The only difference between @ and * is when the form ${my_array[x]} is surrounded with double-quotes. In this case, * expands to a single word where array elements are separated with space. @ expands each array element to a separate word.

Comments