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

相关推荐
70asunflower7 分钟前
堆与栈:C 语言内存管理的核心概念
c语言·开发语言
wjs20248 分钟前
Rust 输出到命令行
开发语言
xingpanvip9 分钟前
星盘接口开发文档:日返比接口指南
开发语言·lua
初心未改HD10 分钟前
Go语言Goroutine与Channel深度解析
开发语言·golang
SilentSamsara11 分钟前
Python 并发基础:threading/GIL 与 multiprocessing 的选型逻辑
服务器·开发语言·数据库·vscode·python·pycharm
FreeGo~13 分钟前
手撕C++】内存管理:感受C++的魅力吧
开发语言·c++
m0_6403093013 分钟前
解决 Python 报错:ModuleNotFoundError: No module named ‘pkg_resources’
开发语言·python
编码浪子18 分钟前
Rust 1.95 稳定版解读与生态新动向
开发语言·后端·rust
asdzx6720 分钟前
告别手动校对:使用 Python 对比两个 PDF 文档的差异
开发语言·python·pdf
Rust研习社21 分钟前
Rust 操作 Redis 从入门到生产级应用
开发语言·redis·后端·rust