Quote:
Originally Posted by Laurel Maury
Hi,
I'm trying to use sed to process some files on Macs running OSX. Anyone know anything about Macs and sed?
Here's the problem
sed 's/^/ /g' test_file > endfile
(there are spaces betwen the second and third /, but the forum software compresses them)
This should put spaces at the beginning of every line (I'm fairly sure, tho' not positive about this). But it's only putting spaces at the beginning of the first line of a file.
I created a test file, and this worked fine for all lines in the document.
A few questions:
Which OS X version,
what application created your text file,
does it work on a simple* test document?
*pico mysed
this
is
a
text
file
then sed 's/^/ /g' mysed > mysed2
I copied the command you tried, from this web page, and inserted a couple more spaces, changed the file names and voila.
My guess is it will work if you use pico, or some other strictly text editor for the test document, but not for the specific text document you tested previously.
Why? Because it probably is not "strictly" a unix text document. It probably has some whacky formating code or somesuch, maybe it doesn't even have \n in it. Maybe the line endings are \r. That might cause the problem you're seeing.
There is a way to see these codes, but I don't recall the commands. Anyone?