Vi - "The replacement pattern is too long"


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Vi - "The replacement pattern is too long"
# 1  
Old 08-20-2008
Vi - "The replacement pattern is too long"

Hi,

I am trying to replace a value in a script with another value. I am performing a vi command from another script.

Code:
vi - ${conf_path}/CANCEL_CD_PART2.txt<<!
:%s/RANGE/${btch_range}/g
:wq
!

'RANGE' is the current value that the parm in the other script has (PARM1=RANGE), along with some other things. I want to substitute it with the value in $btch_range which is

Quote:
145857150104000,145857160204000,145857170104000,145857180204000,145857190204000,145857220104000,1458 57230104000,1458572401
04000,145857250104000,145857260104000,145857290104000,145857300204000,145857310104000,14585801020400 0,145858020204000,14585805010200
0,145858060104000,145858070204000,145858080104000,145858090204000,145858120104000,145858130104000,14 5858140204000,145858150304000
The values in $btch_range cannot be changed since those are batch numbers generated by the system. When I try to execute the vi command shown above, I get the following error:

Quote:
ex: 0602-075 The replacement pattern is too long. The limit is 256 characters.
Any ideas?

Thanks!
# 2  
Old 08-21-2008
in vi editor you can replace max of 256 bytes..
so try using sed externally it allows upto 4000 chars
# 3  
Old 08-22-2008
Used sed

Thanks! It worked. I used the sed command instead, as you suggested.

Code:
sed "s/RANGE/${btch_range}/g" ${conf_path}/CANCEL_CD_PART2.txt > ${conf_path}/CANCEL_CD.txt

# 4  
Old 08-22-2008
or you could set range to the variable not to the value contained in that variable :

Code:
:%s/RANGE/\${btch_range}/g

notice the "\" before the "$"

so before we have:
Code:
PARM1=RANGE

and after we have:

Code:
PARM1=${btch_range}

as long as this is inside a shell script, if it is in a conf file that will not expand the variable ${btch_range} (replace the variable with it's value when read) then the previous answer is what you want.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Shell Programming and Scripting

Copy of "How to create a long list of directories with mkdir?"

To bakunin and corona688: My result when text in file is ms_ww_546 ms_rrL_99999 ms_nnn_67_756675 is https://www.unix.com/C:\Users\Fejoz\Desktop\ttt.jpg I hope you can see the picture. There is like a "whitespace character" after 2 of the 3 created directories. ---------- Post... (0 Replies)
Discussion started by: setub
0 Replies

4. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies

5. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

6. UNIX for Dummies Questions & Answers

Egrep confusion with "I" and "-I" pattern

I am executing following command egrep -w I filename.txt the filename.txt has following data .... -I 07-18 08:31:19.924 9880 6 SessionManager ConnectConfig: ConfigurationWebService LoginResults=SuccessfulLogin I am so hungry that I need to eat I expect egrep to print only the second... (1 Reply)
Discussion started by: VBG
1 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

Command to view full data "export MAESTRO_OUTPUT_STYLE=LONG"

Hi, Always when I login to Unix, I need to give the following command to view the data properly; export MAESTRO_OUTPUT_STYLE=LONG The reason is that by default the settings export MAESTRO_OUTPUT_STYLE=SHORT Please let me know how I could make LONG as the default and avoid giving the... (1 Reply)
Discussion started by: jmathew99
1 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question