Last active
March 17, 2022 19:13
-
-
Save jgeek/e2999f859d3bcc7521b7 to your computer and use it in GitHub Desktop.
bash script
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
# loops: | |
#!/bin/bash | |
for i in 1 2 3 4 5 | |
do | |
echo "Welcome $i times" | |
done | |
#!/bin/bash | |
for i in {1..5} | |
do | |
echo "Welcome $i times" | |
done | |
for i in {0..10..2} | |
do | |
echo "Welcome $i times" | |
done | |
#!/bin/bash | |
for (( c=1; c<=5; c++ )) | |
do | |
echo "Welcome $c times" | |
done | |
#!/bin/bash | |
for (( ; ; )) | |
do | |
echo "infinite loops [ hit CTRL+C to stop]" | |
done | |
#!/bin/bash | |
for file in /etc/* | |
do | |
if [ "${file}" == "/etc/resolv.conf" ] | |
then | |
countNameservers=$(grep -c nameserver /etc/resolv.conf) | |
echo "Total ${countNameservers} nameservers defined in ${file}" | |
break | |
fi | |
done | |
قا این zstd خیلی خره! حتماً استفاده کنین! | |
یه سری فایل html از ۲۲ تا بلاگ گرفته بودم، ۳.۸ گیگ حجمش بود. | |
زدم: | |
time (for d in *; do echo $d...; tar -I 'zstd -T0' -cf $d.zst $d; done) | |
که اصلش اون بخش tar -I 'zstd -T0' هست که میگه با دستور zstd فشرده کنه، اون T0 هم یعنی چندریسمانی به تعداد هستههای پردازندهٔ موجود بزنه. | |
نتیجه؟ تو مدت ۱۵ ثانیه ۳.۸ گیگ رو کرد ۳۴۲ مگ!!! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment