![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Count first column on the basis of two other columns | kaustubh137 | Shell Programming and Scripting | 1 | 05-29-2008 09:54 AM |
| How to get the count only if two column matches? | gobinath | Shell Programming and Scripting | 3 | 05-27-2008 05:01 AM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 09:57 AM |
| How to count pattern in column | ahjiefreak | Shell Programming and Scripting | 12 | 12-04-2007 07:53 PM |
| How to count the record count in an EBCDIC file. | oracle8 | UNIX for Dummies Questions & Answers | 1 | 07-26-2006 08:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Max column count in a file
I have to send a file to mainframe and before sending it, I have to execute the quote command to set the record length.
Since the file is dynamic, I do not know what the maximum size of a line could be. Currently, I use the following function to get the Max Column Count. Since I use "sed" it takes a long time for big files. GetMaxCols() { MAX_COL_SIZE=0 for line in `cat $1 | sed "s! !~!g"` do COL_COUNT=`echo $line | wc -c` if [ "$COL_COUNT" -gt "$MAX_COL_SIZE" ]; then MAX_COL_SIZE=$COL_COUNT fi done echo $MAX_COL_SIZE } Any better ways to achieve this goal ? Thanks in advance. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|