SED on AIX Limitation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED on AIX Limitation
# 1  
Old 02-10-2011
Error SED on AIX Limitation

Hello,

I have a problem running a script created in ksh for Linux (Tested on Debian 5.0, Ubuntu Server 10.04 and RHEL 5.1), it works properly. Smilie
I trying to pass it to a AIX 5.3. Smilie
The problem is the character limit of 256 on a command system and SED.

I need to cut the contents of a file of N characters in chunks of 1850 characters separated by '\n', and the command used in Linux is:

Code:
cat $TMP_MAP_FILE | sed 's/^\(.\{'1850'\}\)/&\n/g' > $map_file

the error that appears is the following:

Code:
sed: 0602-404 Function s/^\(.\{1850\}\g)/&\n/ not can be parsed.

Tell me, if you have any ideas or another way to do it. I'm doing tests with dd
and the block size.

And sorry for my english Smilie
Thank you very much! Smilie

Last edited by nemesis.spa; 02-10-2011 at 11:34 AM..
# 2  
Old 02-10-2011
Have you tried the fold command?
Code:
fold -w 1850 file

This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 02-10-2011
He had not tried, it works. (Do not know the command) Smilie

But I have a second problem. Smilie

The second part was to format the strings obtained, which set in fields of different sizes separated by ',' like a. csv.

code is as follows ...

Code:
cat $TMP_MAP_FILE | sed 's/^\(.\{'$j'\}\)/&;/g' > $MAP_FILE

Thank you very much SmilieSmilieSmilie
# 4  
Old 02-10-2011
Can you post an example of the input file and the desired output?
# 5  
Old 02-10-2011
Java

Of course...

INPUT:
aaaaaabbbbbbcccccccccddddddddeeeffffffgggggggggggg

OUTPUT:
aaaaaa;bbbbbb;ccccccccc;dddddddd;eee;ffffff;gggggggggggg;


One of the fields has 1600 characters

PD: I have tried:
Code:
perl -pi -e 's/^\(.\{'1845'\}\)/&;/' zz

Thanks!

Last edited by nemesis.spa; 02-10-2011 at 09:15 AM..
# 6  
Old 02-10-2011
How do you determine the width of the individual fields?
# 7  
Old 02-10-2011
Java

Copy a part of the script. This code is inside a loop that will receive files.
Sorry for the comments, becose they are in Spanish

Code:
        # Variables que almacenan las longitudes de cabecera, registro y fragmentacion
        CHAR_CABECERA=22        # !!!!!!! A la cabecera debe sumarse 1
        CHAR_CABECERA=`expr $CHAR_CABECERA + 1`
        CHAR_REGISTRO=1850
        # Si se elimina el Ășo campo no habra separador al final
        # Estos datos se obtienen con el valor de cada campo, empezando por el primero sin modificar, y los siguiente, sumandoles el anterior + 1 (el caracter de separacion)
        set -A SEPARADORES 14 21 31 41 49 59 62 75 86 97 104 1305 1406 1707 1709 1714 1723 1727 1731 1736 1739 1742 1758 1774 1778 1782 1784 1789 1805 1808 1812 1815 1818 1823 1827 1829 1831 1833 1835 1837 1848 1889 1892
        # Bucle que va pasando por todos los ficheros encontrados con un patron
        for i in `cat $LST_TMP_PUS`
        do
                # Ficheros temporales donde se realizaran los mapeos
                CABECERA=$TMP_DIR/$i.Ncab
                TMP_MAP_FILE=$TMP_DIR/$i.Tmap
        ## CAMBIAR DIRECTORIO AL QUE SE VUELCAN LOS DATOS
                MAP_FILE=$RES_DIR/$i.map
                # Eliminamos la cabecera, cortamos el fichero por longitudes de registro, dejamos un registro por linea y eliminamos la ultima linea en blanco
                # cut -b$CHAR_CABECERA- $i | sed 's/\(.\{'$CHAR_REGISTRO'\}\)/&\n/g' > $CABECERA
                cut -b$CHAR_CABECERA- $i | sed 's_\(.\{'$CHAR_REGISTRO'\}\)_&\n_g' > $CABECERA
                # Volcamos el contenido del fichero sin fragmentar el registro al fichero que contendra los datos finales
                cat $CABECERA > $TMP_MAP_FILE
                # Bucle en el que formateamos el fichero
                        echo "Comienzo fichero $i separadores"
                for j in ${SEPARADORES[*]}
                do
                        echo "Problema en los separadores"
                        # Formateo del fichero registro a registro, se ha de tener en cuenta que cada registro se ha de sumar al anterior + el caracter de separacion
                        # cat $TMP_MAP_FILE | sed 's/^\(.\{'$j'\}\)/&;/g' > $MAP_FILE
                        cat $TMP_MAP_FILE | sed 's_^(.{$j})_&;_g' > $MAP_FILE
                        cat $MAP_FILE > $TMP_MAP_FILE
                        cat $MAP_FILE >> $RES_PUS
                # Fin - Bucle en el que formateamos el fichero
                done
                # Se eliminan los ficheros temporales
                rm $CABECERA $TMP_MAP_FILE $MAP_FILE
        # Fin - Bucle que va pasando por todos los ficheros encontrados con un patron
        done


