Visit Our UNIX and Linux User Community


Maximum size of sed file...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Maximum size of sed file...
# 1  
Old 03-19-2002
Maximum size of sed file...

The sed -f option (reading sed commands from a file) seems to have a limit of 200 transactions per file. I can't see anything in the man pages about this restriction.

I have a file with several thousand sed commands I need to perform (substitutions) - and while I can split the file into chunks of 200 fairly easily - I wonder if there is a way to define the sed file limitation? Seems a very small number for such a function.
# 2  
Old 03-19-2002
MySQL

wow, several thousand sed commands on 1 file!!?? i was not aware of a limitation but i will take a look and see if I find anything, if i can ask, what type of file are you doing this to? and did you use sed to create the sed file? that is some extreme sed programming you got going on
# 3  
Old 03-19-2002
Yes - sed was used in creating the sed file.....

The purpose for this is to apply an encryption algorithm against a field within each record of a large file.

1. I first extract all of the values in a certain field from each record.
2. I then apply an encryption algorithim to each value in this new file and that creates another file.
3. I then 'paste' the two files together - which leaves me with 2 columns - tab telimited - first column of raw data - second column encrypted data.
4. I use a series of sed commands to change each line to 's/old/new/g'
5. I then use the output of this as a sed file - which I split into a number of smaller sed files (due to this limitation) and apply the substitutions in each file against the original file - effectively substituting all the raw data in each record for its encrypted equivalent.
6. I then do each of these steps (1-5) against a number of different files. (there are a couple of spurious steps such as removing header records etc when creating the sed files - but they're not that relevant).

The original files are flat (text) files. And when the big sed file with all the substitutions iscreated- there are 1,000s of rows. The limitation seems to actually be 199 commands in a sedfile (as 200 stops with the too many arguements error).

Extreme programming - I assure you it's far from it.

I know there are other ways to do this - i.e. 1 record at a time.... but that seems fairly inefficient.

Last edited by peter.herlihy; 03-19-2002 at 07:58 PM..
# 4  
Old 03-19-2002
thats AWESOME..........
i suppose you are talking about splitting up the sed file and then calling the sed commands in a shell script. sounds like the quick fix and running them against the previously changed file. i don't have access to check now but i'll post if i find anything
# 5  
Old 03-19-2002
Yeah - bang on.... I take the large sed file (1,000s) of rows and 'split' into chunks of 199 rows. Then for each of these split files - use sed -f - agsint the original file (renaming it back to it's original name after each sed file is applied)
# 6  
Old 03-20-2002
for loop

Peter,
Sounds like a perfect job for a "for loop" or for something like this.

Something like this. If you have multiple sed commands you can only have one here and use some criteria as below to make the loop continue until all of your data is changed.


for name in `cat original.file`
do
Paste your stuff here.

done 2> /save/to/error/log



Sounds like you have a starting file that you pull a field out of to create a new file. Then you take that column of data and create a new file and then perform the algorithm and then paste both columns into another file with only the 2 columns in it.

Is that correct? Can you post what you have? It is hard to answer without seeing your script.


Smilie
# 7  
Old 03-20-2002
Here's the script that I have used. The my_crypt.pl performs the encryption of a a single column file only and creates a new single column file. (that cannot be changed).

All original input files are *.ABC (I've changed the names of the files for putting it up here for obvious reasons).

There are header rows - so I remove them as they are the only rows that have .ABC or .abc in them.
Some fields are blank (a few only) - so I remove these from the substitue to avoid the error when replacing nulls.
Sedformat has the commands to format the large file into s/old/new/g


for y in *.ABC; do awk -F, '{print $3 }' $y | sort -u > $y.raw; done &&
for z in *.raw; do grep -v "\.ABC" $z > temp; mv temp $z; done &&
for z in *.raw; do grep -v "\.abc" $z > temp; mv temp $z; done &&
for z in *.raw; do grep -v " " $z > temp; mv temp $z; done &&
for x in *.raw; do my_crypt.pl e $x; paste $x crypt.out > $x.sedfile; done 2>/dev/null &&
for w in *.sedfile; do sed -f sedformat $w > temp; mv temp $w; done &&
for v in *.sedfile; do split -199 $v $v; done &&
rm *sedfile &&
for u in *.ABC; do for t in $u.raw.sedfile*; do sed -f $t $u > temp; mv temp $u; done; done &&
rm *.raw* crypt.out

I know it's not the greatest code in the world - it does work however which is fairly important! Any suggestions for enhancements would be great.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #714
Difficulty: Medium
Machine learning is a well known method for mitigating the Von Neumann performance bottleneck
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Maximum size of attachment in mail

Hi Friends, My requirment is to Query the oracle database , generate the file change the extension to .csv and send to clients automatically everyday. However i am able to perform the task. But sometimes when the file size is getting increased more than 1 MB then the mail is... (5 Replies)
Discussion started by: Showdown
5 Replies

2. Programming

Maximum buffer size for read()

Hi friends, Hope everybody is fine. First have a look at my code, then we will talk about it. $ cat copy.c #include <stdio.h> #define PERMS 0644 /* RW for owner, R for group, others */ #define BUFSIZE 1 char *progname; int main(int argc,char * argv) { int f1, f2, n; ... (4 Replies)
Discussion started by: gabam
4 Replies

3. UNIX for Advanced & Expert Users

How to identify maximum stack size?

Hi All, I have set max stack size as 4KB for my thread, but it always using very less. So I like to know what is the maximum stack size is used by my thread. I tried with gcc -fstack-usage command line option, but its not supported by mips. Kindly suggest me the way to find the max stack... (6 Replies)
Discussion started by: rajamohan
6 Replies

4. AIX

maximum size of a ramdisk on AIX 5.3

Hi, Do you know what is the maximum size I can use to create a ramdisk on AIX 5.3? I m pretty sure i've seen somewhere i can use more than 2 Gb but I can't remember where. I need to do some recommandations for one of my customer and they'll need to create a ramdisk of 20 Gb. Can this be done? ... (1 Reply)
Discussion started by: cedric hanquez
1 Replies

5. UNIX for Dummies Questions & Answers

Maximum file size ????

Hi All, - block size of 512KB & every address requires 4 bits - The inode structure contains 10 direct pointers, 1 single indirect, 1 double indirect & 1 triple indirect pointer What could be the possible maximum file size for this system Any guess? I am unable to understand the question... (0 Replies)
Discussion started by: preethgideon
0 Replies

6. UNIX for Dummies Questions & Answers

maximum tar file size?

Is there a reasonable maximum limit for tar file sizes? I want to transfer a pile of files from one server to another but have restricted means, so tarring them first will probably be best... but how big can I go - both for the file format itself and for the operating system (linux) to handle? ... (7 Replies)
Discussion started by: Bobby
7 Replies

7. UNIX for Dummies Questions & Answers

Maximum size of a file in unix

What's the maximum file size supported by unix. (3 Replies)
Discussion started by: nagalenoj
3 Replies

8. HP-UX

Mailx Maximum attachment size

Hi friends, what is the maximum allowable attachment size, we can send using mailx command. what is an alternate option if my file is > than that size? thanks sreeji (0 Replies)
Discussion started by: sreejithau
0 Replies

9. UNIX for Dummies Questions & Answers

Maximum input file size in "Diff" Command

Hello, Can anyone let me know what is the maximum file size that can be given as input for the "Diff" Command in Unix? I have a file size as large as 28MB and which can also increase. Will I face any issues with such a file size. If yes, What is the other alternative. Thanks in advance for... (1 Reply)
Discussion started by: Neeraja
1 Replies

10. Programming

Maximum File Size

Hi, When i checked for the maximum file size on solaris 5.9 the max file size obtained was only 2147483647 and all the further writes to the file which had reached that max size is not added to that file. even i had registered the signal SIGXFSZ, but the signal was not delivered to the... (5 Replies)
Discussion started by: matrixmadhan
5 Replies

Featured Tech Videos