[SOLVED] Insert column with awk or sed between two columns
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.
Might need to go and re-read your favourite awk website of man page.
And I might need to get a degree in Computer Science...I've read the awk websites and they weren't much help - they're basically MAN pages, not detailed tutorials - which is why I posted this in the NEWBIE forum.
Quote:
$0 - The entire line up until the record separator
$1 - $NF - fields based on FS value
yeah, that was no help. Sorry. Thankfully it was only ~750,000 lines. I got what I needed in Excel in like 2 minutes. I'd still like to learn more about sed and awk by example because those MAN pages assume too much prior knowledge.
What grail is attempting to clarify, is that the first field is $1, the second is $2. $0 is the entire record.
Were you to simply update your variables in the first attempt above, you might be pleasantly surprised ... easier than excel by far.
What grail is attempting to clarify, is that the first field is $1, the second is $2. $0 is the entire record.
Were you to simply update your variables in the first attempt above, you might be pleasantly surprised ... easier than excel by far.
Oh man, that was the difference. THAT was way faster than the alternative I used. Thanks syg00! You see, this is what I'm talking about with the manuals and guides, none of them made that clear. "0" is typically considered the first of whatever or so I was told by a programmer long ago. Sigh.
Which is why I was trying to educate and not spoon feed you an answer
thanks for your assistance but with all due respect the best way to learn is by example/mimicry. You're VERY advanced. I'm not. I really had no idea what you meant. The man page you sent is more clear than the two I was reading. It was kind of like trying to learn German by reading der Speigel and only knowing a few German phrases.
I see gnu.org has a guide for sed, I'll read that one too
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.