I tried shell programming

Introduction

This record is used as a memo by a student who is doing JS properly. Don't expect the content.

1. What is shell programming?

The shell interprets the commands entered on the screen and passes them to the kernel. The kernel is the core of the OS. Also, the result output by this kernel is passed to the shell and displayed on the screen. Simply put, it is a function that wraps the core part (kernel) of the OS and interacts with the OS. A shell script is the scripting language used by this shell. In general, shell scripts do not perform complicated tasks, but automate routine tasks, record tasks, and process multiple commands at once. A common shell on Linux is bash, which we will use this time.

2. Creating a working file

touch firstshell.sh


The touch command creates an empty file for Ubuntu if the file with the name passed as an argument does not exist. If it exists, it updates the modification date and time of the file or directory.

3. Write a shell script

To execute this shell script in the bash shell located in / bin / bash, write the following. #!/bin/bash I wanted to make a quiz here, so I added the following.

if [ $yn = "n" ]; then
echo Incorrect answer.
else
echo Correct answer.
fi

The read command seems to be able to receive variables while displaying characters with -p "string". In this script, y or n is assigned to the variable yn. The following is a simple conditional branch, so don't forget to add fi at the end.

4. Try running the shell script program

In order to run the shell script program, it is necessary to give the file permission to execute it, and this time I wrote the following in the console so that it can be executed by all users.

chmod a+x firstshell.sh


Run this script with a relative path including ./

./firstshell.sh


Then it moved smoothly unexpectedly. Yes, protein is protein. No particular error occurred, so this is the end of this time. Thank you for your hard work.

Recommended Posts

I tried shell programming
I tried competitive programming
Shell programming
I tried scraping
I tried PyQ
I tried papermill
I tried django-slack
I tried Django
I tried spleeter
I tried cgo
I tried using parameterized
I tried using argparse
I tried using mimesis
I tried using anytree
I tried running pymc
I tried ARP spoofing
I tried using Summpy
I tried Python> autopep8
I tried using coturn
I tried using Pipenv
I tried using matplotlib
I tried using "Anvil".
I tried using Hubot
I tried using ESPCN
I tried using openpyxl
I tried deep learning
I tried AWS CDK!
I tried using Ipython
I tried to debug.
I tried using Pythonect, a dataflow programming language.
I tried using PyCaret
I tried using cron
I tried using ngrok
I tried using face_recognition
I tried to paste
I tried using Jupyter
I tried using PyCaret
I tried moving EfficientDet
I tried using Heapq
I tried using doctest
I tried Python> decorator
I tried running TensorFlow
I tried Auto Gluon
I tried using folium
I tried using jinja2
I tried AWS Iot
I tried Bayesian optimization!
I tried using the functional programming library toolz
I tried using folium
I tried using time-window
I tried increasing or decreasing the number by programming
I tried Value Iteration Networks
I tried scraping with Python
I tried AutoGluon's Image Classification
I tried to learn PredNet
Try programming with a shell!
[I tried using Pythonista 3] Introduction
I tried using easydict (memo).
I tried face recognition using Face ++
I tried using Random Forest
I tried clustering with PyCaret