- Bash Cookbook
- Ron Brash Ganesh Naik
- 242字
- 2021-07-23 19:17:36
Using SED and AWK to remove/replace substrings
Again, when we need to remove a pesky character or remove sections of strings upon occurrence, we can always rely on these two powerful commands: sed and awk. And while we saw that Bash does indeed have a similar functionality built-in, the full tools are able to offer the same and more complex functionality. So, when should we use these tools?
- When we care less about the speed that might be gained by using the built-in functionality of Bash
- When more complex features are needed (when programming constructs like multi-dimensional arrays are required or editing streams)
- When we are focused on portability (Bash might be embedded or a limited version and standalone tools may be required)
Stream editor (SED) is a handy text manipulation tool that is great for one-liners and offers a simple programming language and regex matching. Alternatively, AWK is also powerful and arguably more than SED. It offers a more complete programming language with a variety of data structures and other constructs. However, it is better suited when working with files such as CSVs, which may contain fields or structured data, but SED can be better when working with text substitutions when working with pipes (for example, grep X | sed ... > file.txt).
- 手機(jī)安全和可信應(yīng)用開發(fā)指南:TrustZone與OP-TEE技術(shù)詳解
- C++面向?qū)ο蟪绦蛟O(shè)計(jì)(第三版)
- Java多線程編程實(shí)戰(zhàn)指南:設(shè)計(jì)模式篇(第2版)
- Mastering NetBeans
- 數(shù)據(jù)結(jié)構(gòu)和算法基礎(chǔ)(Java語(yǔ)言實(shí)現(xiàn))
- Django Design Patterns and Best Practices
- INSTANT OpenNMS Starter
- Building Minecraft Server Modifications
- 程序員修煉之道:通向務(wù)實(shí)的最高境界(第2版)
- Python面向?qū)ο缶幊蹋簶?gòu)建游戲和GUI
- Mastering ArcGIS Enterprise Administration
- JavaScript全棧開發(fā)
- Perl 6 Deep Dive
- 亮劍C#項(xiàng)目開發(fā)案例導(dǎo)航
- Hands-On Full Stack Development with Angular 5 and Firebase