在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):gelisam/hawk开源软件地址(OpenSource Url):https://github.com/gelisam/hawk开源编程语言(OpenSource Language):Haskell 99.8%开源软件介绍(OpenSource Introduction):HawkTransform text from the command-line using Haskell expressions. Similar to awk, but using Haskell as the text-processing language. ExamplesIn Unix the file
The first field is the username. We can use Hawk to list all usernames as follows: > cat /etc/passwd | hawk -d: -m 'head'
root The We could of course have achieved identical results by using awk instead of Hawk: > cat /etc/passwd | awk -F: '{print $1}'
root While Hawk and awk have similar use cases, the philosophy behind the two is very different. Awk uses a specialized language designed to concisely express many text transformations, while Hawk uses the general-purpose language Haskell, which is also known for being concise, among other things. There are many standard command-line tools that can be easily approximated using short Haskell expressions. Another important difference is that while awk one-liners are self-contained, Hawk encourages the use of libraries and user-defined functions. By adding function definitions, module imports and language pragmas to Hawk's user-configurable prelude file, those functions, libraries and language extensions become available to Hawk one-liners.
For instance, we could add a > echo 'takeLast n = reverse . take n . reverse' >> ~/.hawk/prelude.hs
> seq 0 100 | hawk -a 'takeLast 3'
98
99
100 For more details, see the presentation and the documentation. InstallationTo install hawk, either run You should be ready to use Hawk: > hawk '[1..3]'
1
2
3 The first run will create a default configuration file into
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论