I want to print the Nth column to the Mth column of a table; for example:
1 2 3 ... n ... m ... X & $ # ! @ $ % ( *
n ... m # ! ( *
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
a perl one-liner
perl -slane 'print join " ", @F[$n-1 .. $m-1]' -- -n=5 -m=8 file
Do you mean that you want to print between two columns such as from the 4th column to the 10th column?
cut -d ' ' -f 4-8 table.txt
That will print columns 4-8.
cut will work well for this problem as long as the column delimiter is a single character.
Edit The cat wasn't necessary and I changed the delimiter to a space to fit your table.