forked from iiitl/bash-practice-repo-24
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wifi-ssid script added, issue iiitl#1
- Loading branch information
0 parents
commit 1bce1ec
Showing
13 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Foss BashScripting | ||
|
||
See [scripts](./scripts) folder for more information. | ||
|
||
Whereever there is a work to do, there will be a comment present with word "TODO". | ||
|
||
## Running scripts | ||
|
||
After cd into this repository | ||
```bash | ||
export PATH="$PATH:$PWD/scripts" | ||
|
||
# All scripts are ready to execute by their name | ||
``` | ||
|
||
## Some external resources | ||
|
||
* [Linux Basics & CLI Tutorial](https://www.freecodecamp.org/news/linux-command-line-tutorial) | ||
* [Learn X in Y Minutes - Bash](https://learnxinyminutes.com/docs/bash/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# TODO (Run this script as): color magenta && echo hello && color reset | ||
|
||
color() { | ||
echo -ne "\033[$1;$2m" | ||
} | ||
|
||
declare -A color_mapping=( | ||
# TODO: Add more color values | ||
# Refer bash color codes | ||
['magenta']=35 | ||
) | ||
|
||
if [[ $1 == 'reset' ]]; then | ||
color 0 00 | ||
else | ||
color 1 ${color_mapping[$1]} | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
grep -E 'Tctl|Tdie|Package id' /sys/class/hwmon/hwmon*/temp*_label | head -n1 | cut -d':' -f1 | sed 's/label/input/' | xargs cat | ||
|
||
# Following script outputs current cpu die temperature in milidegree-celcius, convert it to celcius and fahrenheit and display as: | ||
# | ||
# Celcius: 42.0 C | ||
# Fahrenheit: 107.6 F |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Arranges the files by grouping them into folder of their extension name | ||
# TODO: Run this script in your downloads folder | ||
|
||
require() { | ||
command -v "$1" 1>/dev/null || { >&2 echo "Error: $1 is not installed";exit 1; } | ||
} | ||
|
||
require fd | ||
require egrep | ||
|
||
declare -A special_cases=( | ||
['^*.(tar.*|tbz)$']='tar' | ||
# TODO: Add your own pattern here for similar file types appropriately | ||
# Refer https://regex101.com/ & https://github.com/ziishaned/learn-regex/ for explaination and writing patterns | ||
# These (regex) are same as ones used in sed command | ||
) | ||
|
||
fd -tf -d1 \ | ||
| while read file; do | ||
folder="$PWD/${file##*.}" | ||
for regex in "${!special_cases[@]}"; do | ||
(echo "$file" | egrep -q "$regex") && { | ||
folder="$PWD/${special_cases[$regex]}" | ||
break | ||
} | ||
done | ||
|
||
mkdir -p "$folder" | ||
mv "$file" "$folder" | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
# TODO: Display lines of code by language in a remote git repository | ||
# Refer "cloc" command or similar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# TODO: Make a ffmpeg script which takes all the mp4 files in a folder (recursively) and output them in the same position mp3 file | ||
# | ||
# E.g.: | ||
# Videos | ||
# ├── Clips | ||
# │ ├── clip1.mp4 | ||
# │ └── clip2.mp4 | ||
# ├── Movies | ||
# │ ├── movie1.mp4 | ||
# │ └── movie2.mp4 | ||
# └── Songs | ||
# ├── Song1.mp4 | ||
# └── Song2.mp4 | ||
# music-extract Videos | ||
# | ||
# The above folder will create another folder with the position of file with just there audio | ||
# Music | ||
# ├── Clips | ||
# │ ├── clip1.mp3 | ||
# │ └── clip2.mp3 | ||
# ├── Movies | ||
# │ ├── movie1.mp3 | ||
# │ └── movie2.mp3 | ||
# └── Songs | ||
# ├── Song1.mp3 | ||
# └── Song2.mp3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Issue: Implement Password Generation Functions | ||
# Description: | ||
# Create a function that generates passwords, The password should consist of uppercase letters, lowercase letters, numbers, and special characters. The function should take in a single argument, which is the length of the password to generate. The function should return the generated password. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
# TODO: Make it print out permissions of the given files in octal format | ||
# | ||
# E.g.: | ||
# $ perms weather ../README.md | ||
# 775 weather | ||
# 664 ../README.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Remove all the binary files (usually made after gcc) present inside current directory | ||
# Refer "man find" for more information, you can also use modern tool like fd instead of find |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Removes all files written in .gitignore of any git repository (multiple) present inside current directory | ||
# To find list of all git repos inside current directory you can use: "find . -name .git -type d -prune" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
# TODO: Display weather of IIIT, Lucknow | ||
# For more information see: https://wttr.in/:help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Extract the wifi username (SSID) | ||
# Refer: "iw dev wlan0 link" command output for this | ||
|
||
ssid=$(iwgetid -r) | ||
|
||
if [ -z "$ssid" ]; then | ||
echo "Not connected to any Wi-Fi network." | ||
else | ||
echo "Connected Wi-Fi network SSID: $ssid" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
# TODO: Make a script to download youtube video from given timeframes | ||
# | ||
# E.g.: youtube-time 2:00 4:00 tutorial.mkv "https://www.youtube.com/watch?v=SPwyp2NG-bE" | ||
# The above command should create a output file which contains the video from 2 min to 4 min. | ||
# | ||
# Refer: youtube-dl and ffmpeg commands for this |