Need advice about which tool to choose?Ask the StackShare community!
AWK vs Grain: What are the differences?
Developers describe AWK as "A language for text processing, data extraction and reporting". A data-driven scripting language consisting of a set of actions to be taken against streams of textual data – either run directly on files or used as part of a pipeline – for purposes of extracting or transforming text, such as producing formatted reports. On the other hand, Grain is detailed as "A strongly-typed functional programming language". Grain is a strongly-typed functional programming language built for the modern web. Unlike other languages used on the web today (like TypeScript or Elm), Grain doesn’t compile into JavaScript. Grain complies all the way down to WebAssembly, and is supported by a tiny JavaScript runtime to give Grain access to web features that WebAssembly doesn’t yet support.
AWK and Grain can be categorized as "Languages" tools.
AWK and Grain are both open source tools. It seems that Grain with 1.21K GitHub stars and 21 forks on GitHub has more adoption than AWK with 206 GitHub stars and 41 GitHub forks.
If you have a file (demo.txt
) that has 3 columns:
Column-1 Column-2 Column-3
Row-1a Row-2a Row-3a
Row-1b Row-2b Row-3b
Row-1c Row-2c Row-3c
Row-1d Row-2d Row-3d
Row-1e Row-2e Row-3e
and you want to only view the first column of the file in your CLI, run the following:
awk {'print $1'} demo.txt
Column-1
Row-1a
Row-1b
Row-1c
Row-1d
Row-1e
If you want to print the second column of demo.txt
, just replace $1
with $2