The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 07:16 AM
error during run: St9bad_alloc - Getting this error while using some conversion progr sathu_pec Shell Programming and Scripting 1 01-20-2008 10:38 PM
I got error like...syntax error on line 1, teletype koti_rama UNIX for Advanced & Expert Users 2 07-07-2007 04:35 PM
error reading sections error at install doelman SUN Solaris 2 02-05-2007 08:21 AM
Error: Internal system error: Unable to initialize standard output file firkus UNIX for Dummies Questions & Answers 2 10-25-2005 12:23 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-13-2008
Registered User
 

Join Date: Jan 2008
Posts: 2
awk error

Hi all,

i have the files in the below sequence:

fancy_LANG_STD_AU_2008-03-05.dat
fancy_LANG_STD_HK_2008-03-06.dat
fancy_LANG_STD_NZ_2008-03-05.dat
fancy_STD_AU_2008-03-05.dat
fancy_STD_HK_2008-03-06.dat
fancy_STD_NZ_2008-03-05.dat

i am trying to sort them like below:

fancy_STD_AU_2008-03-05.dat
fancy_LANG_STD_AU_2008-03-05.dat
fancy_STD_HK_2008-03-06.dat
fancy_LANG_STD_HK_2008-03-06.dat
fancy_STD_NZ_2008-03-05.dat
fancy_LANG_STD_NZ_2008-03-05.dat

the script shows something like this
Code:
local flist="$@"
local filelist=`echo $flist | awk '{
while (++i<=NF) {
split($i,x,"_");
y=(x[2]=="LANG")?4:3;
print x[y],y,$i}
}' | sort -t"-" +1 +2 | awk '{print $3}'`;
I am having a small problem,when the number of files to be sorted increases,I am getting an error like below

: Input line FANCY_LANG_STD_AU_20 cannot be longer than 3,000 bytes.


I am using hp-ux and gawk does not seem to work.Any workaround.I guess there is a "fold" command but not sure if that will fulfill my needs.

Any thoughts?

Regards,
Raju

Last edited by Yogesh Sawant; 05-13-2008 at 06:08 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-13-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,861
There is a limit to command line size. gawk has nothing to do with it. Place your input filenames into a file our use ls directly:

Code:
local filelist=`ls fancy*.dat | awk '{
while (++i<=NF) {
split($i,x,"_");
y=(x[2]=="LANG")?4:3;
print x[y],y,$i}
}' | sort -t"-" +1 +2 | awk '{print $3}'`;
Reply With Quote
  #3 (permalink)  
Old 05-13-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 542
Timtowtdi

The maximum size of an input line is limited by LINE_MAX. getconf LINE_MAX tells you how long an input line can be.

Code:
ls -1 fancy* | \
awk -F"LANG_" '{
    if (NF==2)
       p[$1$2]=$0
    else
       q[$0]
} END {
  for (i in q)
      printf("%s\n%s\n", i, p[i])}'
Reply With Quote
  #4 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: Jan 2008
Posts: 2
another error

local flist="$@"
local tempfile=`echo $flist`
local filelist=`cat $tempfile | awk '{
while (++i<=NF) {
split($i,x,"_");
y=(x[2]=="LANG")?4:3;
print x[y],y,$i}
}' | sort -t"-" +1 +2 | awk '{print $3}'`;

Now i am getting cannot open file fancy_LANG_STD_AU_2008-03-05.dat no such file or directory....

???
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0