Skip to content

Instantly share code, notes, and snippets.

View patricktrainer's full-sized avatar
💭
🪠

Patrick patricktrainer

💭
🪠
View GitHub Profile
@patricktrainer
patricktrainer / get_following_word.sh
Created August 17, 2022 23:42
Get the word next to another word.
#!/bin/bash
# The code below does the following:
# 1. Loop through each .sql file
# 2. Loop through each line in each file
# 3. If the line contains the word, then print the next word.
#
# invoke with: ./get_following_word.sh <word>
#
for file in ./**/*.sql; do
awk '{for (I=1;I<NF;I++) if ($I == word) print $(I+1)}' word="$1" "${file}"