[Ubuntu] made to execute the script | packing a bunch of commands executed sequentially

Reference article:


 

Command line programming, we often need to perform a few specific command, when our high usage of these commands, and these commands is time to execute the order, you may wish to write a script, one-click execution.

In developing Chi V3s, we need to make a system image, copy and paste each time and really troublesome.
Not much to say, directly on the code:
First create sh file: gedit makeimg.sh
open makeimg.sh editing window, paste the code below:

#!/bin/bash
dd if=/dev/zero of=flashimg.bin bs=32M count=1 &&
dd if=u-boot/u-boot-sunxi-with-spl.bin of=flashimg.bin bs=1K conv=notrunc &&
dd if=linux/arch/arm/boot/dts/sun8i-v3s-licheepi-zero-dock.dtb of=flashimg.bin bs=1K seek=1024 conv=notrunc &&
dd if=linux/arch/arm/boot/zImage of=flashimg.bin bs=1K seek=1088 conv=notrunc &&
dd if=jffs2.img of=flashimg.bin bs=1K seek=5184 conv=notrunc

The first line is the script statement, the following is the command you want to execute, may need to be replaced according to their own command.

But do note that after each command (the last line of command behind do not need) , remember to add "&&", the role is to distinguish between adjacent command and the command is executed sequentially.

----------------
Disclaimer: This article is CSDN bloggers' @ technology white "in the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/qq_40860568/article/details/100153681


Application examples:

Question: being given directly execute executable program: error while loading shared libraries: liblcm.so.1: can not open shared object file: No such file or directory

Answer: LD_LIBRARY_PATHa Linux environment variable name, the environment variable is mainly used to specify the default look for other path other than the path of the shared library (DLL).

1. Create sh script: run_QPlayBack.sh, Fu execute permissions

In the directory run_QPlayBack.sh, open a terminal and execute the command:

chmod +x run_QPlayBack.sh

2. Edit run_QPlayBack.sh script

open with vim, pressing i enters the input mode (also called edit mode): 

#!/bin/bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./ &&
./QPlayBack

After editing, press the ESC button to return to normal mode (lower left corner - INSERT - disappears);

In the normal mode, press: wq leaving vim after storage.

3. Execute the script run_QPlayBack.sh

 In the directory run_QPlayBack.sh, open a terminal and execute the command:

./run_QPlayBack.sh

 

Guess you like

Origin www.cnblogs.com/hhxxgdd/p/11847503.html