#shell

find匹配文件名

目录内容:

text  text.bak

希望从中找到text.bak。使用find实现。

·1min·李岩
find匹配文件名

sed使用备注

sed功能介绍

先看下官方的介绍

Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).
While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and
is consequently more efficient. But it is sed’s ability to filter text in a pipeline which particularly distinguishes it from other types of
editors.

大概的意思,是面向流的文本编辑工具。一般用来对文件中的文本进行替换等操作。
以下备注一些常用的操作方式了。

·2min·李岩
sed使用备注

shell-访问字符串同名变量

考虑以下场景:
期望通过给定的变量名称var_str,打印出该名称对应的变量值${var_str}。使用指令eval可以很方便的实现:

var_str="1213";
ned_param_name="var_str";
eval echo '$'"${ned_param_name}";

输出结果为1213;

·1min·李岩
shell-访问字符串同名变量