I found some ways to pass external shell variables to an awk script, but I'm confused about ' and ". First, I tried with a shell script: $ v=123test $ echo $v 123test $ echo "$v" 123test Then trie...
I have a file like the following and I would like to print the lines between two given patterns PAT1 and PAT2. 1 2 PAT1 3 - first block 4 PAT2 5 6 PAT1 7 - second block PAT2 8 9 PAT1 10 - th...
I am learning awk and I would like to know if there is an option to write changes to file, similar to sed where I would use -i option to save modifications to a file. I do understand that I could us...
I'd like to print a single line directly following a line that contains a matching pattern. My version of sed will not take the following syntax (it bombs out on +1p.) which would seem like a simple ...
Using awk or sed how can I select lines which are occurring between two different marker patterns? There may be multiple sections marked with these patterns. For example: Suppose the file contains: ...
How do I find and replace every occurrence of: subdomainA.example.com with subdomainB.example.com in every text file under the /home/www/ directory tree (recursive find/replace)?
My server is having unusually high CPU usage, and I can see Apache is using way too much memory. I have a feeling, I'm being DOS'd by a single IP - maybe you can help me find him? I've used the follo...
How would an awk script (presumably a one-liner) for removing a BOM look like? Specification: print every line after the first (NR > 1) for the first line: If it starts with #FE #FF or #FF #FE, ...
I have a text file with the following format. The first line is the "KEY" and the second line is the "VALUE". KEY 4048:1736 string 3 KEY 0:1772 string 1 KEY 4192:1349 string 1 KEY 7329:2407 string 2...
I'd like to execute an gawk script with --re-interval using a shebang. The "naive" approach of #!/usr/bin/gawk --re-interval -f ... awk script goes here does not work, since gawk is called with th...