paddl3r
November 27th, 2007, 07:46 AM
Dear Forum,
I am struggling to write a block of awk to take a string such as:
blah
the split on all characters and print them out:
b
l
a
h
The closest I've got is this:
#!/usr/bin/awk -f
BEGIN {
string="blah";
n=split(string,array,"[A-Z]|[a-z]");
for (i=1;i<=n;i++) {
print(array[i]);
}
exit;
}
It splits on each character but prints a blank line for each of the characters. Any suggestions would be welcome.
Cheers,
paddl3r
PS I don't have nawk or gawk on this system. My boss has insisted it slots in with an existing suite of awk scripts rather than allowing me to use perl :(
I am struggling to write a block of awk to take a string such as:
blah
the split on all characters and print them out:
b
l
a
h
The closest I've got is this:
#!/usr/bin/awk -f
BEGIN {
string="blah";
n=split(string,array,"[A-Z]|[a-z]");
for (i=1;i<=n;i++) {
print(array[i]);
}
exit;
}
It splits on each character but prints a blank line for each of the characters. Any suggestions would be welcome.
Cheers,
paddl3r
PS I don't have nawk or gawk on this system. My boss has insisted it slots in with an existing suite of awk scripts rather than allowing me to use perl :(