Introducing a less common concept: embedding documents

Today, Ah Ming introduces a less common concept:

Embedded document

The English name is Here Documents.

That is what you saw in the shell script.

Cat <

First come to a piece of shell code:

#!/bin/bash

Cat > 1.txt <

Hello

My

Name

Is aming.

This's a test text.

EOF

After running this script, a 1.txt file will be generated with the following contents:

Hello

My

Name

Is aming.

This's a test text.

This usage is Here Documents.

Here "EOF" is called an identifier, and can be replaced with other strings, such as ABC, 123, etc., you define it as a å•¥, but to ensure that it is before and after, do not cause confusion with other strings.

Usually people are used to writing EOF, which is easy for others to recognize. Just like "the shell script name ends with .sh".

Here Documents needs to pay attention to the last identifier (EOF)

Must be written in the top

Of course, it doesn't have to be cat <

Wc -l <

1

2

3

EOF

There is not much to say about the role of Here Documents.

Here I only talk about a typical usage: in the shell script you need to call the expect script, then the expect script needs to be written in advance, and is an extra file.

At this point, you can use Here Documents to write the contents of the expect script to the specified file, and then call it.

The advantage of this is that a shell script is done, no need to write an additional expect script to facilitate management.

Introducing a less common concept: embedding documents

Absolute Encoder

Absolute rotary Encoder measure actual position by generating unique digital codes or bits (instead of pulses) that represent the encoder`s actual position. Single turn absolute encoders output codes that are repeated every full revolution and do not output data to indicate how many revolutions have been made. Multi-turn absolute encoders output a unique code for each shaft position through every rotation, up to 4096 revolutions. Unlike incremental encoders, absolute encoders will retain correct position even if power fails without homing at startup.

Absolute Encoder,Through Hollow Encoder,Absolute Encoder 13 Bit,14 Bit Optical Rotary Encoder

Jilin Lander Intelligent Technology Co., Ltd , https://www.jilinlandermotor.com