Awk: Difference between revisions

No edit summary
adds an awk idiom to output ls into tsv
Line 130: Line 130:
awk '{gsub(/^[ \t]+|[ \t]+$/,"");print}'
awk '{gsub(/^[ \t]+|[ \t]+$/,"");print}'
awk '{$1=$1;print}'          # also removes extra space between fields
awk '{$1=$1;print}'          # also removes extra space between fields
# This awk idiom can be used to turn command output into spreadsheet-friendly output by separating it with tabs.
# So for example, the output of the ls command:
ls -l | awk -v OFS="\t" '$1=$1'


# insert 5 blank spaces at beginning of each line (make page offset)
# insert 5 blank spaces at beginning of each line (make page offset)