given input
echo 1,2,3,4,5,6,7,8,9,...100
If I want to cut columns 5 I can do
cut -d, -f-4,6-
what if I want to cut multiple non consecutive columns like 5, 7,etc
is there a one liner?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should be able to continue the sequences directly in your existing
-fspecification.To skip both 5 and 7, try:
As you’re skipping a single sequential column, this can also be written as:
To keep it going, if you wanted to skip 5, 7, and 11, you would use:
To put it into a more-clear perspective, it is easier to visualize when you use starting/ending columns which go on the beginning/end of the sequence list, respectively. For instance, the following will print columns 2 through 20, skipping columns 5 and 11:
So, this will print “2 through 4”, skip 5, “6 through 10”, skip 11, and then “12 through 20”.