Showing posts with label cut. Show all posts

Print limited characters per a line

Printing first 80 characters in a line.Below are the different ways to do it.
Cut
cut -c1-80 your_file
Awk
awk '{print substr($0,0,80)}' your_file
Sed
sed -e 's/^\(.\{80\}\).*/\1/' your_file
Perl
perl -lne 'print substr($_,0,80)' your_file
perl -lpe 's/.{80}\K.*//s' your_file

Grep
grep -o "^.\{80\}" your_file