The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
send a message through email to 5 people using unix script? MARY76 Shell Programming and Scripting 2 02-05-2007 03:29 PM
What are people using for Centralized Unix Administration x96riley3 UNIX for Dummies Questions & Answers 0 09-27-2006 12:03 PM
Unix for MS People NEWX UNIX for Dummies Questions & Answers 2 04-13-2006 11:19 AM
Is Unix a Network operating system for Macintosh computers Bill1263 UNIX for Advanced & Expert Users 2 09-05-2002 11:50 PM
Unix for Macintosh Icarus Where do I download LINUX & UNIX? 9 11-15-2001 01:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-27-2006
Laurel Maury Laurel Maury is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 3
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
  #2 (permalink)  
Old 09-27-2006
hitmansilentass hitmansilentass is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 37
Not sure of MAC, anyways try this one


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

Or with awk


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

  #3 (permalink)  
Old 09-27-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,965
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 (permalink)  
Old 09-27-2006
[MA]Flying_Meat [MA]Flying_Meat is offline
Registered User
  
 

Join Date: Sep 2002
Location: San Fran
Posts: 131
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?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0