bash
This demonstrates the usage of the printf
command in Bash for formatted output, including strings, integers, floats, and writing to files.
printf "Hello %s, I'm %s" Sven Olga #=> "Hello Sven, I'm Olga printf "1 + 1 = %d" 2 #=> "1 + 1 = 2" printf "This is how you print a float: %f" 2 #=> "This is how you print a float: 2.000000" printf '%s\n' '#!/bin/bash' 'echo hello' >file # format string is applied to each group of arguments printf '%i+%i=%i\n' 1 2 3 4 5 9
bash internaldata manipulationsstring manipulation and expansionsformatted output
bash
This demonstrates various uses of the cd
command in Bash for directory navigation, including moving to the home directory, going up one level, navigating to a specific directory, and returning to the last directory.
cd ~ # change to home directory cd # also goes to home directory cd .. # go up one directory # (^^say, from /home/username/Downloads to /home/username) cd /home/username/Documents # change to specified directory cd ~/Documents/.. # now in home directory (if ~/Documents exists) cd - # change to last directory # => /home/username/Documents
bash internalfile and stream operationsdirectory operationsdirectory navigation