Last edited by nemesis.spa; 02-10-2011 at 11:34 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX lpar bad disk I/O performance - 4k per IO limitation ?

Hi Guys, I have fresh new installed VIO 2.2.3.70 on a p710, 3 physical SAS disks, rootvg on hdisk0 and 3 VIO clients through vscsi, AIX7.1tl4 AIX6.1tl9 RHEL6.5ppc, each lpar has its rootvg installed on a LV on datavg (hdisk2) mapped to vhost0,1,2 There is no vg on hdisk1, I use it for my... (1 Reply)
Discussion started by: frenchy59
1 Replies

2. Shell Programming and Scripting

sed 255 Character Limitation

Hello, I am using sed command to place a comma dynamically in certain positions. When the position variable exceeds 255 characters, it errors out. I would appreciate if someone can point in the correct direction sed 's/^\(.\{'"$pos"'\}\)./\1,/' ragha.txt > ragha3.txt If $pos > 255,... (8 Replies)
Discussion started by: ragha81
8 Replies

3. AIX

What is the limitation in AIX?

Hi All, i got few questions... 1) What is the maximum number of files that we can save under a single directory in AIX ? (* we have enough storage/disk space) 2) And what is the maximum number of sub - directories in side a directory? I know that...every directory is a (special)... (11 Replies)
Discussion started by: System Admin 77
11 Replies

4. UNIX for Dummies Questions & Answers

Limitation in addition

whats wrong with this addition? Whats the maximum number of digits can be handled? pandeeswaran@ubuntu:~/Downloads$ const=201234454654768979799999 pandeeswaran@ubuntu:~/Downloads$ let new+=const pandeeswaran@ubuntu:~/Downloads$ echo $new -2152890657037557890 pandeeswaran@ubuntu:~/Downloads$ (4 Replies)
Discussion started by: pandeesh
4 Replies

5. AIX

Limitation for SFTP on AIX number of sessions

Hello. I am using AIX 6 and If wish to receive more than 500 files via SFTP, I get some time out errors. Could you please advise where is the limit for number of concurrent transfers setup in AIX Box or what is the limit and can that be changed? Many Thanks (3 Replies)
Discussion started by: panchpan
3 Replies

6. AIX

AIX 5.3 : Limitation to 1 telnet session for some users

Hi, I search the way to limit, for a group on a AIX 5.3, one telnet session by user (Simultaneous). I search a lot in /etc/security but the only way found is with the pam authentication that i not use. No solution found also in smit menu... Thanks for your help. (2 Replies)
Discussion started by: feilong
2 Replies

7. Shell Programming and Scripting

sed limitation of 255 characters

Gurus, sed -e "s/\(.\{1,255\}\)\(.\{1,2\}\)\(.*\)/\1AB\3/" FILE ---this works sed -e "s/\(.\{1,468\}\)\(.\{1,2\}\)\(.*\)/\1AB\3/" FILE ---this does not It works only till 1,255 ( any number below 255 works) Any one know how to increase this limit. Thanks Sirababu (4 Replies)
Discussion started by: sirababu
4 Replies

8. UNIX for Dummies Questions & Answers

grep limitation

Hello, I am looking for a way to get around an issue, as I am using the grep command in a very common situation: grep ^50 File.*.txt | "some awk process" My problem is that bash throws me an error on the grep command if the directory in question contains several thousands files. ... (6 Replies)
Discussion started by: Indalecio
6 Replies

9. HP-UX

HP-UX 11i - File Size Limitation And Number Of Folders Limitation

Hi All, Can anyone please clarify me the following questions: 1. Is there any file size limitation in HP-UX 11i, that I can able to create upto certain size of file (say 2 GB) and not more then that???? 2. At max. how many files we can able to keep inside a folder???? 3. How many... (2 Replies)
Discussion started by: sundeep_mohanty
2 Replies

10. Shell Programming and Scripting

find limitation

Hi , i'm trying to use "find "command with "-size "option but i encounter 2gb file limitation. Can you confirm this limitation ? Is there a simple way to do the same thing ? My command is : <clazz01g-notes01>/base/base01 # find /base/base01 -name '*.nsf' -size +5242880000c -exec ls... (2 Replies)
Discussion started by: Nicol
2 Replies
Login or Register to Ask a Question