Bash Scripting Tutorial for Beginners - medium synoposis

Bash Scripting Tutorial for Beginners - medium synoposis

I) Website address

URL path

II) Transcript

2.15) SED

there will come a time where you want to change certain values in text files, and that's where sed or set comes in.

set is a command line tool that will allow you to modify values in a txt file using regular expressions. Let's have a look at an exact example on how to use 'sed' or 'set' to replace values in a text file.

Create a text file called settestdottxt. Let's write down some text here. Now we will replace the word fly with grasshopper, just for demonstration purposes.

so we type in sed, single quotes, s, forward slash , fly forward slash, grasshopper forward slash, G single quotes and then the name o our text file, which is settest dot txt.

Now the structure of this command is a little bit daunting, but let's break it down. First, we start off with the sed command, we open the single quotes and start our regular expression.

First we enter the mode we want to use, which is as for substitute, meaning we want to substitute the next word behind the forward slash with the word after the second forward slash, which is the First one is fly, and the second one is grasshopper.

That after the last, we provide the G which means that we want to do this globally. G stands for globally and globally means that you want to do this across the entire text file, which means that we want to change every occurrence, we close it

相关推荐
R-G-B5 小时前
【02】C#入门到精通——C# 变量、输入/输出、类型转换
开发语言·c#·c# 变量·c#输入/输出·c#类型转换
星河队长5 小时前
C# 软件加密方法,有使用时间限制,同时要防止拷贝
开发语言·c#
史迪奇_xxx5 小时前
10、一个简易 vector:C++ 模板与 STL
java·开发语言·c++
2301_801252225 小时前
Java中的反射
java·开发语言
Kiri霧6 小时前
Rust开发环境搭建
开发语言·后端·rust
weixin-a153003083166 小时前
[数据抓取-1]beautifulsoup
开发语言·python·beautifulsoup
小杨同学yx6 小时前
有关maven的一些知识点
java·开发语言
重生之我要当java大帝7 小时前
java微服务-尚医通-编写医院设置接口下
java·开发语言·sql
寻找华年的锦瑟7 小时前
Qt-QDir
开发语言·qt
小妖6667 小时前
vscode 怎么运行 c++ 文件
开发语言·c++