Tag Archives: bash

Use sed to replace last character after matching a line

If you are a coder like me we tend to discover after we have made a script that we need to change something on multiple lines. Recently I have a script whereby added a “log_message” function which would echo a … Continue reading

Posted in Command Line FU | Tagged , , | Leave a comment

Remove any potential special characters or spaces from an IP address using AWK

Got stuck earlier in an interesting regex mystery and I command-line FU’d an AWK Solution. PROBLEM I want to strip out all spaces and/or special characters from an IP address PROCESS I know how to validate an IP address no … Continue reading

Posted in Command Line FU, Linux | Tagged , , , , , | Leave a comment

sed print only line AFTER string match

File Example

Posted in Command Line FU | Tagged , , | Leave a comment

Cut all characters after last match using SED

Output

Posted in Command Line FU | Tagged , , | Leave a comment

Increment a variable name within a BASH loop

Example

Posted in Command Line FU | Tagged , , | Leave a comment

Include Line Numbers to bash set-x debug output

There are times you need to view the line numbers in a bash script to view script execution. Within bash ‘set -x’ either at the shell, or within the bash script will display debug output. To include line numbers you … Continue reading

Posted in Command Line FU | Tagged , | Leave a comment