Probos
1
Ok. I'm just starting to use AWK and I have a question. Here's what I'm trying to do:
uname -n returns the following on my box:
ftsdt-svsi20.si.sandbox.com
I want to pipe this to an AWK statement and make it only print:
svsi20
I tried:
uname -n | awk '{ FS = "." ; print $1 }'
But that prints:
ftsdt-svsi20
How do I get it to exclude everything before the "-" and everything after the "."?
Try
uname -n | awk -F "[.-]" '{ print $1 }'
ilan
3
How about using this...
uname -n | awk '{ FS = "." ; print $1 }' | cut -d '-' -f2
or
uname -n | cut -d '.' -f1| cut -d '-' -f2
the above will give you the o/p svsi20
Hope your objective will be met!
-ilan
Probos
4
That gave me:
awk: syntax error near line 1
awk: bailing out near line 1
as always..... if on Solaris - use 'nawk' instead.
Probos
6
wow - the cut command. Why didn't I think of that,..works like a charm. Thanks a bunch.