Submitted Questions

  • Print nth column of pattern

    How to print nth column of a pattern/file without using awk,cut commands?

    Nawaz

    • Jun 9th, 2017

    Read the lines by character and count the number of spaces (delimiter). When the count of space (delimiter) is n-1 (keeping in mind you need nth column), print the characters before next space (delimiter).

    Tigran Petrosyan

    • Oct 24th, 2014

    I=1; while read line; do for word in $line; do if [[ $i -eq 2 ]]; then echo $word; i=1; break; else ((i++)); fi; done; done < input.txt