![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
use double-quotes
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
||||
|
||||
|
once again - use double-quotes:
Code:
sed -n "${count}p" myFile
|
|
#7
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |