The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 3 10-19-2007 11:16 AM
fl command - set record length Tom Siegel Shell Programming and Scripting 2 07-17-2006 06:50 AM
fixed record length george_ Shell Programming and Scripting 16 03-28-2006 02:41 AM
Record too long for awk vibhor_agarwali UNIX for Dummies Questions & Answers 2 01-28-2005 11:14 PM
UNIX Default Record Length in AWK JLandry UNIX for Advanced & Expert Users 1 01-25-2002 06:40 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Mar 2006
Posts: 3
Record Length too long -- AWK Problem

Hi All,
I have a txt file which is an export of a query result from the database. The txt file contains 'Processid#sqlquery' from the database table.As the sqlquery is too long.... i am unable to get the fields seperated using the awk script as below:-

cat sql.txt | awk -F'#' '{printf $2}'
Error:-
awk: record ` 16355#SELECT EDW_RE...' too long

My objective is to have Processid as txt file name which contains that particular query. So for each row of Processid#sqlquery i shud be creating a processid file containing that particular sql. Please help me with ur suggestions!!

Thanks,
Ajay
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-14-2007
Moderator
 

Join Date: Feb 2007
Posts: 1,996
With printf you'll get an output of one long line. Try:

Code:
{print $2}
or

Code:
{printf $2 "\n"}
Regards
Reply With Quote
  #3 (permalink)  
Old 03-05-2007
Registered User
 

Join Date: Feb 2007
Location: Israel
Posts: 22
the problem is the input not the output

Since awk has limitations of the size of input it can take in one line try the following:
cat sql.txt | perl -e 'print (split (/#/,$_))[1]'
split works like the FS of awk, but the field count starts from 0
if you need a newline after the output use:
cat sql.txt | perl -e 'print (split (/#/,$_))[1] . "\n"'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:11 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