cat /tmp/file1 | \ awk '{ if ($0~"RHEL" || $0~"rhel" || $0~"CENT" || $0~"cent") print $0 " --os-family \"Redhat\"" if ($0~"Ubuntu" || $0~"UBUN" || $0~"ubun") print $0 " --os-family \"Debian\"" };' > /tmp/file2
Wednesday, January 8, 2020
AWK with if-else loop example
Bash script with AWK example - in this example, if the line contains one type of keywords, I wanted to add something in the end of same line and if the line contained something else, I wanted to add some other text.
Labels:
awk,
Linux fundamentals
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment