Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
final
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
hatem.ibrahim
final
Commits
f247cb73
Commit
f247cb73
authored
Jul 01, 2024
by
hatem.ibrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
7b59194b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
the hatem homework
the hatem homework
+62
-0
No files found.
the hatem homework
0 → 100644
View file @
f247cb73
السؤال الاول
#!/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
new_folder="$HOME/new_folder"
mkdir -p "$new_folder"
for letter in {a..z}; do
for number in {1..10}; do
filename="file${number}_${letter}"
touch "$new_folder/$filename"
done
done
for file in "$new_folder"/*_x; do
echo "Hello Linux" > "$file"
done
for letter in {a..z}; do
folder="$new_folder/$letter"
mkdir -p "$folder"
mv "$new_folder"/*_$letter "$folder"
done
find "$new_folder" -type f \( -name "*3*" -o -name "*4*" \) -delete
========================================================================================
#!/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)
if (( end_range >= start_range )); then
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