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

相关推荐
chen_227几秒前
qt加ffmpeg制作简易录屏工具
开发语言·qt·ffmpeg
历程里程碑3 分钟前
LeetCode 283:原地移动零的优雅解法
java·c语言·开发语言·数据结构·c++·算法·leetcode
卜锦元3 分钟前
Golang后端性能优化手册(第一章:数据库性能优化)
大数据·开发语言·数据库·人工智能·后端·性能优化·golang
虾说羊5 分钟前
java中的反射详解
java·开发语言
特立独行的猫a5 分钟前
C++23 std::expected 详解:告别传统错误码和异常,构建现代健壮代码
开发语言·c++23·expected·错误码处理
leaves falling9 分钟前
c语言-根据输入的年份和月份,计算并输出该月份的天数
c语言·开发语言·算法
云栖梦泽9 分钟前
鸿蒙企业级工程化与终极性能调优实战
开发语言·鸿蒙系统
Eloudy11 分钟前
通过示例看 C++ 函数对象、仿函数、operator( )
开发语言·c++·算法
leaves falling12 分钟前
c语言将三个整数数按从大到小输出
c语言·开发语言
superman超哥12 分钟前
仓颉高性能实践:内存布局优化技巧深度解析
c语言·开发语言·c++·python·仓颉