#### What Will I Learn? In the first lesson we will learn how to create bash files and enter shell systems with a few examples. - Shell Script - Bash 4.4 #### Requirements Linux Operating System #### Difficulty Intermediate #### Tutorial Contents I'll show you how to write Shell Script with Bash on Linux operating systems. In this first lesson we will learn the "echo" and "read" constructs. #### Curriculum [How to Write a Shell Script with Bash? Turkish Tutorial #1](https://utopian.io/utopian-io/@sedatyildiz/how-to-write-a-shell-script-with-bash-turkish-tutorial-1) [How to Write a Shell Script with Bash? Turkish Tutorial #2](https://utopian.io/utopian-io/@sedatyildiz/how-to-write-a-shell-script-with-bash-turkish-tutorial-2) <hr> <br> Linux işletim sistemlerinde kullandığımız standart komutlar ile yapabileceğimiz en yaygın ve kolay programlama dili olan Shell için mini programlar yazacağız. Kullanacağımız Bash teknolojisi yani Bourne Again Shell, kullanım kolaylığı açısından bize oldukça yardımcı olacak ve ileriki derslerimizde komut tamamlama gibi nimetlerini çokça kullanacağız. Bildiğiniz üzere linux ve tüm unix distrolarda vazgeçilmez yönetim bölümümüz terminaldir, GUI ile ara yüz üzerinden yapılabilecek hemen her işlemi komut istemi yardımıyla gerçekleştirebilmekteyiz. Bu dersimizde en baştan başlayarak bir .sh dosyası oluşturup programımıza bir kaç işlem yaptıracağız. Ben Windows bir işletim sistemi kullandığım için linux bir sunucuya SSH bağlantısı gerçekleştirerek örneklendireceğim, siz terminal üzerinden çalışabilirsiniz.  Öncelikle terminalimizi açıp <code>echo '#!/bin/sh' > utopian.sh</code> komutumuzu girerek **utopian.sh** isminde bir komut dosyası oluşturuyoruz. Burada **utopian.sh** örnek bir isimdir, siz başka birşey kullanabilirsiniz. Gördüğünüz **#!/bin/sh** bölümü, betikleri çalıştırabilmemiz için bütün yazdığımız programlarda gereklidir. Ardından <code>echo 'echo Merhaba Utopian' >> utopian.sh</code> komutumuz ile oluşturduğumuz **utopian.sh** dosyasına **echo Merhaba Utopian** komutunu yazdırmış olduk. Bu da demek oluyor ki programımız bize **echo** ile Merhaba Utopian yazısını basacak. <code>chmod 755 utopian.sh</code> komutu ile **utopian.sh** dosyamıza **755** izni yani **okuma ve çalıştırma** yetkisini veriyoruz. Akabinde <code>sh utopian.sh</code> komutunu yazarak oluşturduğumuz shell scripti çalıştırabiliriz ve bize **Merhaba Utopian** şeklinde bir yanıt verdiğini görebiliriz. Bunun gibi **echo** ile bir çok karşılama cümlesi bastırabiliriz.  <code>echo 'echo Utopian' >> utopian.sh</code> <code>echo 'echo SedatYildiz' >> utopian.sh</code> <code>echo 'echo Steemit' >> utopian.sh</code> <code>echo 'echo Deneme123' >> utopian.sh</code> Yukarıdaki örneklerde **Merhaba Utopian** yerine yine aynı yöntem ile farklı kelimeler bastırdık, farklı cümleler ve kelimeleri bu yöntem ile istediğiniz kadar programımıza yazdırabiliyoruz. İlk adımımızdan yani dosyamızı oluşturup içerisine çalıştırma komutunu verdikten sonra **echo** ile komut istemcisinde çalışmak yerine kolaylık olması açısından direkt terminal üzerinden **nano** editörümüz ile bash dosyamızı açabilir ve komutlarımızı bu şekilde girebiliriz.  Gireceğimiz <code>nano utopian.sh</code> komutu ile oluşturduğumuz **utopian.sh** içerisine giriş yapabiliyoruz. Bir üstteki dört satırlık çıktı örneğimizi son haliyle görebiliriz. Daha komplike bir örnek yapalım ve bu sefer programımızdan bir soru karşılığı yanıt alalım. Bunun için nano editörü ile komutlarımızı yazacağız.  <code>echo İsmin nedir?</code> --> İsmin nedir? şeklinde bir çıktı bastırıyoruz. <code>read isim</code> --> Programımıza "isim" adındaki değişkeni okumasını söylüyoruz. <code>echo "Merhaba $isim . Memnun oldum."</code> --> Değişkeni belirleyip, okuduktan sonra basacağı çıktıyı söylüyoruz. Hepsi tamamlandığında **CTRL+X ve Y** tuşları ile .sh yi kaydedip editörümüzden çıkıyoruz ve <code>sh utopian.sh</code> komutu ile programımızı çalıştırdığımızda bize ismimizi soruyor. Örneğin ben **sedatyildiz** yazdım ve yukarıdaki komutlar dolayısıyla **Merhaba sedatyildiz . Memnun oldum.** şeklinde bir yanıt verdi. Son örneğimizde de shell scriptimize ufak bir matematik işlemi yaptıralım.  <code>echo -n "Sonuc = "</code> --> Alacağı değişkenin ekrana basmasını söyledik. <code>echo $((324324 + 1234))</code> --> 324324 ve 1234 sayılarını toplayıp sonuca aktarttık. Kaydedip sh utopian.sh ile programımızı çalıştırdığımızda bize başarıyla toplamı yani **Sonuc = 325558** çıktısını yazdırmış oldu. Bu derste öğrendiğimiz yapılar ile sonraki dersimizde, yaptırdığımız matematik işlemini sh içerisine yazmayıp direkt komutlarla soracağız ve programımıza hesaplatacağız. <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@sedatyildiz/how-to-write-a-shell-script-with-bash-turkish-tutorial-1">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | sedatyildiz | ||||||
---|---|---|---|---|---|---|---|
permlink | how-to-write-a-shell-script-with-bash-turkish-tutorial-1 | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":90001159,"name":"gnu_bash","full_name":"gitGNU/gnu_bash","html_url":"https://github.com/gitGNU/gnu_bash","fork":false,"owner":{"login":"gitGNU"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","tr","linux","shell","bash"],"users":["sedatyildiz"],"links":["https://utopian.io/utopian-io/@sedatyildiz/how-to-write-a-shell-script-with-bash-turkish-tutorial-1","https://utopian.io/utopian-io/@sedatyildiz/how-to-write-a-shell-script-with-bash-turkish-tutorial-2","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516060241/nodmwho5sc6eyvpjgzwj.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516060678/ffgpazslcrftiz49404d.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516060969/wnqo8xsjkxlluivkkddu.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516061138/nnjlq6p6htfzm659gcij.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516061931/wvd5ippfsq0uqcrrawf0.gif"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1516060241/nodmwho5sc6eyvpjgzwj.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516060678/ffgpazslcrftiz49404d.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516060969/wnqo8xsjkxlluivkkddu.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516061138/nnjlq6p6htfzm659gcij.gif","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516061931/wvd5ippfsq0uqcrrawf0.gif"],"moderator":{"account":"scipio","time":"2018-01-16T13:21:21.937Z","reviewed":true,"pending":false,"flagged":false}} | ||||||
created | 2018-01-16 00:30:24 | ||||||
last_update | 2018-01-17 18:32:27 | ||||||
depth | 0 | ||||||
children | 9 | ||||||
last_payout | 2018-01-23 00:30:24 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 25.222 HBD | ||||||
curator_payout_value | 10.218 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 5,406 | ||||||
author_reputation | 4,535,285,897,770 | ||||||
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 29,822,414 | ||||||
net_rshares | 4,704,352,172,434 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
kendewitt | 0 | 556,382,737 | 0.7% | ||
themanualbot | 0 | 98,446,204 | 0.7% | ||
nickfost | 0 | 512,419,016 | 0.7% | ||
renzoarg | 0 | 1,662,771,213 | 0.7% | ||
dexter-k | 0 | 3,016,100,163 | 0.7% | ||
coolenglish | 0 | 2,680,536,412 | 0.7% | ||
detlev | 0 | 652,371,581 | 0.7% | ||
acwood | 0 | 717,216,277 | 0.7% | ||
staticinstance | 0 | 6,663,616,573 | 0.7% | ||
arunava | 0 | 1,900,521,428 | 0.7% | ||
isacoin | 0 | 1,273,657,927 | 0.7% | ||
alphacore | 0 | 203,160,615 | 0.7% | ||
xtetrahedron | 0 | 540,461,836 | 0.7% | ||
imransoudagar | 0 | 365,084,790 | 0.7% | ||
bitcoinbutter | 0 | 645,838,357 | 0.7% | ||
amitsharma | 0 | 745,028,723 | 0.7% | ||
bigdeej | 0 | 4,057,468,839 | 0.7% | ||
gazur | 0 | 676,999,753 | 0.7% | ||
larrydavid4 | 0 | 897,574,187 | 0.7% | ||
grandpawhale | 0 | 41,800,823,098 | 0.7% | ||
funkie68 | 0 | 1,397,487,331 | 0.7% | ||
intuitivejakob | 0 | 485,184,480 | 0.7% | ||
zord189 | 0 | 553,281,934 | 0.7% | ||
bobdos | 0 | 2,044,350,268 | 5% | ||
irfandemire2084 | 0 | 2,500,567,008 | 100% | ||
tarikhakan55 | 0 | 9,361,913,556 | 49% | ||
utopian-io | 0 | 4,597,643,230,070 | 2.63% | ||
tradingbroom | 0 | 579,534,337 | 0.7% | ||
ipg | 0 | 515,480,013 | 0.7% | ||
zoltarian | 0 | 679,972,119 | 0.7% | ||
aghunter | 0 | 2,650,650,780 | 0.7% | ||
steemitstats | 0 | 2,052,396,181 | 5% | ||
matematikciemre | 0 | 1,834,686,319 | 100% | ||
exposez | 0 | 1,738,549,080 | 0.7% | ||
sedatyildiz | 0 | 2,263,667,053 | 100% | ||
cryptoconnector | 0 | 532,635,256 | 0.7% | ||
amicus | 0 | 794,481,890 | 0.7% | ||
bedis | 0 | 593,470,496 | 100% | ||
slyghx | 0 | 614,500,000 | 100% | ||
timmylace | 0 | 284,677,636 | 0.7% | ||
pars11 | 0 | 657,214,417 | 100% | ||
caps | 0 | 117,004,017 | 100% | ||
chelsea.bear | 0 | 2,079,014,862 | 5% | ||
claraquarius | 0 | 2,078,846,657 | 5% | ||
cheysanta | 0 | 153,607,216 | 54.65% | ||
jangli-billa | 0 | 479,289,729 | 100% |
Yakışıklı post olmuş.
author | irfandemire2084 |
---|---|
permlink | re-sedatyildiz-how-to-write-a-shell-script-with-bash-turkish-tutorial-1-20180116t123515936z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-16 12:35:15 |
last_update | 2018-01-16 12:35:15 |
depth | 1 |
children | 1 |
last_payout | 2018-01-23 12:35:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 21 |
author_reputation | 6,691,727,725,489 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,929,821 |
net_rshares | 0 |
Teşekkür ederim.
author | sedatyildiz |
---|---|
permlink | re-irfandemire2084-re-sedatyildiz-how-to-write-a-shell-script-with-bash-turkish-tutorial-1-20180116t123854244z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-16 12:38:57 |
last_update | 2018-01-16 12:38:57 |
depth | 2 |
children | 0 |
last_payout | 2018-01-23 12:38:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 16 |
author_reputation | 4,535,285,897,770 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,930,452 |
net_rshares | 0 |
emeğinize sağlık
author | matematikciemre |
---|---|
permlink | re-sedatyildiz-how-to-write-a-shell-script-with-bash-turkish-tutorial-1-20180116t012630352z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-16 01:26:36 |
last_update | 2018-01-16 01:26:36 |
depth | 1 |
children | 1 |
last_payout | 2018-01-23 01:26:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 16 |
author_reputation | 3,736,149,759,917 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,830,501 |
net_rshares | 0 |
Çok teşekkürler.
author | sedatyildiz |
---|---|
permlink | re-matematikciemre-re-sedatyildiz-how-to-write-a-shell-script-with-bash-turkish-tutorial-1-20180116t014015816z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-16 01:40:18 |
last_update | 2018-01-16 01:40:18 |
depth | 2 |
children | 0 |
last_payout | 2018-01-23 01:40:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 16 |
author_reputation | 4,535,285,897,770 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,832,458 |
net_rshares | 0 |
Thank you for the contribution. It has been approved. Suggestions for this and future bash (shell) tutorial series: - `sh` is not `bash` and so if your script uses `bash` (2nd generation, "Bourne Again sh"), then you should be more specific and use `bash` in your shebang; - in essence you only created a .sh file (you could have used `touch` instead of echo'ing, but alright), showed how to run a .sh file, chmod'ed it t 755 (not explaining what those numbers mean!), you appended some text, read user input, and did some extremely trivial math additions. Of course in "part 1" of a series you need to start somewhere, but I'd like to see **on this contribution** that you change the "What will I learn?" to "creating, modifying and running `sh files": telling users that they will learn shell scripting is a bit misleading... - I'm looking forward to parts 2 and next of your shellscript tutorial series, but make sure to cover **focused** topics/concepts per tutorial and explain exactly what you are doing where, why and how. @scipio You can contact us on [Discord](https://discord.gg/uTyJkNm). **[[utopian-moderator]](https://utopian.io/moderators)**
author | scipio |
---|---|
permlink | re-sedatyildiz-how-to-write-a-shell-script-with-bash-turkish-tutorial-1-20180116t132945986z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-16 13:29:45 |
last_update | 2018-01-16 13:29:45 |
depth | 1 |
children | 1 |
last_payout | 2018-01-23 13:29:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,157 |
author_reputation | 34,229,826,851,736 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,940,371 |
net_rshares | 0 |
Hello, your edit has been made. I tried to keep it simple because it was the first lesson because you know a little complicated language structure. The next derste mathematical operations will be a bit more complex. Thank you for your approval and your interest.
author | sedatyildiz |
---|---|
permlink | re-scipio-re-sedatyildiz-how-to-write-a-shell-script-with-bash-turkish-tutorial-1-20180116t144337082z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-16 14:43:39 |
last_update | 2018-01-16 14:43:39 |
depth | 2 |
children | 0 |
last_payout | 2018-01-23 14:43:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 262 |
author_reputation | 4,535,285,897,770 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,955,475 |
net_rshares | 0 |
Kodcumuz iş başında yine... Maşallah...
author | tarikhakan55 | ||||||
---|---|---|---|---|---|---|---|
permlink | re-sedatyildiz-2018116t13239434z | ||||||
category | utopian-io | ||||||
json_metadata | {"tags":["utopian-io","tr","linux","shell","bash"],"app":"esteem/1.5.0","format":"markdown+html","community":"esteem"} | ||||||
created | 2018-01-16 00:32:42 | ||||||
last_update | 2018-01-16 00:32:42 | ||||||
depth | 1 | ||||||
children | 1 | ||||||
last_payout | 2018-01-23 00:32:42 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 39 | ||||||
author_reputation | 38,506,275,601,183 | ||||||
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 29,822,786 | ||||||
net_rshares | 2,307,999,097 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
sedatyildiz | 0 | 2,307,999,097 | 100% |
Teşekkür ediyorum abicim :)
author | sedatyildiz |
---|---|
permlink | re-tarikhakan55-re-sedatyildiz-2018116t13239434z-20180116t003420388z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-16 00:34:21 |
last_update | 2018-01-16 00:34:21 |
depth | 2 |
children | 0 |
last_payout | 2018-01-23 00:34:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 27 |
author_reputation | 4,535,285,897,770 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,823,044 |
net_rshares | 0 |
### Hey @sedatyildiz I am @utopian-io. I have just upvoted you! #### Achievements - You have less than 500 followers. Just gave you a gift to help you succeed! - Seems like you contribute quite often. AMAZING! #### Suggestions - Contribute more often to get higher and higher rewards. I wish to see you often! - Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck! #### Get Noticed! - Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
author | utopian-io |
---|---|
permlink | re-sedatyildiz-how-to-write-a-shell-script-with-bash-turkish-tutorial-1-20180117t124506243z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-17 12:45:06 |
last_update | 2018-01-17 12:45:06 |
depth | 1 |
children | 0 |
last_payout | 2018-01-24 12:45:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,509 |
author_reputation | 152,955,367,999,756 |
root_title | "How to Write a Shell Script with Bash? Turkish Tutorial #1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 30,163,853 |
net_rshares | 0 |