UNIX in the MacIntosh (for sed people)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX in the MacIntosh (for sed people)
# 1  
Old 09-27-2006
UNIX in the MacIntosh (for sed people)

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.

Any thoughts? I've already had problems with Mac's idea of sed and the \n newline character (Mac's sed doesn't seem to recognize it). And downloading GNU's sed onto all the machines here (aobut 200) isn't an option, but we've got a lot of files to process.

Any help would be appreciated.

Best wishes,
Laurel Smilie
# 2  
Old 09-27-2006
Not sure of MAC, anyways try this one

Code:
sed 1,$"s/^/' '/g"

Or with awk

Code:
awk '{gsub("^"," ")}'

# 3  
Old 09-27-2006
OSX doesn't have GNU sed? That's a suprise to me, what version does it have? If it's a nonstandard version, maybye it has nonstandard flags to make it use normal linefeeds...

Use code tags for code, it'll use a monospace font and not compress the spaces. Like {code} stuff {/code} but with [ ] instead of { }.
# 4  
Old 09-27-2006
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Looking for application that simplifies for non techie people accessing unix/linux env

Hello all I searched the net but didn't found any application that wrap ssh connection with GUI interface so that non techie people can connect to unix/linux accounts and work with files , so it will looks like there familiar Microsoft windows directory structure . Please don't answer with ..... (6 Replies)
Discussion started by: umen
6 Replies

2. UNIX for Dummies Questions & Answers

macintosh

hello, i am new to this forum. i own a macbook pro running mac os x 10.5.2 leopard. just wondering, if these forums will help me? i work a lot in an application called terminal, it is apples command line. i like programming and have questions, like there was a post about text scrolling, the... (2 Replies)
Discussion started by: jamesapp
2 Replies

3. UNIX for Advanced & Expert Users

send a message through email to 5 people using unix script.

Hi All, I want to send a message through email to 5 people in unix script. Please let me know, how to do it.Please do reply it is urgent. Thanks, Mary. (3 Replies)
Discussion started by: MARY76
3 Replies

4. Shell Programming and Scripting

send a message through email to 5 people using unix script?

Hi All, I want to send a message through email to 5 people in unix script. Please let me know, how to do it.Please do reply it is urgent.How to do it?Please reply.thanks! Thanks, Mary. (2 Replies)
Discussion started by: MARY76
2 Replies

5. UNIX for Dummies Questions & Answers

What are people using for Centralized Unix Administration

What are people using for Centralized Unix Administration? I'm not just talking user administration, I'm also talking system administration. I prefer a customized SSH enivonment that allows me to connect to server after server quickly to perform multiple tasks at once. I know there are products... (0 Replies)
Discussion started by: x96riley3
0 Replies

6. UNIX for Dummies Questions & Answers

Unix for MS People

Hello Unix gods! I'm probably a pretty good programmer (on the windows/web/asp/iis side of things) with a good background in IT, but am looking for a new and fresh challenge, hence, I purchased a Sun Ultra5 system with Solaris 7 installed!! I'm quite good when it comes to "IBM compatibles" and... (2 Replies)
Discussion started by: NEWX
2 Replies

7. UNIX for Dummies Questions & Answers

Macintosh user needs help with pop3d

Hi folks! I am not a power user, and have been able to enable Postfix to run on my Macintosh. It was a little bit difficult for me. But I payed good attention, while following an Internet Tutorial. Postfix version 2.1.5 I can send out emails, from local accounts or even from other... (0 Replies)
Discussion started by: fundidor
0 Replies

8. UNIX for Advanced & Expert Users

Is Unix a Network operating system for Macintosh computers

I am in the process of reading up on and learning about linux,and as i read, i am seeing that it was built off of the unix system platform,and i also believe that it is used in the mac computer field,i would like to know if this is true, and if i should learn about the macintosh computer... (2 Replies)
Discussion started by: Bill1263
2 Replies

9. Where do I download LINUX & UNIX?

Unix for Macintosh

Hi all, I'm a Mac-user (imac se at the moment), using Mac OS 9.1 I really want to learn how to work with unix-systems. What is the best place for me to start? Where can i download a system? Can i still use my imac as a software basestation for an ibook running OS 9.1? It seems like i... (9 Replies)
Discussion started by: Icarus
9 Replies
Login or Register to Ask a Question