Commit f247cb73 authored by hatem.ibrahim's avatar hatem.ibrahim

Add new file

parent 7b59194b
السؤال الاول
#!/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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment