📜  sed 替换文件 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:51:45.399000             🧑  作者: Mango

代码示例6
# Basic syntax using awk:
awk '{gsub(regex, substitution_text, $field#); print $0;}' input_file
# Where:
#    - gsub is a function that replaces every regular expression (regex)
#        match with substitution_text. 
#    - $field# is optional but can be used to specify a particular field
#        where gsub should operate. (This is useful if you want to 
#        restrict the substitutions to a specific column)

# Example usage:
awk '{gsub(" ","",$0); print $0;}' input_file
# This replaces every space " " with nothing "", thereby eliminating all
# whitespace from the file