Raspberry Pi_Eng_10.7.2 “;” Command – Execute Multiple Commands Successively


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


10.7.2  ";" Command - Execute Multiple Commands Successively

 

Linux provides a way to enter and process all the commands at once, if you have multiple commands to process. To execute several commands at once in this way, link each command with the ";" command as follows.

 

[Command Format]

exec-command  ;    exec-command

 

[Command Overview]

   This executes several commands at once successively with this command.

   User privilege          -- Normal user.

 

[Detail Description]

   If you enter multiple commands in this way, the command will be executed one by one from the beginning. As the commands are sequentially executed, the execution results of the commands are also sequentially displayed on the screen.

 

[Used Example]

First, let's start by executing the following commands one by one sequentially.

 

pi@raspberrypi ~ $ cd testdata

pi@raspberrypi ~/testdata $ ls -l

total 24

-rw-r--r-- 1 pi pi   62 Apr 23 22:06 customer_list.txt

-rw-r--r-- 1 pi pi  123 Apr 23 22:00 customer_product.txt

drwxr-xr-x 4 pi pi 4096 Apr 25 16:56 TestFolder01

drwxr-xr-x 2 pi pi 4096 Apr 10 22:32 TestFolder02

drwxr-xr-x 2 pi pi 4096 Apr 25 17:11 TestFolder03

-rw-rw---- 1 pi pi  113 Apr 23 17:22 user_guide01.txt

pi@raspberrypi ~/testdata $ cat customer_list.txt

Microsoft

Google

IBM

Facebook

LG

Samsung

Sony

Hewlett-Packard

 

The above command moves to the "testdata" directory, checks what data is in the directory, and checks the contents of the "customer_list.txt" file in that directory.

Then, this time, we will enter all of the commands executed above at the same time and execute them at once.

 

pi@raspberrypi ~ $ cd testdata ; ls -l ; cat customer_list.txt

total 24

-rw-r--r-- 1 pi pi   62 Apr 23 22:06 customer_list.txt

-rw-r--r-- 1 pi pi  123 Apr 23 22:00 customer_product.txt

drwxr-xr-x 4 pi pi 4096 Apr 25 16:56 TestFolder01

drwxr-xr-x 2 pi pi 4096 Apr 10 22:32 TestFolder02

drwxr-xr-x 2 pi pi 4096 Apr 25 17:11 TestFolder03

-rw-rw---- 1 pi pi  113 Apr 23 17:22 user_guide01.txt

Microsoft

Google

IBM

Facebook

LG

Samsung

Sony

Hewlett-Packard

 

If you check the above, it can be seen that the displayed result while the respective commands are executed is displayed sequentially without a special seperator.