cut
→ All posts
FreeBSD/Linux
Cut out selected portions of a text file
# man page example, works well with known file formatting
cut -d : -f 1,7 /etc/passwd
# over-engineered example: print last item of $PATH environment variable
# i.e. use cut command without knowing the position of last item
cut -w -f $(echo $PATH | \ # feed -f flag with the right $(number)
> sed "s/:/ /g" | \ # change : to whitespace
> wc -w | xargs) \ # word count, xargs strips wc whitespace; -f now fed
> <(echo $PATH | sed "s/:/ /g") #
/home/dell/bin