Results 1 to 7 of 7
Hi everyone,
my question is quite simple, could you tell me what this small part of code means?
cat $File | grep .Vault | sed "s/ *$//" | \
awk ...
- 02-03-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 3
Help with awk
Hi everyone,
my question is quite simple, could you tell me what this small part of code means?
cat $File | grep .Vault | sed "s/ *$//" | \
awk -vvowner=$vowner \
'BEGIN
{
....
}
- 02-03-2010 #2
the sed portion is "greedy match 0 or more" (that's the *) $ means the end of the string. Looks like it says grab whatever is at the end and get rid of it, since is a substitution-mode regex. that output gets sent to awk where it makes a variable named vowner and is assigned the value of $vowner, which I would assume is defined previously in the script.
- 02-04-2010 #3Just Joined!
- Join Date
- Feb 2010
- Posts
- 3
Thanks for your answer.
But what im wondering is how the awk will be executed.
"It looks for a line in the file with .Vault", the spaces at the end of the line are erased. And it sends the line in the awk and because any delimiters are defined, the awk will do something for each character in the line."
That's it?
- 02-04-2010 #4
awk will do whatever is passed to it from sed, what exactly awk will do is defined after the BEGIN inside those brackets.
- 02-04-2010 #5Just Joined!
- Join Date
- Feb 2010
- Posts
- 3
You're absolutely right, what I meant to say is if in the BEGIN i write " echo {1}"
and I had the line "hello my friend.Vault". What result shoult I get?
Thank you for your help.
- 02-04-2010 #6
- 02-05-2010 #7
if the result from sed is:
Vault blah 2 exit
would yield Vault, as its the first string in the input of awkCode:print $1


Reply With Quote
