awk/Q/How can I extract the first column?
Properties
- logseq-entity
- Logseq/Entity/Question, Logseq/Entity/Card
How can I extract the first column? card
My Answer
AI Answer
- AI/Response
- Short answer: use
awk '{print $1}'—$1is the first whitespace-delimited field. awksplits each line into fields on whitespace by default. Fields are numbered$1,$2, …$NF(last field).- The
-Fflag sets the field separator to any character or regex. Without it,awkcollapses consecutive spaces/tabs into a single separator. - Reference: GNU awk manual — Fields