You are not logged in.

#1 2005-10-24 14:25:46

sven
Member
Registered: 2005-02-01
Posts: 311

[SOLVED] sed not accepting a long string (Bash)

I would like to use the following commands to read a text from file into variable and then append the text to a certain place inside another text. I am using includeRules as "anchor" that will be overwritten to indicate the place for the text.

test=`cat textfile`
sed -i 's|^.includeRules.*$|#includeRulesn"'${test}'"|' $othertextfile

After executing these commands, I get "/bin/sed: Argument list too long". What program could I use instead of sed to enter the text to its place?

Offline

#2 2005-10-24 14:31:38

sven
Member
Registered: 2005-02-01
Posts: 311

Re: [SOLVED] sed not accepting a long string (Bash)

Even Perl doesn't seem to like that long string: when I try:

perl -i -wpe "s/includeRules/$test" $othertextfile

I also get the same error: /usr/bin/perl: Argument list too long

Offline

#3 2005-10-24 14:36:53

sven
Member
Registered: 2005-02-01
Posts: 311

Re: [SOLVED] sed not accepting a long string (Bash)

I found my answer. In other parts of the code I can run the sed command multiple times and this way have smaller strings in a variable.

EDIT: the whole problem was actually caused because I had many characters included that were interpreted as control signs, like  and "". This messed up sed logic.

Offline

Board footer

Powered by FluxBB