The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Splitting the line in multiple lines dd_sh Shell Programming and Scripting 3 03-31-2008 10:54 AM
Line Splitting evoGage UNIX for Dummies Questions & Answers 7 11-30-2005 06:59 PM
Splitting a single line into multiple lines thanuman Shell Programming and Scripting 4 02-23-2005 01:56 AM
splitting the files sounder123 Shell Programming and Scripting 1 06-04-2004 04:03 AM
Splitting a line up lilas UNIX for Dummies Questions & Answers 1 03-12-2001 09:34 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 07-05-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 546
Hi.
Quote:
Originally Posted by spindoctor View Post
And I'm fooling around with the sed string outside of the script, and it's not actually working, period.
s/==Document\n/==\nDocument/
You'll need to be more specific. When something works correctly, we can see that it works. If it fails, there could be a number of reasons, and we need to examine the evidence.

If you run my script with the data1 file, does it work? ... cheers, drl
Reply With Quote
Forum Sponsor
  #9  
Old 07-05-2007
Registered User
 

Join Date: May 2007
Posts: 31
drl,
I don't understand what your data1 file is.
Spin
Reply With Quote
  #10  
Old 07-05-2007
Registered User
 

Join Date: May 2007
Posts: 31
Or rather:
could you explain precisely the syntax in the script to read the data1 file? Is data1 a filename?
Reply With Quote
  #11  
Old 07-05-2007
Registered User
 

Join Date: May 2007
Posts: 31
OK, I tried your script with a file named (data1) and it comes close to working. Except the only thing is that the modified text splits into two lines
-------------Do
cument 7 of 9

I double-checked where the newline character is in the replacement portion of my script and it appears to be right where it should be.
Reply With Quote
  #12  
Old 07-05-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 546
Hi.

OK, that sounds like progress. As I did, please post the script and the output, using CODE tags around them to make them readable ... cheers, drl
Reply With Quote
  #13  
Old 07-05-2007
Registered User
 

Join Date: May 2007
Posts: 31
OK: now I'm trying this again, and for some reason it's failed to work.
Here is the precise script I'm running:
#!/bin/sh
# @(#) s1 Demonstrate sed line split and merge.

set -o nounset
echo " sh version: $BASH_VERSION" >&2
sed --version | head -1

FILE=${1-data1}

echo
echo " Input file:"
nl $FILE

cat >script <<'EOF'
/==Document$/
N
s/==Document\n/==\nDocument/
}
EOF

echo
echo " Output"
sed -f script $FILE |
nl

exit 0
When I run this on data1 (I've taken one of my own text files and renamed it data1 to match the script), it cats the file with numbered lines and then reads this output error:

Output
sed: 1: script: command expected
Reply With Quote
  #14  
Old 07-05-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 546
Hi.

You are missing a curly brace in the script:
Code:
cat >script <<'EOF'
/==Document$/
N
s/==Document\n/==\nDocument/
}
EOF
should be:
Code:
cat >script <<'EOF'
/==Document$/{
N
s/==Document\n/==\nDocument/
}
EOF
cheers, drl
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0