-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathsearch.sh
More file actions
executable file
·35 lines (28 loc) · 896 Bytes
/
Copy pathsearch.sh
File metadata and controls
executable file
·35 lines (28 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
# Function: search_dir
# Description: searches current directory for a file or folder with the given name
# Usage: search_dir [arguments]
# Alias: sd
function search_dir() {
# Function implementation goes here
echo "Function search_dir called"
# If no argument is provided, return usage
if [ -z "$1" ]; then
echo "${orange}Usage: search_dir [arguments]${reset}"
return 1
fi
# If -d flag passed search for a directory with the given name
if [ "$1" = "-d" ]; then
echo "Searching for directory with name: $2"
echo "${green}"
find . -maxdepth 1 -type d -name "$2"
echo "${reset}"
return 0
fi
# Default case search for a file or folder with the given name
echo "${green}"
find . -maxdepth 1 -name "*$1*"
echo "${reset}"
}
# Create alias
alias sd="search_dir"