Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
S
saeed_bakdoness_homework
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
saeed.bakdoness
saeed_bakdoness_homework
Commits
da1dac01
Commit
da1dac01
authored
Jul 01, 2024
by
saeed.bakdoness
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CONTRIBUTING
parent
7cbf449b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
saeed.txt
saeed.txt
+75
-0
No files found.
saeed.txt
0 → 100644
View file @
da1dac01
script 1
#!/bin/bash
current_directory=$(pwd)
for item in "$current_directory"/**/*.txt; do
if [[ -f "$item" ]]; then
sed -i 's/oldworld/newworld/g' "$item"
fi
done
========================================================================================
script 2
#!/bin/bash
# step 1
new_folder="$HOME/new_folder"
mkdir -p "$new_folder"
# step 2
for letter in {a..z}; do
for number in {1..10}; do
filename="file${number}_${letter}"
touch "$new_folder/$filename"
done
done
# step 3
for file in "$new_folder"/*_x; do
echo "Hello Linux" > "$file"
done
# step 4
for letter in {a..z}; do
folder="$new_folder/$letter"
mkdir -p "$folder"
mv "$new_folder"/*_$letter "$folder"
done
# step 5
find "$new_folder" -type f \( -name "*3*" -o -name "*4*" \) -delete
========================================================================================
script 3
#!/bin/bash
# alive2.sh
# Checks to see if a range of hosts are alive
start_ip=$(echo "$1" | cut -d- -f1)
end_ip=$(echo "$1" | cut -d- -f2)
network_prefix=$(echo "$start_ip" | cut -d. -f1-3)
start_range=$(echo "$start_ip" | cut -d. -f4)
end_range=$(echo "$end_ip" | cut -d. -f4)
# Check if end_range is greater than start_range
if (( end_range >= start_range )); then
# Iterate through IP addresses
for ((n=start_range; n<=end_range; n++)); do
host="$network_prefix.$n"
ping -c2 "$host" &> /dev/null
if [ $? = 0 ]; then
echo "$host is UP"
else
echo "$host is DOWN"
fi
done
else
echo "Invalid range. The end range is smaller than the start range."
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment