Python Pioneers: A Beginner's Guide ๐Ÿ‡ช๐Ÿ‡น
8.82K subscribers
346 photos
40 videos
24 files
64 links
Welcome to Python Pioneers: Empowering Ethiopian students to embark on their coding journey.

๐Ÿ“ข Channel: @python_pioneers
๐Ÿ‘ฅ Group: @python_pioneers_chat
Download Telegram
What is Shell Scripting?

Shell Scripting shell แ‰ แ‰…แ‹ฐแˆ แ‰ฐแŠจแ‰ฐแˆ แ‰ฐแŠจแ‰ณแ‰ณแ‹ญ แ‰ตแ‹•แ‹›แ‹žแ‰ฝแŠ• แŠฅแŠ•แ‹ฒแˆแŒฝแˆ แ‹จแˆ˜แŒปแ แˆ‚แ‹ฐแ‰ต แАแ‹แข

Shell operating system แ‹แˆตแŒฅ command interpreter(แŠ แˆตแ‰ฐแˆญแŒ“แˆš) แАแ‹, แˆˆแˆแˆณแˆŒ Bash in Unix-like systems.

It allows users to automate tasks, perform system administration, manipulate files and directories, and interact with the operating system through the command line interface.

แŠจแАแ‰ฃแˆˆแˆแ‹ commands execute แŠฅแ‹ซแˆจแŒแŠ• แ‹จแАแ‰ แˆจแ‹ แ‰ฐแˆซ แ‰ แ‰ฐแˆซ แŠฅแ‹จแƒแแŠ• แАแ‰ แˆญ แŒแŠ• shell script แ‰ แˆ˜แŒ แ‰€แˆ the whole bunch of code in our script, sequence แŒ แ‰ฅแ‰† execute แŠฅแŠ•แ‹ฒแˆ†แŠ• แŠฅแŠ“แˆจแŒˆแ‹‹แˆˆแŠ•แข

Getting started: Steps to write a shell script

#1. Choose a shellแก แ‰ แŒฃแˆ แ‹จแ‰ฐแˆˆแˆ˜แ‹ฐแ‹ Shell bash (Bourne Again Shell) แˆฒแˆ†แŠ• แ‹ญแˆ…แˆ แ‰ แ‰ฅแ‹™ Unix-like systems แˆ‹แ‹ญ default แАแ‹แข

#2. Setup your environmentแก Open a terminal or command prompt on your system.

#3. Script แ‹แ‹ญแˆ แˆ˜แแŒ แˆญแก Text editors like Vim, nano, or any other other text editor แ‰ แˆ˜แŒ แ‰€แˆ แ‰ .sh extension แ‹จแˆšแ‹ซแˆแ‰… script แˆ˜แแŒ แˆญแฃ แˆˆแˆแˆณแˆŒ new_script.sh

Extension แˆแŠ•แˆˆแ‹ แŠจfile name แ‰€แŒฅแˆŽ แ‹จแˆšแˆ˜แŒฃ แ‹จแ‹แ‹ญแˆ‰แŠ• type แ‹ˆแ‹ญแˆ format แ‹จแˆšแАแŒแˆจแŠ• แ‹จfile name part แАแ‹แข แˆˆแˆแˆณแˆŒ sample.txt แˆ‹แ‹ญ แ‰ แˆ˜แŒจแˆจแˆป แ‹ซแˆˆแ‹ .txt extension แ‹จแˆšแАแŒแˆจแŠ• แ‹แ‹ญแˆ‰ text file แŠฅแŠ•แ‹ฐแˆ†แА แАแ‹แข

#4. Set Permissions (Unix-like Systems): Make the script executable by running chmod +x new_script.sh.

...แ‹ญแ‰€แŒฅแˆ‹แˆ

#ShellScripting

@python_pioneers
@python_pioneers
๐Ÿ‘5โšก3๐Ÿ‘1
This media is not supported in your browser
VIEW IN TELEGRAM
More On Shell Scripting
แ‹จvideoแ‹แŠ• แˆ›แ‰ฅแˆซแˆชแ‹ซ แŠจแ‰€แŒฃแ‹ญ post แˆ›แŒแŠ˜แ‰ต แ‰ตแ‰ฝแˆ‹แˆ‹แ‰ฝแˆ ๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡

#ShellScripting

@python_pioneers
@python_pioneers
More On Shell Scripting
แ‰ฃแˆˆแˆแ‹ แŠฅแŠ•แ‹ณแ‹จแАแ‹ แ‹จshell scripting แ‹‹แŠ“ purpose tasks automate แˆˆแˆ›แˆจแŒ แАแ‹แข แˆ›แˆˆแ‰ตแˆ commands แŠ แŠ•แ‹ต แ‰ แŠ แŠ•แ‹ต แŠฅแ‹จแƒแแŠ• terminal แˆ‹แ‹ญ execute แŠจแˆ›แˆจแŒ แ‰ แŠ แŠ•แ‹ด script แŠฅแŠ•แ…แแŠ“ แˆตแˆ…แ‰ฐแ‰ต/ bug แŠฅแˆตแŠจแˆŒแˆˆแ‰ แ‰ต แ‹ตแˆจแˆต every lines will be executed one after the other.

แˆˆแˆแˆณแˆŒ แก
แŠ แŠ•แ‹ต "Hello, Ethiopia!" แ‰ฅแˆŽ terminal แˆ‹แ‹ญ print แ‹จแˆšแ‹ซแˆจแŒ แ‹จshell script แŠฅแŠ•แƒแแฃ แˆ™แˆ‰ แˆ‚แ‹ฐแ‰ฑแŠ• แˆˆแˆ˜แˆจแ‹ณแ‰ต แŠจแˆ‹แ‹ญ แ‹ซแˆˆแ‹แŠ• แŠ แŒญแˆญ video แ‰ฐแˆ˜แˆแŠจแ‰ฑแข

1. แ‰ แˆ˜แŒ€แˆ˜แˆชแ‹ซ text editor แŠฅแŠ•แŠจแแ‰ณแˆˆแŠ• (such as nano, vim, or gedit) and hello.sh แ‹จแ‰ฐแ‰ฃแˆˆ file แŠฅแŠ•แˆแŒฅแˆซแˆˆแŠ•แข แŠฅแ‹šแˆ… video แˆ‹แ‹ญ แ‹จแ‰ฐแŒ แ‰€แˆแАแ‹ text editor nano แАแ‹แข
nano hello.sh
แŠจแ‹› แ‹แ‹ญแˆ‰ แ‹แˆตแŒฅ แŠฅแАแ‹šแˆ…แŠ• แАแŒˆแˆฎแ‰ฝ แŠฅแŠ•แ…แ‹แˆˆแŠ•

#!/bin/bash
# This is a comment
echo "Hello, Ethiopia!"
#line_1 "#!/bin/bash" /shebang line/ แ‰ฅแˆˆแŠ• แŠจแˆ‹แ‹ญ แ‹จแƒแแАแ‹ scriptu แ‰ bash shell interpreter execute แŠฅแŠ•แ‹ฒแˆ†แŠ•แˆแŠ• แАแ‹ แข

แ‰ programming comment แ‹จแˆแŠ•แˆˆแ‹ a text still in the code yet not executed, แˆˆ shell Scripting comment แˆ˜แƒแ แŠจแˆแˆˆแŒแŠ• textun แ‰ "#" แŠฅแŠ•แŒ€แˆแˆซแˆˆแŠ•แข

แˆˆแˆแˆณแˆŒ the 2nd line of our script does nothing because it is a comment.

Interpreter แ‹จแˆแŠ•แˆˆแ‹ itself is a program that translates and executes code written in a high-level programming language in to machine code(which is understandable by the computer).

2. แŠจแ‹› แ‰ แ‹ƒแˆ‹ we will save our hello.sh script file.
nano แ‹จแˆแ‰ตแŒ แ‰€แˆ™ แŠจแˆ†แА แˆ˜แŒ€แˆ˜แˆชแ‹ซ แˆ‹แ‹ญ "CTRL - O" to save the file then "CTRl - X" to exit from the text editor.

3. แ‰ แ‰€แŒฃแ‹ญ แ‹จแˆแŠ“แˆจแŒˆแ‹ script แ‹แ‹ญแˆ‰แŠ• executable แˆ›แˆจแŒ แАแ‹: แ‹ˆแ‹ญแˆ permission แˆ˜แˆตแŒ แ‰ต แАแ‹ for the file to be executed.
แˆตแˆˆ file permission แ‰ แ‰€แŒฃแ‹ญ แŠฅแŠ•แˆ›แˆซแˆˆแŠ• but for now just do this.
chmod +x hello.sh
4. แ‰ แˆ˜แŒจแˆจแˆป แ‹จแ‰€แˆจแŠ• แАแŒˆแˆญ scriptun run แˆ›แˆจแŒ แАแ‹แฃ to do this:
./hello.sh
แ‹ญแˆ„ script run แˆตแŠ“แˆจแŒˆแ‹ bash interpreter แ‰ แˆ˜แŒ แ‰€แˆ the code runs and a text "Hello, Ethiopia!" is printed in our terminal, this was done by the command "echo".

แ‹ญแˆ… แ‰€แˆ‹แˆ แˆแˆณแˆŒ แАแ‹ แˆŒแˆŽแ‰ฝ แŠฎแ‹ถแ‰ฝแŠ• แ‰ แˆ˜แƒแ shell Scripting แ‰ฐแˆˆแˆ›แˆ˜แ‹ฑแข

#ShellScripting
#PythonPioneers

@python_pioneers
@python_pioneers
@python_pioneers
๐Ÿ‘3๐Ÿ”ฅ2