I have a formatted list of processes (top output) and I’d like to remove unnecessary information. How can I remove for example the second word+whitespace of each line.
Example:
1 a hello
2 b hi
3 c ahoi
Id like to delete a b and c.
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 can use
cutcommand.--complementdoes the inverse. i.e. with-f2second field was choosen. And with--complementif prints all fields except the second. This is useful when you have variable number of fields.GNU’s cut has the option
--complement. In case,--complementis not available then, the following does the same:cut -d’ ‘ -f1,3- file
Meaning: print first field and then print from 3rd to the end i.e. Excludes second field and prints the rest.
Edit:
If you prefer
awkyou can do:awk {$2=""; print $0}' fileThis sets the second to empty and prints the whole line (one-by-one).