English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Method to extract server images using shell scripts

Shell Tutorial

Shell is a program written in C language, which serves as a bridge for users to use Linux. Shell is both a command language and a programming language.
Shell refers to an application that provides an interface for users to access the services of the operating system kernel.

Ken Thompson's sh is the first Unix Shell, Windows Explorer is a typical graphical interface Shell.

Firstly, what is SHELL?

  (1)shell is a command-line interpreter.

  (2)is the bridge of communication between users and the Linux kernel, belonging to middleware. See the figure below

  (3)Interactive process: shell accepts user input commands => delivers the command to the Linux kernel => after the kernel processes it, it returns to the shell interpreter => returns to the user understandable content

Secondly, let's see how shell completes the action of extracting server images.  

To extract all images under the server, for the convenience of display, I only extract the first10line.

 find /home/wwwroot/default/ -"name "*.png" -"or -"name "*.jpg" -"or -"name "*.jpeg" -"or -"name "*.gif"


The extracted images need to replace the path with the http method. Next, let's see the shell syntax. The syntax is very straightforward, so I won't say more.

for i in 
`find /home/wwwroot/default -"name "*.png" -"or -"name "*.jpg" -"or -"name "*.jpeg" -"or -"name "*.gif" | sed 's/^\/home\/wwwroot\/default\///g'`;
do 
echo http://211.159.175.39/shell_img/$i;
done

The sed command is to replace the path with the one you want. It handles characters such as slashes.  

After execution, see the figure below:

Summary

The above-mentioned is the method of using shell script to extract server images introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave a message, and the editor will reply to everyone in time. I also want to express my sincere gratitude to everyone for supporting the Yelling Tutorial!

Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (When reporting, please replace # with @) for reporting, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.

You May Also Like