FEX(1)
π FEX(1) β the field extraction glow-up
okay bestie, welcome to fex, the field extractor from section 1 of the manual. this page is gonna be a whole vibe and also you will learn literally everything, promise π
β¨ NAME β¨
fex β simple and powerful field extraction. that's it, that's the whole name, and yes it is iconic of it to be that brief π
π¦ SYNOPSIS π¦
fex selector ...
πΈ DESCRIPTION πΈ
fex helps you split things by field. the stuff you'd normally do with awk or cut? so much simpler in fex. and there's also stuff in fex you can't do nearly as easily in awk or cut at all β main character energy, no cap π
π SELECTOR SYNTAX π
the selector syntax looks like this, bestie:
<delimiter><selection>...
the delimiter is a single character that's used to split the input string. simple.
the first delimiter is implied as space ' '. you can specify multiple fields with curly braces and numbers split by commas. also valid inside the curly braces {} are number ranges β number ranges are similar to python array slices, split by colon.
the selection is one of the following, and it's what picks which fields get chosen after the delimiter did its little split β¨
- a single number β a single number will select that numbered field. like
awk, fields start at 1.
example selecting third field:
% echo "a b c d e" | fex '3'
a b c d
example selecting the second field delimited by slash:
% echo "/home/hello/world" | fex '/2'
hello
{N:M}β this is a range selection. the syntax for ranges is, in curly braces,N:M, which chooses the fields in range N to M, inclusive π«Ά
example selecting first through fourth fields:
% echo "a b c d e" | fex '{1:4}'
a b c d
{N,M,...}β the syntax for multiple selections is numbers within curly braces.
example selecting first and fifth fields:
% echo "a b c d e" | fex '{1,5}'
a e
{range,field,field,range,field}β combining the above, you can literally select ranges and individual fields using the{...}syntax by delimiting each selection by comma π it's giving versatility
example selecting fields 1 to 3, and 5: {1:3,5}
% echo "a b c d e" | fex '{1:3,5}'
a b c e
{?range,field,...}β the{?...}notation turns on 'non greedy' field separation π the differences here can be shown best by example, first:
% echo "1...2.3.4" | fex '.{1:3}'
1.2.3
% echo "1...2.3.4" | fex '.{?1:3}'
1..
in the first example, fex uses . as delimiter and ignores empty fields. in the second example (non greedy), it does not ignore those empty fields. π©΅
/regexp/β the/regexp/selection will choose only fields that match the given pattern.
example, pulling out words with addr: in it from ifconfig output:
% ifconfig | fex ' /addr:[0-9]/'
addr:127.0.0.1
addr:192.168.0.28
π₯ EXAMPLES π₯
π Show the MTU for a given interface
the mtu in ifconfig output looks like mtu:1500. so have fex split by space, then grab fields matching /mtu:/, split by colon, and choose the last field. chain it, bestie π
% ifconfig wlan0 | fex ' /mtu:/:-1'
1500
π Parse apache logs
pull the IP address (first field by space) and the path requested (2nd field in "GET <path> ...")
% fex 1 '"2 2' < /b/logs/access
65.57.245.11 /
65.57.245.11 /icons/blank.gif
65.57.245.11 /icons/folder.gif
π§ SEE ALSO π§
Project site: <http://www.semicomplete.com/projects/fex>
Source Code: <https://github.com/jordansissel/fex>
π CONTACT π
please send questions to jls@semicomplete.com
file bugs and feature requests at the following URL:
<https://github.com/jordansissel/fex/issues>
alternately, if you prefer email, feel free to file bugs by email. whatever works for you :) π«Ά
patches, ideas, and other contributions by many, nice folks. see the CHANGELIST file for who provided what. β
π AUTHOR π
fex was written by Jordan Sissel. slay.
okay that's the whole page, you're officially fluent in fex now πβ¨ go split some fields, you absolute icon π¦
this page is from FEX(1), dated 2024-11-26 β see you in the man pages, bestie ππ
π¦ where this page comes from
- epel 10: fex 2.0.0-22.el10_0 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms