Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Now I want to replace the 3rd column with space but I cant use anything like cat file.txt |awk '{$3=" "};1' because I want the 'C' to be still there. ie the output should be have a blank 3rd column with C as its heading(only the numbers should be removed)
Thanks ! It worked. But I want the change to be reflected in the original file, and not just print the output. How can I do that?
Also,the output was like:
Please use ***[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, bolding, colors, or other fancy formatting.
The majority of command line tools, including awk, only print to stdout and do not alter the input file. And you can't just redirect the output back into the same input file, as the redirection operator will overwrite it before it even gets read. For the most part you need to output to a temporary file or variable first, and then replace the original.
It could be any valid field number, 1 is just easy, and it will restructure the line with OFS between each field. Change it to 1 (one) and see the difference.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.