5月2日是什么星座| 凤凰男是什么意思| 12月24号是什么星座| 脑供血不足食补吃什么| 口臭去医院挂什么科室看病| 维生素b族什么时候吃最好| 月台是什么意思| 3ph是什么意思| 1963年属什么| 包皮龟头炎吃什么药| 过期药品属于什么垃圾| 体格检查是什么意思| 雌激素过高吃什么药| 强迫症吃什么药效果好| candies什么意思| 英国用什么货币| 吃什么食物补钙最快| 国防部长是什么级别| 偏头痛有什么症状| 女性睾酮高说明什么| 冬天手脚冰凉是什么原因怎么调理| 歇斯底里是什么意思| 高压低是什么原因| 彼岸花代表什么星座| 递增是什么意思| 男人为什么会得前列腺炎| 前夕是什么意思| 秋天什么水果成熟| 吃什么可以丰胸| 藏在我回忆里的那个人什么歌| 布洛芬治什么| 跛行是什么意思| 扁桃体发炎严重吃什么药好得快| 早泄是什么| hbsag阳性什么意思| 结膜炎吃什么消炎药| 梦到亲人死了是什么征兆| 额头上长斑是什么原因造成的| 牙齿有黑线是什么原因| 水果有什么| 三百年前是什么朝代| 心肌损伤是什么意思| 脂肪肝是什么症状| 胎菊泡水喝有什么功效| 风热咳嗽吃什么药| 关节痛挂号挂什么科| 一动就大汗淋漓是什么原因| 王加几念什么| 千年等一回是什么生肖| 有气质是什么意思| 什么是贸易顺差| 双脚浮肿是什么原因| 涩是什么意思| 阁僚是什么意思| 吸狗是什么意思| 夏天穿什么鞋子| 黄丫头是什么鱼| 硕是什么意思| 扁平疣是什么样子图片| 心脏做造影是什么意思| 预防是什么意思| 久坐伤什么| 植物神经紊乱挂什么科| 法老是什么意思| 6.30什么星座| 玛丽苏什么意思| 什么色什么异| 脐带血能治疗什么病| 阴沟肠杆菌是什么病| 上腹疼是什么原因| 正月十九是什么日子| 睡觉就做梦是什么原因| 合是什么生肖| 医保卡什么样子| 眼睛红了是什么原因| 尿血应该挂什么科| 喝酒前喝什么不容易醉又不伤胃| 44岁属什么| 肝硬化是什么引起的| 什么是抽动症| 茴三硫片主治什么| 补气血吃什么药| 顺丰为什么这么快| 每个月14号都是什么情人节| 松解手术是什么| 紫药水是什么| 龟头敏感用什么药| 什么是天丝| 足跟疼痛用什么药| 额头上长小疙瘩是什么原因| 什么是良心| 胆囊息肉有什么症状| 一个人自言自语的说话是什么病| 6月12日什么星座| 梦见水代表什么| 以讹传讹什么意思| 懿代表什么意思| 确幸是什么意思| 孩子第一次来月经要注意什么| 手忙脚乱是什么意思| 007什么意思| 逃之夭夭是什么意思| 啵啵是什么意思| 糖尿病吃什么菜最好| 甲鱼是什么| 人间四月芳菲尽的尽是什么意思| 肝多发小囊肿什么意思| 昱字五行属什么| 才高八斗什么生肖| 人这一生什么最重要| 青枝骨折是什么意思| 微量泵是干什么用的| 渡劫是什么意思| q热是什么病| 小肠炖什么好吃又营养| 脸上脱皮是什么原因| 什么木头有香味| 8月20号什么星座| 三月二十三是什么星座| 女人吃秋葵有什么好处| 什么护肤品最好用| 鼻子干痒是什么原因| 唯有读书高的前一句是什么| 蛇七寸是什么部位| faleda是什么牌子的手表| 依非韦伦片治什么病的| 人为什么会得脑梗| complex是什么意思| 办身份证需要准备什么| 阎王是什么意思| 师范类是什么意思| 秦始皇为什么叫祖龙| 彪马属于什么档次| 金牛座是什么象星座| 鄂尔多斯是什么意思| gsp全称是什么| 还愿有什么讲究| 跑得最快的是什么生肖| 什么金属最贵| 什么叫肝功能不全| 运费险是什么意思| 怕冷不怕热是什么体质| 肝素帽是什么| 射手座女和什么星座最配| 手上三条线分别代表什么| 嘢是什么意思| 命格是什么意思| 鱼油有什么用| 卤素灯是什么灯| 美容美体是干什么的| 野鸭吃什么| 统战部是干什么的| 吃干饭是什么意思| 腹泻什么意思| 下午四点是什么时辰| 北京市长什么级别| 紫色裤子配什么上衣| 脚后跟干裂起硬皮用什么药| 复检是什么意思| 腋下有异味用什么药| 可尔必思是什么饮料| 被舔是什么感觉| 白洞是什么东西| 直接胆红素高是什么病| 光绪帝叫什么名字| 今天是什么生肖| 火车动车高铁有什么区别| 闭合性跌打损伤是什么意思| 孕早期吃什么| 心肝血虚吃什么中成药| 八府巡按是什么官| 淋病和梅毒有什么区别| 7月30日是什么日子| 开心的反义词是什么| 什么样的疤痕影响当兵| 姨妈是什么意思| upup是什么意思| 出虚恭是什么意思| 常吐痰是什么原因| 涎是什么意思| 为什么尿是红色的| 广东省省长什么级别| 鼻子大的男人说明什么| 水泻拉肚子是什么原因| 儿童超敏c反应蛋白高说明什么| 小孩趴着睡觉是什么原因| 石榴花是什么颜色| 碘伏和络合碘有什么区别| qc是什么| 宝宝半夜咳嗽是什么原因| 窝沟封闭是什么意思| 踢皮球是什么意思| 和合双全是什么生肖| 头重脚轻是什么生肖| 梦到狐狸是什么意思| 白眼狼什么意思| 白猫来家里有什么预兆| 肝风是什么意思| 煞是什么意思| 当医生要什么学历| 痛风能吃什么菜谱大全| 入伏吃什么| 安吉白茶属于什么茶类| 郝字五行属什么| 吃坏东西拉肚子吃什么药| 寒湿吃什么药| 血脂血糖高吃什么食物好| 胃不好吃什么| 胸口疼应该挂什么科| 涮菜都有什么菜| 什么什么的阳光| 今天什么时候下雨| 手脚热吃什么药| 牛鬼蛇神指什么生肖| 蚕豆病是什么病有什么症状| 穿刺是检查什么的| 嘴咸是什么原因| 坐以待毙是什么意思| 西瓜又什么又什么填空| 九天什么月| 不言而喻的喻是什么意思| 兔子吃什么蔬菜| 萎靡不振是什么意思| 孕妇梦见蛇是什么意思| 牙周炎吃什么药| 头疼头晕去医院挂什么科| 6.10号是什么星座| 儿童水痘吃什么药| 文曲星什么意思| 后背有痣代表什么意思| 血糖和尿糖有什么区别| 骨质疏松是什么原因引起的| 什么星星| 果酸有什么作用| 术后病人吃什么营养恢复快| 女人梦到地震预示什么| 海白菜是什么菜| 抄手是什么| 腹膜转移是什么意思| 什么是优质蛋白| 平均血小板体积低是什么原因| hepes缓冲液是什么| 银属于五行属什么| 悬雍垂发炎吃什么药| 蜱虫咬人后有什么症状图片| 油管是什么意思| 囗腔溃疡吃什么维生素| 蚂蝗是什么| 为什么会痛风| 局座是什么梗| sinoer是什么牌子| 红细胞数目偏高是什么意思| 四级残疾证有什么用| 空心菜是什么菜| 字如其人什么意思| s和m是什么意思啊| 什么是帽子戏法| 九个口是什么字| 什么样的柳树| 蜂蜜什么时候喝最好| 无花果吃了有什么好处| movefree是什么药| 8023是什么意思| 标本是什么意思| 百度
Home Computer Tutorials Computer Knowledge Stream Editor (SED): Basics

