Mar 18: Paste
I've always loved Unix and vi and despair at those who prefer to faff around on Windows trying to edit files with an operating system and editors that, yes, are much more friendly but are hopelessly limited. The advent of Google (and yes, I'm more than aware of previous search engines) has added to the Unix/vi combination when I desperately need to solve a text processing problem in a hurry. I'm no awk expert!
Last Friday was one of those desperate moments. I was in the midst of an environment refresh and was rolling the test database forward using the Production control file. Each time I got a new copy of the control file to roll forward a bit more (because we use the control file as the RMAN repository), I wanted to rename the 170+ datafiles that make up the database. I had an ordered list of test and production files and their respective paths, but in two seperate files. All I wanted was to mingle the lines from each file into one file, with the two filenames on a single line.
I won't go into the details and I definitely won't get into extended dialogues about alternative solutions and why they didn't apply here*. This is a simple blog about the Unix paste command, which came to my rescue. (That link is to the very first Google result - no research or careful review.)
* No doubt those conversations will crop up, but I'm in course slide hell at the moment so don't expect much response from me.
Yikes! Hadn't seen this one mentioned since the last millenium!
Relax: just kidding.
The so-called "Unix relational commands": cut, paste, cat and pr.
Thanks for reminding me of the sanity of the Unix command line. "paste" saved me many times, together with "cut". Long before the rodent-based GUI was the norm.
And I still regularly use that same command-line. In fact, I'm finding myself more and more doing it in Windows: there are quite a few environments there that make it easier to do things in the old "cmd" screen.
Thoroughly recommend gvim for Windows, if you feel so inclined.
Hadn't seen this one mentioned since the last millenium!
Someone needs to keep them alive
There may be a tech-political edge to this post, too. I keep seeing people FTP-ing text files to Windows so that they can manually play around with them because they don't see Unix as a fantastic text-manipulation o/s
I was really desperate last Friday too and it was with a small contented sigh that paste baled me out. Next time it'll be cut or sed (a particular favourite because I'm too much of a lightweight for awk. I've got the sed and awk book and I can't say it helped me much ...)
sed and awk are lovely tools... I remember the Christmas I gave my wife "sed & ark in a nutshell"... that was when the relationship went downhill
Do you have the original awk book? If I didn't have that, I'd probably have to finally learn perl.
I hear what you're saying about ftp'ing to Windows, the proprietary environment I'm working in has a built-in to download the program files to whatever client editor is set up. So each editor screws with the formatting, and I can only diff my own files 'cause I'm the only one who actually works on the server. One of these days I need to set up a prettifier...
As I was in the middle of typing this, someone called me over to show me something, and they were manually deleting lines from a 79K line sqlplus listing file in notepad... thinking that is more efficient than figuring out a simple where clause...
"I can't stand it." - Charlie Brown
I have the O'Reilly sed and awk book (sounds like the same one as Pete). In the end, sed did most of what I wanted and awk just seemed too obtuse. There are only so many languages I want to learn!
Very cool! as i'm always saying i've never been finished to learn. Really i use windoz visual editor to do such things. I like command line but all of us have to use the better tools to do a job. I will take a note about paste,cut and pr commands, because they may be useful.
The thing is, I'm pretty comfortable with people FTP-ing files to Windows to use WYSIWYG editors. I understand that.
What I don't really understand is why they don't sometimes FTP Windows text files up to the Unix servers for the text processing.
Whatever tool is best for the job!
(and yes, I know there are quite a few Unix-tools-on-Windows alternatives but, when the file you're working on already sits on a Unix server, I do wonder ...)
Ah yes, after [mumble]teen years of Solaris sysadmin'ing, I keep only a small number of books on my desk for emergency reference : Solaris Internals, and the vi O'Reilly reference book. To me, perhaps the two most useful books ever.
Awk, sed & Perl - all essential if you're serious about text processing. It's true Perl can do anything that the other two can, but sometimes it's just easier to use sed/awk for simple one-liners on the command line.