Skip to content

Instantly share code, notes, and snippets.

@tanzyy
Created April 13, 2017 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanzyy/382cf71812bc8d99d9407517100dec37 to your computer and use it in GitHub Desktop.
Save tanzyy/382cf71812bc8d99d9407517100dec37 to your computer and use it in GitHub Desktop.
#!/bin/bash
#This script shows how to pass shell variable to awk using option -v
index_pos="4"
search_string="31/Mar/2017:03:58:38"
cat ~/Desktop/tempp.txt | awk -v pos=$index_pos -v ss=$search_string '{ if($pos==ss) print $0 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment