03-05-2007
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"'
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hello -
QUESTION:
Is there a way to override the default record length limitation over awk in Unix?
Or, is there a better way to do what I am trying to do than the way I am trying to do it now? (See BACKGROUND and CURRENT PROCEDURE below...)
BACKGROUND:
In a Kornshell script, I have... (1 Reply)
Discussion started by: JLandry
1 Replies
2. UNIX for Dummies Questions & Answers
I am trying to generate a small report with the help of awk.
The contents are present in a file whose last line is very long.
I can't shorten this line as its generated after a lot of processing.
On reading this file awk says
record "starting of line ..." too long
record number 30
Now... (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies
3. Shell Programming and Scripting
Hi All,
I've got some strange behaviour going on when trying to manipulate a file that contains spaces.
My input file looks something like this:
xxxxxxxxx,yyyy,sss sss sss,bbbbbbb
If I use awk:
When running from the command line I get:
sss sss sss
But when running from a... (7 Replies)
Discussion started by: pondlife
7 Replies
4. Shell Programming and Scripting
Hi Friends,
Need some help in AWK.
Working on AIX 5
Have been trying the following functionality to make the record length fixed:
if( length(record) < 300 )
{
printf("%-300s\n", record);
}
In my opinion it will apply some fillers in the end.
Its is not making any... (4 Replies)
Discussion started by: kanu_pathak
4 Replies
5. UNIX for Dummies Questions & Answers
I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies
6. Shell Programming and Scripting
Hi Guys,
I wanted to print the length of each record and the record itself.
I tried the following awk ...
awk 'a=length(); {print $a,$0}' file1
But it is giving me the records instead of length.
and also, it giving me each record twice. Means the value of a is not the length of the... (0 Replies)
Discussion started by: mac4rfree
0 Replies
7. Shell Programming and Scripting
Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types:
(H)eader Records
(D)etail Records
(T)railer Records
The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies
8. Shell Programming and Scripting
I have written below script to add substring in a file containing fixed length record, but when I run below script I get error as:
ERROR:
awk: record `22503004502488344040...' too long
My fixed length record has length around 2000, each file is having 5000 records and total number of files is... (3 Replies)
Discussion started by: Devesh5683
3 Replies
9. UNIX for Dummies Questions & Answers
Hi All ,
I am getting record too long for the below command .
nawk -F\" '{a=a" "$2} END{for(i in a) print i,a }' test|sort|awk '{for(i=1;i<=NF;i++) t=t"\t"$i;if(NF>max)max=NF} END{for(i=1;i<=max;i++)print t }'
File test has 850 records ...
Please help.. (2 Replies)
Discussion started by: saj
2 Replies
10. Shell Programming and Scripting
Hi Team,
I have an issue to split the file which is having special chracter(German Char) using awk command.
I have a different length records in a file. I am separating the files based on the length using awk command.
The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies