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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Append Header and Trailer balzzz UNIX for Dummies Questions & Answers 2 01-06-2008 05:19 AM
Checking the header and trailer for a given string and if not found, exit out of the er_ashu UNIX for Dummies Questions & Answers 2 11-08-2007 06:55 AM
Copy all the files with time stamp and remove header,trailer from file ksrams UNIX for Dummies Questions & Answers 35 07-30-2007 11:15 AM
Removing trailer from a flat file!!! kumarsaravana_s UNIX for Dummies Questions & Answers 12 06-24-2007 12:53 AM
Count No of Records in File without counting Header and Trailer Records guiguy Shell Programming and Scripting 2 06-07-2007 09:15 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-06-2006
Registered User
 

Join Date: Mar 2006
Posts: 14
TRAILER!! Output

I run my script which i wrote which has the job of inputing a line of text into a certain place in a file. When i run the script i get an error which relates to one line of code as shown below:

sed -n '$count p' $2 | cpio -o >> tempfile

The error i keep getting from this line is this:

sed: -e expression #1, char 3: Extra characters after command
1 block
sed: -e expression #1, char 3: Extra characters after command
1 block

and so on as long as it loops. Anyway i don't know why this is happenning and the file that i am inputing into tempfile contains a brunch of stuff that looks like this:

^@^@^@^@^@^@Çq^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^@^@^@^K^@^@^@^@^@TRAILER!!!^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@Çq^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^@^@^@^K^@^@^@^@^@TRAILER!!!^@



Why is this being output to the file and is their anyway to fix my orignal problem?
Reply With Quote
Forum Sponsor
  #2  
Old 04-06-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
use double-quotes
Reply With Quote
  #3  
Old 04-06-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
That looks a little like untranslated EBCDIC text. Anyway, instead of sed which doesn't seem to like the data, try dd which is meant for playing with stuff like this.
dd will replace cpio and sed. dd will also translate EBCDIC to ASCII if you want.

man dd
Reply With Quote
  #4  
Old 04-06-2006
Registered User
 

Join Date: Mar 2006
Posts: 14
sed

I had it in double qoutes but in despair took them off. Cheers on the dd I'll have a look at it and see if it helps.

Last edited by Quesa; 04-06-2006 at 08:08 AM.
Reply With Quote
  #5  
Old 04-06-2006
Registered User
 

Join Date: Mar 2006
Posts: 14
I've looked at dd and I don't know if it will work with what I am trying to do. From what i gather dd seems very good at copying with control on blocks. But i need to input a line in a particlar place in a file. The place is to do with line number. So i have loop like so:

while [ "$linenum" -gt 0 ]
do
sed -n ' "$count" p ' $2 | cpio -o >> tempfile

if [ "$linenum" -eq "$reqline" ]
then
echo $1 >> tempfile
fi
reqline=<various calc's>
count=`expr "$count" + 1`
linenum=`expr "$linenum" - 1`
done

I don't think dd will work in this context (I may be wrong ) as it won't let me specfic the line number. It will only let me skip a number of blocks and do things like that. Anyway my knowledge of dd is not complete so I may be wrong.
Reply With Quote
  #6  
Old 04-06-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
once again - use double-quotes:
Code:
sed -n "${count}p" myFile
Reply With Quote
  #7  
Old 04-06-2006
Registered User
 

Join Date: Mar 2006
Posts: 14
You where right it works when I use the line :
sed -n "$count p" $2 >> tempfile

but not when i use:
sed -n '$count p' $2 >> tempfile


Yet at the command promt if I use say somthing like
sed -n '3 p' $2 >> tempfile
it works fine. Anyway thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
cpio

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:05 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