├── searcher.sh └── README.md /searcher.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check that two parameters are provided 4 | if [ "$#" -ne 2 ]; then 5 | echo "Usage: $0 " 6 | exit 1 7 | fi 8 | 9 | # Parameters 10 | directory=$1 11 | filename=$2 12 | 13 | # Check if the directory exists 14 | if [ ! -d "$directory" ]; then 15 | echo "Error: Directory '$directory' does not exist." 16 | exit 1 17 | fi 18 | 19 | # Search for the file in the specified directory 20 | found_files=$(find "$directory" -type f -name "$filename" 2>/dev/null) 21 | 22 | if [ -z "$found_files" ]; then 23 | echo "No files named '$filename' found in directory '$directory'." 24 | else 25 | echo "Files found:" 26 | echo "$found_files" 27 | fi 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Repository for useful notes 2 | 3 | ### Created 2 branches for testing pull requests 4 | 5 | # Bash Cheat Sheet 6 | 7 | ## Basic Commands 8 | - pwd - Print the current working directory. 9 | - ls - List files in the current directory. 10 | - ls -l - Long format. 11 | - ls -a - Show hidden files. 12 | - cd - Change directory. 13 | - mkdir - Create a new directory. 14 | - rm - Remove a file. 15 | - rm -r - Remove a directory and its contents. 16 | - cp - Copy files or directories. 17 | - mv - Move or rename files or directories. 18 | 19 | ## File Viewing 20 | - cat - Print the contents of a file. 21 | - less - View file contents page by page. 22 | - head - Show the first 10 lines of a file. 23 | - tail - Show the last 10 lines of a file. 24 | - tail -f - Follow a file as it grows (e.g., logs). 25 | 26 | ## Permissions 27 | - chmod - Change file permissions. 28 | - Example: chmod 755 script.sh 29 | - chown : - Change the owner of a file. 30 | 31 | ## Variables 32 | - VAR=value - Define a variable. 33 | - $VAR - Access a variable's value. 34 | - export VAR=value - Make a variable available to child processes. 35 | 36 | ## Loops and Conditionals 37 | ### For Loop 38 | ```bash 39 | for i in {1..5}; do 40 | echo "Iteration $i" 41 | done 42 | --------------------------------------------------------------------------------