![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
Other UNIX.COM Threads 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 |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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}'`;
: 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 |
| Forum Sponsor | ||
|
|
|
|||
|
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}'`;
|
|
|||
|
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])}'
|
|
|||
|
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.... ??? |
|||
| Google UNIX.COM |