历史·人文--云南频道--人民网

Mar 20, 2024 pm 03:11 PM
txt editor sed

百度 2创建调解机构,建立商会调解队伍。

Stream Editor (SED): Basics

SED, also known as the Stream Editor, is a very useful tool. It is used to search for a specific word or pattern and then perform some operation on that word or pattern, or in other words, transform it. In Windows, SED is also known as the Find and Replace function. SED comes natively with Ubuntu, so there's nothing to install; just start using it. In this tutorial we will show you how to use SED or Stream Editor.

"S" Command

The most important command in SED or stream editor is the "s" command. The "s" stands for substitute. The syntax is as follows:

/regexp/replacement/flags

So, let's use a file called "file.txt" as an example. Here's what "file.txt" looks like if you trace it:


Let us use an example to illustrate how the "S" command works:

SED‘S/First/Moon/I’file.txt>moon.txt

When an expression like this is given, it means:

    • S—It stands for Substitute.
    • first—The word to search for in a file named "file.txt".
    • "Moon" - "First" is replaced by "Moon".
    • stands for ignore. Let’s ignore this part first.
    • File.txt - The file in which SED will search for patterns or words. In this case, the word "First" would be:
    • Searched in file .txt

    • Moon.txt – When the word “first” is replaced by “Moon”, it will be saved under “moon.txt”.

In SED, the word "first" is replaced with "moon" only in the first instance (this means that if "first" appears multiple times, only the first time will be replaced). This command searches in a file named "file.txt" and once the replacement is complete, the results will be saved to the "moon.txt" file.

This is what it looks like:


Please remember to put "/" where needed. If "/" is omitted, SED will not accept the command.

So far, we have only replaced "first time" with the word "encounter". Now, let's say we want to replace the word "line" (which appears multiple times - four times, to be specific) in the third line with the word "Angel".

How do we specifically target the third line? We use the following command:

SED‘3S/Line/Angel/I’file.txt>angel.txt

So, what just happened here? Okay, "3" specifies the line number. So it comes to the third line. Then, replace "angel.txt" with "line" in the file named "file.txt" and save the converted file as "angel.txt".


What if we want to replace or convert rows "3" and "4"?

Sed‘3,4s/line/Angel/I’file.txt>angel2.txt


Note that in the previous example, we used the "i" flag to represent ignore. Now, we use the "g" flag to represent global.

Let us use an example to illustrate how the "s" command works:

sed’s/line/sun/g ‘file.txt> sun. txt

When an expression like this is given, it means:

G stands for global. Remember, in the first example, when we used the "i" flag, there was only one substitution. Since we added a "g" to global, this means there are alternatives everywhere. So, instead of saying first row, second row, third row and last row, it says first sun, second sun, third sun and last sun. It replaces lines of words (everywhere) in the entire file with the word "sun".


Now, what if we want to select a line based on the words it contains? Well, we can see that the last line of "file.txt" has the word "last". Now, let's say we want "This is the last line". This is the last word." "This is the last ghost. This is the last sentence."

We write as follows:

Sed‘/last/S/line/host/’file.txt>.ghost.txt

The "last" here tells SED to find the line containing the word "last" and then replace the word "line" with "ghost" within that line.


Now, let's say we want to do the opposite. Suppose we want every line without the word "last" to have the word "line" changed to "host". Let's write the following:

Please select ‘/last/! S/line/ghost/’file.txt>.ghost 2.txt

As you can see here, every line except the last line (which contains the word "last") has the word "ghost" replaced with the word "line".


We can also use line numbers to achieve this:

Sed‘3,4! S/行/夜/I’file.txt>night.txt

In this case, lines 3 and 4 are omitted, but every other line has the word "line" replaced by the word "night".

Multiple commands

So, what if you have multiple commands? Would you rather do them one at a time or all at once to save yourself time and work?

What should we do if we want to change the word "first" to "day", the word "second" to "night", and the word "rest" to "ghost"? We do this using semicolons. Don't forget to put the semicolon at the end!

Please note that you do not have to put the "i" flag or the "ignore" flag, but you must put the slash (/) after the conversion phrase.

Now, let us verify it with an example:

sed’s/first/day/;s/second/night/;s/third/ghost/;s/last/ghost/;’file.txt> combination.txt

in conclusion

The Stream Editor, or SED, is a method of selecting words or patterns and converting them. It is effectively the command line equivalent of Windows' "find" and "replace" functions. SED commands can get very complex, but if you at least know the basics, you're ready! SED is actually a very powerful tool. While we can't cover them all in one tutorial, we cover the basics of SED. Essentially, we learned how to convert a specific word using the "s" command, where "s" stands for replacement word. We can replace words with other words, selectively select a line to replace, or even negate it. Either way, this is the easiest part about SED.

Happy coding!

The above is the detailed content of Stream Editor (SED): Basics. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
How to fix file names or extensions that are too long in Windows 11? How to fix file names or extensions that are too long in Windows 11? Apr 22, 2023 pm 04:37 PM

Have you ever faced any issues while transferring files that prevented you from doing so? Well, many Windows users have recently reported that they faced issues while copying and pasting files into a folder, where an error was thrown saying “The file name of the destination folder is too long”. Additionally, some other Windows users expressed frustration when opening any file and said "the file name or extension is too long" and they were unable to open the file. This disappoints users by not allowing them to transfer files to any other folder. While analyzing the issue, we have come up with a series of solutions that may help alleviate the issue and allow users to transfer files easily. If you are in a similar situation, please see this post for more information. Source: http

What is Intel TXT? What is Intel TXT? Jun 11, 2023 pm 06:57 PM

IntelTXT is a hardware-assisted security technology launched by Intel. It can ensure the integrity and security of the server during startup by establishing a protected space between the CPU and BIOS. The full name of TXT is TrustedExecutionTechnology, which is Trusted Execution Technology. Simply put, TXT is a security technology that provides hardware-level protection to ensure that the server has not been modified by malicious programs or unauthorized software when it is started. this one

How to turn off Windows Defender Smart Screen in Windows 11, 10? How to turn off Windows Defender Smart Screen in Windows 11, 10? Apr 26, 2023 am 11:46 AM

Many Windows users have recently reported that they were annoyed when Windows Defender SmartScreen warned users not to launch applications that were not recognized by Microsoft Windows and they had to click on the "Run anyway" option every time. Windows users are unsure what they can currently do to avoid or disable it. After researching the issue, we found that Windows Defender functionality on the system can be disabled through the Settings application or the Local Group Policy Editor or by adjusting the registry files. By doing this, users will no longer have to face the defender SmartScreen. If your system also encounters

Detailed guide to 15 Python editors/IDEs, there is always one that suits you! Detailed guide to 15 Python editors/IDEs, there is always one that suits you! Aug 09, 2023 pm 05:44 PM

There is no better way to write Python code than using an integrated development environment (IDE). Not only can they make your work simpler and more logical, they can also improve programming experience and efficiency. Everyone knows this. The question is, how to choose the best Python development environment among the many options.

How to use ClipChamp: the free Windows 11 video editor How to use ClipChamp: the free Windows 11 video editor Apr 20, 2023 am 11:55 AM

