01-29-2009
There are tons of guide, howtos etc on the net, even some machines have man page for awk installed. Check for the "length" function.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to display df -h command out in proper format, how can I display
each field of each record in a fixed length. (2 Replies)
Discussion started by: roopla
2 Replies
2. Shell Programming and Scripting
Hi Unix Champs,
I want to awk on a fixed length file.
Instead if the file was a delimited file, then I could have used -F and then could have easily done manipulation on the fields.
How do i do the same in case of fixed length file?
Thanks in Advance.
Regards. (7 Replies)
Discussion started by: c2b2
7 Replies
3. 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
4. Shell Programming and Scripting
I am trying to use the following code:
awk '{s=$0;if(length(s) < 750){getline; s=s " " $0}printf("%s\n",s)}' filename
but an error shows that 'awk' is too long. Is there a limit to the awk length function? and what could be an alternate solution for long fixed width records?
The code... (3 Replies)
Discussion started by: CKT_newbie88
3 Replies
5. Shell Programming and Scripting
Hi,
I have requirement where record length is stored in an variable RECORD_LENGTH
Code goes as follows
RECORD_LENGTH=537
the above is arrived from
#RECORD_LENGTH=`awk -F"=" '{$sum+=$2} END{print $sum}' DBP_Claims_CFG.ini`
awk '
{
if (length() == '$RECORD_LENGTH')
print FNR, $0... (4 Replies)
Discussion started by: ainuddin
4 Replies
6. Shell Programming and Scripting
Hi Folks -
I'm quite new to awk and didn't come across such issues before. The problem statement is that, I've a file with duplicate records in 3rd and 4th fields. The sample is as below:
aaaaaa|a12|45|56
abbbbaaa|a12|45|56
bbaabb|b1|51|45
bbbbbabbb|b2|51|45
aaabbbaaaa|a11|45|56
... (3 Replies)
Discussion started by: asyed
3 Replies
7. Shell Programming and Scripting
Hi..
Just got a problem with awk and cannot figure out whats the issue. I am not really expert in awk so looking for help/opinion from experts
Command is
$ cat abinaryfile | sed -e "s/@@//g;s/@$//" | awk ' begin {} { printf(length($0)); }'
Well its a binary file and I am... (3 Replies)
Discussion started by: iffarrukh
3 Replies
8. Shell Programming and Scripting
Morning, every one.
I have a file like this:
AAEQGAGNQPQH 27
AAGETQY 51
AAGGSSYNEQF 12
AAGGYEQY 72
AAGLEAKNIQY 159
AAGPYEQY 26
AAGQDYNSPLH 45
AAGQGGEQF 1587
AAGREGGNTEAF 4
AAGSPQH 3
AAGSYEQY 45
AAGTGAYEQY 19
AAGTSGNNEQF 79
AAGWNTEAF 37
I want to count the string length of the... (2 Replies)
Discussion started by: xshang
2 Replies
9. Shell Programming and Scripting
Hello, I have the following input data:
A C
AA GG
A G
CG AG
the code I tried:
awk -F" " '{ if ((length($1==1) && (length($2==1))) input_file
is not working, I need the output to be (such that only the columns containing one letter are printed)
A C
A G
Any help would be appreciated! (5 Replies)
Discussion started by: Rabu
5 Replies
10. Shell Programming and Scripting
My question is basically as the title says. How can I check a user inputted string is only certain characters long (for example, 3 characters long) and how do I check a user inputted string only contains certain characters (for example, it should only contain the characters 'u', 'a', 'g', and 'c')... (4 Replies)
Discussion started by: Eric1
4 Replies