Posted on 09/11/2010 9:24:44 AM PDT by Ernest_at_the_Beach
sed
No, don't assume /bin/cat is available, but that's one way to do it.
cat can be done by:
#!/bin/sh while read line; do echo "$line" done
which of course doesn't always work in "modern" systems because of how the semantics of echo have been perverted. In that case, you'll want `print -'.
The same technique can be extended to avoid retyping the whole file. For example to replace all lines matching "bar" with "FRee Republic" you would do:
while read line; do if [ x"$line" = xbar ]; then echo FRee Republic else echo "$line" fi done < file > file.new mv file file.bak; mv file.new file
It may seem trivial now, but this was the first time anything close to this had ever been done in an OS before. Stephen Bourne created magic.
Another handy cat hint, if you're using X11 and need to copy/paste some text while removing formatting (say you're copying formatted text from a browser into a plaintext file):
Yes, very clever. I do that too, except with ed, then typing `a'. Usually the time I'm trying to cut & paste into something that doesn't quite want to take it is a web browser with a stupid text field that gets wiped out if something else is wrong on the page and that way I can save the text to a file if I have to.
If I need to wipe out formatting, it's usually easier to paste it into a handy XEmacs *scratch* buffer. That is, of course, a matter of taste. :-)
You were right. Yes, you do need mv. I was typing in the answer, see the post above.
I did Unix System V/386 device drivers around 1990, so I don't have any plausible deniability and have been careful to stay away from "standard" Unix utilities since then.
The installation problems associated with Linux show the how and why that it isn’t a commercial product, nor can it be.
Installation problems? My PCLinuxOS distro is just about the most painless install out there. Easier than Ubuntu, there’s no difficulties at all. 20 minutes and it’s done, and you’re up and running.
>For those, like me, who started their understanding of OS’s using DOS commands in Windows 3.1 learning the entire new commands for Linux is daunting. I suppose if I immersed myself in it I would catch on but I just don’t have the time.
“The novice Unix user is always surprised by Unixs choice of command
names. No amount of training on DOS or the Mac prepares one for the
majestic beauty of cryptic two-letter command names such as cp, rm, and
ls.” - Unix-Hater’s Handbook
>I have a box that runs Linux Ubuntu that I use in the basement. It runs great. Adding things to it just takes too much time.
>
>I heartily endorse Linux distros though. They seem to be pretty stable and run without any real hassle.
I dislike *nix for many, many reasons; it’s [IMO] poorly designed [I believe it to be a direct result of being designed in-parallel w/ C].
Personally I’d rather use a well-designed OS using a read high-level language like Ada rather than ones built with the pretend high-level languages C & C++.
>2: Microsoft Excel. Simply put, Excel and Word are head and sholders above the competition. There are alternatives, sure (open office, google docs etc) but none that really measure up - especially in the spreadsheet market. As long as MS retains that competitive edge, Windows will be the preferred platform on business computers.
I *HATE* Excel with the hatred of a million burning suns. Management types tend to be idiots who want to use spreadsheets ALL THE TIME... especially when the intended use of the information therein would be *FAR* better handled by a database.
I merely strongly dislike Word; it’s truly a horrible program... especially when you delete some text/paragraph and it alters formatting [usually in awkward ways]. If proper formatting is a requirement for your document, such as legal or scientific works, I’d strongly recommend WordPerfect above Word simply because of the superior manner it handles formatting. (I still use WP11 in preference to MS Word.)
>#5 is Linuxs biggest shortcoming. The Linux community can pump up OpenOffice as much as they want - but it will never replace MS Office. Microsoft will also never release a Linux version, for obvious reasons.
The biggest problem with Open-Office [IMO] is that it is blindly following/cloning MS Office.
Didn’t you and I have a chat about Unix/OSes/design a while back?
>That box changed my life. I had started programming in C a few years before, but the Unix environment and I immediately got along like old buddies, and it’s still my favorite OS.
Hm, as an old-hand at C I’m sure you’ve got a lot to say on the various shortcomings/pitfalls therein.
Shortcomings and pitfalls of C? Those have been listed and recited and documented and argued for 30+ years. I needn't repeat them yet again.
I prefer simple tools that do exactly what I want, to complex tools that make selected tasks trivial and other tasks impossible. I prefer driving a manual transmission car, for example.
C is still the language of choice for much of the non-application programs written today. System stuff, drivers, utilities, embedded devices, controllers, etc. You know, the stuff that actually DOES something beyond painting pretty pictures on a user's screen. :)
The two main reasons (IMO) that anybody uses anything else are:
> The two main reasons (IMO) that anybody uses anything else are:
> 1. In the hands of a less-than-skilled programmer, C will happily do what they tell it to do, which is most often erroneous. It’s not for the lazy or inept.
That’s odd; IMO the C/Linux mentality encourages laziness — In my personal experience I’ve often come across the response “why don’t you download the/a unix/linux source” when my peers [I’m a CS major; one final class left] hear that I’d like to make an OS.
There’s also the “an example online,” cut-and-paste, and then tailor it to your program’s needs crowd; but I’m hesitant to link that with the C/Unix mindset as it seems to be more language agnostic & it’s also possible that the shift in a lot of the curriculum to Java influenced/germinated that a bit more than C.
> There are much safer languages, Nanny-May-I style, for those programmers.
Ah, like Ada.
I actually REALLY like the amount of things (checks & optimizations) Ada compilers can do at COMPILE-TIME; some of which is quite impressive.
> 2. String and database processing in C can be very tiring and frustrating, and a lot of business software processes strings and databases. There are special-purpose languages that excel at those tasks.
Strings and databases processing can be tiring/frustrating w/o C; I think that those two areas are inherently more... picky/difficult.
For strings, some of it is the native language [English in our case] where the different forms and exceptions all have to be handled: pluralities is a perfectly good example. Goose —> Geese; but Moose -/-> Meese. Mouse —> Mice; but House -/-> Hise. Matrix —> Matrices; does Dominatrix —> Dominatrices?
Databases are similar in that the storage-forms in the database might not be the best forms for the types of manipulations you intend to do.... and the multiple valid formats for the same data-fields might be structurally different (yet presenting the same information); consider street addresses, especially international ones.
>C is still the language of choice for much of the non-application programs written today. System stuff, drivers, utilities, embedded devices, controllers, etc. You know, the stuff that actually DOES something beyond painting pretty pictures on a user’s screen. :)
Honestly I think that Ada would be a better choice for embedded/system stuff; its development *was* first commissioned by the DOD specifically for handling the unique/”non-standard” hardware of the various weapon-systems, like missile-launch control — and especially considering that the spec/implementation separation is much more ‘definite’ than C; I mean how many times have you had to work around header-files exposing some implementation detail in C?
> Honestly I think that Ada would be a better choice for embedded/system stuff; its development *was* first commissioned by the DOD specifically for handling the unique/non-standard hardware of the various weapon-systems, like missile-launch control...
Funny you mention that. In the early 80's I was designing an embedded controller for geostationary comm-sat attitude control systems, and I was strongly encouraged at that time to look at Ada for the implementation (which I did, of course). But it wasn't a requirement at the time, since I was first doing prototype proof-of-concept design work, so I could choose my own poison (I chose C).
I agree that Ada has some very strong advantages for that sort of work.
Open Office has come a long way... its been ported to Windows and MacOSX. Microsoft does make a version for MacOSX that is generally regarded as superior to its Windows version. But open source is good an OO will do 90% of what Microsoft’s expensive office suite does. There really is much good to say about free in these tight times.
Microsoft has Open Office converters so the issue of formatting is bunk. And Open Office can read MS Office files. We’re getting close to an interoperability standard so it doesn’t matter what office suite you run.
I think you’re disputing the guy I was responding to.
Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.