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

相关推荐
逊嘘5 分钟前
【Java语言】抽象类与接口
java·开发语言·jvm
Half-up8 分钟前
C语言心型代码解析
c语言·开发语言
也无晴也无风雨22 分钟前
代码中的设计模式-策略模式
设计模式·bash·策略模式
Source.Liu29 分钟前
【用Rust写CAD】第二章 第四节 函数
开发语言·rust
monkey_meng30 分钟前
【Rust中的迭代器】
开发语言·后端·rust
余衫马33 分钟前
Rust-Trait 特征编程
开发语言·后端·rust
monkey_meng36 分钟前
【Rust中多线程同步机制】
开发语言·redis·后端·rust
Jacob程序员38 分钟前
java导出word文件(手绘)
java·开发语言·word
小白学大数据1 小时前
正则表达式在Kotlin中的应用:提取图片链接
开发语言·python·selenium·正则表达式·kotlin
VBA63371 小时前
VBA之Word应用第三章第三节:打开文档,并将文档分配给变量
开发语言