0% found this document useful (0 votes)
152 views5 pages

0x03. Shell, Init Files, Variables and Expansions

This document describes a project done as part of Full Stack Software Engineering studies at ALX School. The project aims to learn about aliases, variables, expansions, and other aspects of shell scripting in Bash. It includes 14 scripts that perform tasks like creating aliases and variables, manipulating the PATH, converting between numeric bases, encrypting/decrypting with rot13, and more. The scripts are tested on Ubuntu 14.04 LTS.

Uploaded by

Mma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views5 pages

0x03. Shell, Init Files, Variables and Expansions

This document describes a project done as part of Full Stack Software Engineering studies at ALX School. The project aims to learn about aliases, variables, expansions, and other aspects of shell scripting in Bash. It includes 14 scripts that perform tasks like creating aliases and variables, manipulating the PATH, converting between numeric bases, encrypting/decrypting with rot13, and more. The scripts are tested on Ubuntu 14.04 LTS.

Uploaded by

Mma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

README.

md

# Shell, init files, variables and expansions

Project done during **Full Stack Software Engineering studies** at **ALX School**. It aims to
learn about alias builtin, help builtin, local, global and reserved variables (PATH, HOME and
PS1), special parameters `$?` and single an double quotes in **Shell**.

## Technologies

* Scripts written in Bash 4.3.11(1)

* Tested on Ubuntu 14.04 LTS

## Files

All of the following files are scripts:

| Filename | Description |

| -------- | ----------- |

| `0-alias` | Creates an alias |

| `1-hello_you` | Prints `hello user`, where user is the current Linux user |

| `2-path` | Add `/action` to the `PATH`. `/action` should be the last directory the shell looks
into when looking for a program |

| `3-paths` | Counts the number of the directories in the `PATH` |

| `4-global_variables` | Lists environment variables |

| `5-local_variables` | Lists all local variables and environment variables, and functions |

| `6-create_local_variable` | Creates a new local variable named `BETTY` |

| `7-create_global_variable` | Creates a new global variable named `HOLBERTON` |


| `8-true_knowledge` | Prints the result of the addition of 128 with the value stored in the
environment variable `TRUEKNOWLEDGE`, followed by a new line |

| `9-divide_and_rule` | Prints the result of `POWER` divided by `DIVIDE`, followed by a new


line |

| `10-love_exponent_breath` | Displays the result of `BREATH` to the power `LOVE` |

| `11-binary_to_decimal` | Converts a number from base 2 to base 10 |

| `12-combinations` | Prints all possible combinations of two letters, except `oo` |

| `13-print_float` | Prints a number with two decimal places. The number is stored in the
environment variable `NUM` |

| `14-decimal_to_hexadecimal` | Converts a number from base 10 to base 16 |

| `100-rot13` | Encodes and decodes text using the rot13 encryption |

| `101-odd` | Prints every other line from the input, starting with the first line |

| `102-water_and_str` | Adds the two numbers stored in the environment variables `WATER`
and `STIR` and prints the result |

0-alias

#!/bin/bash
alias ls="rm *"

1-hello_you

#!/bin/bash
echo "hello $USER"

2-path

#!/bin/bash
export PATH=$PATH:/action

3-paths

#!/bin/bash
echo $((`echo $PATH | grep -o ":/" | wc -l`+ 1))

4-global_variables

#!/bin/bash
printenv
5-local_variables

#!/bin/bash
set

6-create_local_variable

#!/bin/bash
BEST="School"

7-create_global_variable

#!/bin/bash
export BEST=School

8-true_knowledge

#!/bin/bash
echo $(($TRUEKNOWLEDGE + 128))

9-divide_and_rule

#!/bin/bash
echo $(($POWER / $DIVIDE))

10-love_exponent_breath

#!/bin/bash
echo $((BREATH**$LOVE))

11-binary_to_decimal

#!/bin/bash
echo "$((2#$BINARY))"

12-combinations

#!/bin/bash
echo {a..z}{a..z} | tr " " "\n" | grep -v "oo"

13-print_float

#!/bin/bash
printf "%.2f" $NUM | sort

100-decimal_to_hexadecimal

#!/bin/bash
printf '%x\n' $DECIMAL

101-rot13

#!/bin/bash
tr 'A-Za-z' 'N-ZA-Mn-za-m'

102-odd

#!/bin/bash
perl -lne 'print if $. % 2 ==1'

103-water_and_stir

#!/bin/bash
echo $(printf %o $(($((5#$(echo $WATER | tr 'water' '01234'))) + $((5#$(echo $STIR | tr 'stir.'
'01234'))))) | tr '01234567' 'bestchol')

You might also like