goldenradium2001
Technical User
Any help will be appreciated. I'm learning awk right now and wanted to clear up a few things.
I have a file that looks like this (the <TAB> actually indicates that I'm using Tab spaces):
one<TAB>two<TAB><TAB>three
I issue the following command to put a dash between these columns:
nawk '{print $1"-"$2"-"$3"-"$4}' FS="\t" filename
The output that I get is:
one-two--three
My question is: Why did I have to specify four fields in order to get this output? Is the space between the two dashes -- actually a field?
When I specify only three fields using the following command:
nawk '{print $1"-"$2"-"$3}' FS="\t" filename
I get the following output:
one-two-
Is this proof that there exists a field between the two -- dashes?
I know I can use:
nawk '{print $1"-"$2"-"$3}' FS="\t+" filename
to get around this dilemma of having two dashes but the reason why I'm writing is because I want to know WHY the space between the two dashes -- is considered a field?
Thanks for enlightening me!!! Any guesses are welcome!
I have a file that looks like this (the <TAB> actually indicates that I'm using Tab spaces):
one<TAB>two<TAB><TAB>three
I issue the following command to put a dash between these columns:
nawk '{print $1"-"$2"-"$3"-"$4}' FS="\t" filename
The output that I get is:
one-two--three
My question is: Why did I have to specify four fields in order to get this output? Is the space between the two dashes -- actually a field?
When I specify only three fields using the following command:
nawk '{print $1"-"$2"-"$3}' FS="\t" filename
I get the following output:
one-two-
Is this proof that there exists a field between the two -- dashes?
I know I can use:
nawk '{print $1"-"$2"-"$3}' FS="\t+" filename
to get around this dilemma of having two dashes but the reason why I'm writing is because I want to know WHY the space between the two dashes -- is considered a field?
Thanks for enlightening me!!! Any guesses are welcome!