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 11:16 AM
error during run: St9bad_alloc - Getting this error while using some conversion progr sathu_pec Shell Programming and Scripting 1 01-21-2008 02:38 AM
I got error like...syntax error on line 1, teletype koti_rama UNIX for Advanced & Expert Users 2 07-07-2007 08:35 PM
error reading sections error at install doelman SUN Solaris 2 02-05-2007 12:21 PM
Error: Internal system error: Unable to initialize standard output file firkus UNIX for Dummies Questions & Answers 2 10-25-2005 04:23 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-13-2008
gyankr gyankr is offline
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 10:08 AM.. Reason: added code tags
  #2 (permalink)  
Old 05-13-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,773
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}'`;
  #3 (permalink)  
Old 05-13-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
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])}'
  #4 (permalink)  
Old 05-15-2008
gyankr gyankr is offline
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....

???
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0