Lookup YARN Acls capacity scheduler queue users from /etc/passwd

Following is an awk script that I use in TextWrangler as a Text Filter. This script generates the required awk and grep commands to lookup /etc/passwd file.

#!/bin/sh
# gawk '{match($0,"([a-zA-Z]+).acl_submit_applications=(.*)",a); if(a[1] != "") print a[1] "\t" a[2] }'
# awk -F: '/zeppelin/{print $1 "\t" $5}' /etc/passwd
gawk '{
    match($0,"([a-zA-Z]+).acl_submit_applications=(.*)",a); 
    
    if(a[1] != "" && a[2] ~ "[^ ]*") {
      str = a[2]
      gsub(/ ,/, "", str)
      gsub(/,/, "|", str)
      
      str_grep = "grep -E \"" str "\" /etc/passwd"
      str_awk = "awk -F: '\''/" str "/{print $1 \"\\t\" $5}'\'' /etc/passwd"
      #Bad code below
      if (str == " ") { str_grep = "";  str_awk = ""}
      
      print a[1] "\t" a[2] "\t" str_grep "\t" str_awk
    }
  }'

 

Location of Text Wranglers’ Text Filter folderĀ ~/Library/Application Support/TextWrangler/Text Filters

Create a shell file and paste the contents above to use it from TextWrangler.

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *