Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field Separator Help

Status
Not open for further replies.

rswarich

Technical User
Jun 7, 2001
7
US
Is there a way to use FS=??? in the
BEGIN part of an awk script so that
every character becomes a field separator?

I would like to use $1, $2 ... $n to specify
the nth character on a line, regardless of
what separates the characters.

So, for example on the line:
abcd e f g hi

$13 would be the "i"

Thanks
 
echo 'abcd e f g hi' | nawk '{substr($0, 13,1)}'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
> every character becomes a field separator
As field value can't contain field separator you'll be in trouble ...
Anyway, you can get the nth character on a line with the substr($0,n,1) built-in function.

Hope This Help
PH.
 
Thanks,
The substr is working and is much better
than what I originally asked for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top