Coder Social home page Coder Social logo

bash's Introduction

class: center, middle , inverse, farsi

bash

اسکریپت نویسی bash

echo 'hello dudes!'

githubwebsite


class: center, middle , inverse, farsi

حلقه‌ها


class: farsi

دستور seq

  • دستور seq دنباله ای از اعداد را ایجاد می‌کند. مثلا برای اعداد ۱ تا ۵ می‌نویسیم
seq 1 5
1
2
3
4
5
  • این‌جوری می‌شه گام هم براش تعریف کرد که دوتا دو تا بره جلو مثلاً
seq 1 2 5
1
3
5

class: inverse, farsi

حلقهٔ for

for i in $( seq 1 5 )
do
  echo $i
done
1
2
3
4
5

class: inverse, farsi

تفاوت while و until

حلقهٔ while تا زمانی که شرط «درست باشه» ادامه پیدا می‌کنه

حلقهٔ until تا وقتی که شرط «درست بشه» ادامه پیدا می‌کنه،

  • یعنی قراره false باشه همیشه وقتی true شد اون موقع تموم می‌شه

class: inverse, farsi

تفاوت while و until

COUNTER=0
while [ $COUNTER -lt 5 ]; do
    echo counter is $COUNTER
    let COUNTER+=1 
done
counter is 0
counter is 1
counter is 2
counter is 3
counter is 4

class: inverse, farsi

تفاوت while و until

COUNTER=10
until [ $COUNTER -lt 5 ]; do
    echo counter is $COUNTER
    let COUNTER-=1 
done
counter is 10
counter is 9
counter is 8
counter is 7
counter is 6
counter is 5

class: center, middle , inverse, farsi

دستور‌های خط فرمان لینوکس


class: inverse, farsi

tr

  • فرض کنید فایل sample.txt با متن داخلی زیر را در اختیار داریم
cat ./sample.txt
April is the cruelest month, breeding
lilacs out of the dead land, mixing
memory and desire, stirring
dull roots with spring rain

class: inverse, farsi

tr

  • با دستور tr می‌تونیم یه سری پترن‌ها را به پترن‌های دیگه ترجمه کنیم
cat sample.txt |  tr aeoui AEOUI
AprIl Is thE crUElEst mOnth, brEEdIng
lIlAcs OUt Of thE dEAd lAnd, mIxIng
mEmOry And dEsIrE, stIrrIng
dUll rOOts wIth sprIng rAIn
  • اینجا، هر حرف صدا داری که با حروف کوچیک نوشته شده باشه را به حروف بزرگ تبدیل می‌کنیم

class: inverse, farsi

tr

  • می‌تونیم بدون cat هم از tr استفاده کنیم. اینجوری خروجی رو توی stdout می‌بینیم
tr aeoui AEOUI  < sample.txt
AprIl Is thE crUElEst mOnth, brEEdIng
lIlAcs OUt Of thE dEAd lAnd, mIxIng
mEmOry And dEsIrE, stIrrIng
dUll rOOts wIth sprIng rAIn

class: inverse, farsi

tr

  • یا همون دستور قبلی رو استفاده کنیم ولی خروجی رو توی یه فایل بنویسیم
tr aeoui AEOUI  < sample.txt > output.txt
cat output.txt
AprIl Is thE crUElEst mOnth, brEEdIng
lIlAcs OUt Of thE dEAd lAnd, mIxIng
mEmOry And dEsIrE, stIrrIng
dUll rOOts wIth sprIng rAIn

bash's People

Contributors

iamvee avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.