Remember Windows MovieMaker on Windows 7? Since discontinuing Windows MovieMaker, Microsoft hasn't launched any real movie makers. On the other hand, they tried to revamp the Photos app with a small and lightweight built-in video editor. After a long time, Microsoft launched Clipchamp, a better video processor for all Windows 11 devices. In this article, we’ll take a deep dive into how to get everything from the Clipchamp app on your Windows 11 device. How to use Clipchamp – Detailed tutorials are available

How to convert html to txt How to convert html to txt Aug 31, 2023 am 09:23 AM

Methods for converting html to txt include using a text editor, using online conversion tools, and using Python programming. Detailed introduction: 1. To open an HTML file, you can use any text editor, such as Notepad, Sublime Text, etc. To select the content of the entire HTML file, you can press the Ctrl+A shortcut key or drag the mouse to select and copy the selection. The content can be copied by pressing the Ctrl+C shortcut or through the copy option in the right-click menu, opening a new TXT file, using the same text editor, etc.

How to use Clipchamp video editor on Windows 11 and 10 How to use Clipchamp video editor on Windows 11 and 10 Apr 17, 2023 pm 07:55 PM

How to Install and Use Clipchamp on Windows The Clipchamp app is not yet pre-installed on Windows, but this is a future plan. At the same time, you need to download and install Clipchamp first. To install and use Clipchamp on Windows 11 and Windows 10: Download and install Clipchamp from the Microsoft Store. Once installed, search for Clipchamp in the Start menu to launch it. In the Clipchamp window you will need to log in with your Microsoft or Google account, or use your own personal email

Fix the issue where Windows 11/10 login options are disabled Fix the issue where Windows 11/10 login options are disabled May 07, 2023 pm 01:10 PM

Many Windows users have encountered the problem of being unable to log in to Windows 11/10 systems due to failed login attempts or multiple system shutdowns. Users are frustrated because there is nothing they can do about it. Users may forget their PIN code to log into the system, or experience lags when using or installing software, and the system may be forced to shut down multiple times. Therefore, we have compiled a list of the best available solutions that will undoubtedly help consumers solve this problem. To learn more, continue reading this article. Note: Before doing this, make sure you have your system's administrator credentials and Microsoft account password to reset your PIN. If not, wait an hour or so and try with the correct PIN

See all articles
点解是什么意思 什么药治肝最好最安全 复光是什么意思 给老人买什么礼物 什么情况下吃丹参滴丸
什么是玄关在哪个位置 什么鼻子好看 莱卡是什么面料 屁股痒用什么药膏 齐多夫定片是治什么病的
为什么不能用红笔写名字 干细胞是什么东西 铅超标吃什么排铅 时过境迁是什么意思 吃什么降血脂最快最好
班禅是什么级别 9年是什么婚 同工同酬是什么意思 粗糙的什么 嗓子不舒服做什么检查
吃什么对肺好hcv9jop5ns4r.cn 什么是资本家xianpinbao.com 切除脾脏对身体有什么影响hcv8jop8ns8r.cn 厚实是什么意思hcv9jop0ns2r.cn 梦见开车是什么意思hcv9jop1ns3r.cn
很nice什么意思hcv9jop2ns9r.cn 日本为什么经常地震inbungee.com 脑供血不足会导致什么后果hcv7jop6ns8r.cn 碘伏和络合碘有什么区别hcv8jop8ns0r.cn 父母坟上长树意味什么jiuxinfghf.com
男人是什么动物hcv9jop0ns6r.cn 周杰伦什么病hcv7jop9ns5r.cn 心脏早搏吃什么药好hcv9jop6ns7r.cn 油边是什么肉hcv8jop7ns2r.cn 1959年属猪的是什么命chuanglingweilai.com
1973年属牛的是什么命bysq.com 检查尿酸挂什么科hcv8jop8ns1r.cn 灰蓝色是什么颜色hcv7jop5ns3r.cn 经常流鼻涕是什么原因shenchushe.com 梦见抓蛇是什么预兆hcv9jop4ns0r.cn
百度