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 and shell scripting languages 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 9 12-04-2008 04:04 PM
fl command - set record length Tom Siegel Shell Programming and Scripting 2 07-17-2006 10:50 AM
fixed record length george_ Shell Programming and Scripting 16 03-28-2006 06:41 AM
Record too long for awk vibhor_agarwali UNIX for Dummies Questions & Answers 2 01-29-2005 03:14 AM
UNIX Default Record Length in AWK JLandry UNIX for Advanced & Expert Users 1 01-25-2002 10:40 AM

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 02-14-2007
venkatajay_18 venkatajay_18 is offline
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
  #2 (permalink)  
Old 02-14-2007
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

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


Code:
{print $2}

or


Code:
{printf $2 "\n"}

Regards
  #3 (permalink)  
Old 03-05-2007
moshe fried moshe fried is offline
Registered User
  
 

Join Date: Feb 2007
Location: Israel
Posts: 24
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"'
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 10:32 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