stringawk

find a string in a string using awk


here is column 6 in a file:

ttttttttttt
tttttttttt
ttttttttt
tttttttattt
tttttttttt
ttttttttttt

how can I use awk to print out lines that include "a"


Solution

  • If you only want to search the sixth column, use:

    awk '$6 ~ /a/' file
    

    If you want the whole line, any of these should work:

    awk /a/ file
    
    grep a file
    
    sed '/^[^a]*$/d' file