Commit 5defcb9b authored by mohamed.mardeen's avatar mohamed.mardeen

Add new file

parents
script 1
#!/bin/bash
currentdi=$(pwd)
for item in "$currentdi"/**/*.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 l in {a..z}; do
for n in {1..10}; do
filename="file${n}_${l}"
touch "$new_folder/$filename"
done
done
for file in "$new_folder"/*_x; do
echo "Hello Linux" > "$file"
done
for l in {a..z}; do
folder="$new_folder/$l"
mkdir -p "$folder"
mv "$new_folder"/*_$l "$folder"
done
find "$new_folder" -type f \( -name "*3*" -o -name "*4*" \) -delete
========================================================================================
script 3
#!/bin/bash
# alive2.sh
stIp=$(echo "$1" | cut -d- -f1)
endIp=$(echo "$1" | cut -d- -f2)
network_prefix=$(echo "$stIp" | cut -d. -f1-3)
stRange=$(echo "$stIp" | cut -d. -f4)
endRange=$(echo "$endIp" | cut -d. -f4)
if (( endRange >= stRange )); then
for ((n=stRange; n<=endRange; 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 "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