cut magic

cut and print 2 to rest of all columns.
# echo www.domain.com | cut -d"." -f2-
domain.com

cut and print 2nd column.
# echo www.domain.com | cut -d"." -f2
domain

cut and print first to 2nd column.
# echo www.domain.com | cut -d"." -f-2
www.domain

cut and print 1st,3rd columns.
# echo www.domain.com | cut -d"." -f1,3
www.com

cut and print 1st and 4 to rest of all columns.
# echo a.b.c.d.e | cut -d"." -f4-,1
a.d.e

cut and print 1 to 3 and 5th columns.
# echo a.b.c.d.e | cut -d"." -f1-3,5
a.b.c.e

cut and print 3rd character.
# echo abcde | cut -c3
c

cut and print 3-rest of characters.
# echo abcde | cut -c3-
cde

cut and print first-3 of all characters.
# echo abcde | cut -c-3
abc

Leave a Reply

Your email address will not be published. Required fields are marked *