sed: Function cannot be parsed.
I have a shell script 'Test.sh'
echo "Enter The File Name" read FILE_NAME echo "Enter The First Column" read Col RowNum=2 Diff=4 Data=" " ColNumFrom=`grep -i $Col Data.csv | cut -d "," -f2` ColNumFrom=`expr $ColNumFrom - 1` sed -i "${RowNum}s@\(.\{$ColNumFrom\}\).\{$Diff\}@\1${Data}@" $FILE_NAME >> NewFile Data.csv is AA01, AA02,73 AB01,303 AB02,83 When I run the File for Col 'AA02', it works fine but for Col as 'AB01', is throws following error sed: Function 2s@\(.\{302\}\).\{4\}@\1 @ cannot be parsed. Please Help me solve the error... |
what is the maximum line length sed can handle?
|
According to http://sed.sourceforge.net/sedfaq6.html
Code:
6.6.1. Maximum line length |
For AAO2 nothing happens (well, not true, and empty NewFile gets created).
Plus you have the file-name hard-coded in the line with the grep ;} |
Some versions of sed do not work with n greater than 255 in \{n\}
This regular expressions tutorial (written for Solaris) mentions the limitation. http://www.grymoire.com/Unix/Regular.html#uh-8 Also http://www.gnu.org/software/sed/manu...ar-Expressions |
can i increase the length from 255 to 755 or something?
|
You could try building 755 up in sections using bash arithmetic. I don't know if this will work with all versions of sed. I only have GNU sed, which has an upper limit of 32767 for \{n\}.
Code:
ColNumFrom=755 |
is there no other way by which a sed command can edit the file beyond 255th character?
|
Quote:
Note that one post suggests the limitation only as part of the {n} construct--which I assumed to refer to a regex that is repeated n times. Whatever the limitations actually ARE, you are not going to change them except by: a. Using a different version b. Getting the source code and compiling your own special flavor. |
Quote:
eg Code:
echo "Enter The File Name" |
in man pages, there is a WARNING
The hold space is limited to 8192 characters. What does this mean? |
Quote:
|
So if this hold space is 8192, & i am trying to edit 2nd row, 302th character (where record/row length = 735 character, so i am editing 1037th character of the file), sed should not through any error.
But i am getting an error that function can't be parsed. |
Quote:
the limitations of 255 mentioned earlier refer to the multiplier {} and not to the total buffer-space. Which version of sed are you using? |
i am using sed.
I dont have any other version.:( (ssed GNU sed etc) I can see the trailer as "HP-UX Release 11i: November 2000" in man pages, bt no version details. |
All times are GMT -5. The time now is 07:05 AM. |