cat vs sed vs awk (lemmy.sdf.org)
submitted 3 years ago* (last edited 3 years ago) by to c/linux@lemmy.ml
 
you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 3 years ago* (last edited 3 years ago) (2 children)

cat
while read -r l; do echo "$l"; done <

cat -e
while read -r l; do echo "$l"$; done <

cat -n
n=0; while read -r l; do n="$((n+1))"; printf '%5d %s\n' "$n" "$l"; done <

cat -b
n=0; while read -r l; do [ -n "$l" ] && n="$((n+1))" && printf '%5d %s' "$n" "$l"; echo; done <

  • source
  • hideshow 2 child comments