please explain below command Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionStruggles with grep, sed, awk to filter htmlPlease help explain this bash output redirectionPlease explain the Awk script provided belowExplain the shell command: shift $(($optind - 1))Please explain this awk statementCan someome explain me the below awk substring command val=$( echo $text $len|awk 'print substr($0,0,$2)')Please explain below bash functionCan someone please explain the meaning of the following awk script?Please explain what does exec, trap, mknod, tee doCan someone explain this line of code/command please?
Do I really need to have a message in a novel to appeal to readers?
Why do we bend a book to keep it straight?
Find the length x such that the two distances in the triangle are the same
What is this building called? (It was built in 2002)
How do I stop a creek from eroding my steep embankment?
How can I use the Python library networkx from Mathematica?
Do I really need recursive chmod to restrict access to a folder?
Can you shove before Attacking with Shield Master using a Readied action?
Generate an RGB colour grid
Using audio cues to encourage good posture
For a new assistant professor in CS, how to build/manage a publication pipeline
Irreducible of finite Krull dimension implies quasi-compact?
Can a party unilaterally change candidates in preparation for a General election?
What would be the ideal power source for a cybernetic eye?
Around usage results
Do wooden building fires get hotter than 600°C?
How to Make a Beautiful Stacked 3D Plot
Delete nth line from bottom
Where are Serre’s lectures at Collège de France to be found?
Should I use a zero-interest credit card for a large one-time purchase?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
Why do the resolve message appear first?
Do square wave exist?
Is it a good idea to use CNN to classify 1D signal?
please explain below command
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionStruggles with grep, sed, awk to filter htmlPlease help explain this bash output redirectionPlease explain the Awk script provided belowExplain the shell command: shift $(($optind - 1))Please explain this awk statementCan someome explain me the below awk substring command val=$( echo $text $len|awk 'print substr($0,0,$2)')Please explain below bash functionCan someone please explain the meaning of the following awk script?Please explain what does exec, trap, mknod, tee doCan someone explain this line of code/command please?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
getDateFormat() awk -F"_" 'print $1'
I would like to know What does the above function do?
$ awk '$2 == "1" print $0 ' cols.txt
Where the match occurs, print the entire line. But what this command returns
echo $1 | awk -F"-" 'print $2'
$ii - What is this?
i=1;
echo $ii
It didn't print anything.
shell-script shell awk variable
add a comment |
getDateFormat() awk -F"_" 'print $1'
I would like to know What does the above function do?
$ awk '$2 == "1" print $0 ' cols.txt
Where the match occurs, print the entire line. But what this command returns
echo $1 | awk -F"-" 'print $2'
$ii - What is this?
i=1;
echo $ii
It didn't print anything.
shell-script shell awk variable
5
One cannot explain this abomination of code. From uninitialized variables ($iiused in a test) to inconsistent spelling and capitalization of the months, to an undocumented and clearly uncommon input requirement.
– KevinO
Jun 16 '17 at 15:27
add a comment |
getDateFormat() awk -F"_" 'print $1'
I would like to know What does the above function do?
$ awk '$2 == "1" print $0 ' cols.txt
Where the match occurs, print the entire line. But what this command returns
echo $1 | awk -F"-" 'print $2'
$ii - What is this?
i=1;
echo $ii
It didn't print anything.
shell-script shell awk variable
getDateFormat() awk -F"_" 'print $1'
I would like to know What does the above function do?
$ awk '$2 == "1" print $0 ' cols.txt
Where the match occurs, print the entire line. But what this command returns
echo $1 | awk -F"-" 'print $2'
$ii - What is this?
i=1;
echo $ii
It didn't print anything.
shell-script shell awk variable
shell-script shell awk variable
edited Apr 13 at 15:00
Rui F Ribeiro
42.1k1484142
42.1k1484142
asked Jun 16 '17 at 14:41
Shivashankari SekarShivashankari Sekar
12
12
5
One cannot explain this abomination of code. From uninitialized variables ($iiused in a test) to inconsistent spelling and capitalization of the months, to an undocumented and clearly uncommon input requirement.
– KevinO
Jun 16 '17 at 15:27
add a comment |
5
One cannot explain this abomination of code. From uninitialized variables ($iiused in a test) to inconsistent spelling and capitalization of the months, to an undocumented and clearly uncommon input requirement.
– KevinO
Jun 16 '17 at 15:27
5
5
One cannot explain this abomination of code. From uninitialized variables (
$ii used in a test) to inconsistent spelling and capitalization of the months, to an undocumented and clearly uncommon input requirement.– KevinO
Jun 16 '17 at 15:27
One cannot explain this abomination of code. From uninitialized variables (
$ii used in a test) to inconsistent spelling and capitalization of the months, to an undocumented and clearly uncommon input requirement.– KevinO
Jun 16 '17 at 15:27
add a comment |
1 Answer
1
active
oldest
votes
$1 is the first positional parameter, i.e. argument to the function. awk -F- sets awks field separator to a dash, and print $2 prints the second field. So from aa-bb-cc, you'd get bb.
Presumably the function expects to be called as getDateFormat something-2017-06 which looks odd, but the year is picked from the second dash-separated field.
$ii would refer to a variable, but it's not set before the test if [ $mm -eq $ii ]; so the test sees [ 123 -eq ] (with 123 probably some number picked from $1). That causes an error since the operator -eq is missing the other operand.
iiis undefined on the first iteration, but that's semantically zero; on subsequent iterations, it gets incremented. I don't think the logic is entirely correct, but with a few fixes, the loop would convert -- horribly clumsily -- from a month name to a month number. (Notice also how the month names use erratic capitalization and abbreviation conventions, and how July is incorrectly listed before June.)
– tripleee
Jun 16 '17 at 15:43
I guess withii=1instead ofi=1it would superficially work for many month names.
– tripleee
Jun 16 '17 at 15:47
mmis set before the loop, apparently to the month name.
– tripleee
Jun 16 '17 at 15:47
@tripleee, without changing fromi=1toii=1, I get an error in bash on the first loop, so I think it needs to be set prior to the first loop iteration as you subsequently noted.
– KevinO
Jun 16 '17 at 15:56
@tripleee, sorry, my bad on themm. But since$iiis unquoted, it resolves to nothing, so that still doesn't work... And even when quoted, I think the empty string would give an error from-eq.
– ilkkachu
Jun 16 '17 at 16:16
|
show 3 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f371535%2fplease-explain-below-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$1 is the first positional parameter, i.e. argument to the function. awk -F- sets awks field separator to a dash, and print $2 prints the second field. So from aa-bb-cc, you'd get bb.
Presumably the function expects to be called as getDateFormat something-2017-06 which looks odd, but the year is picked from the second dash-separated field.
$ii would refer to a variable, but it's not set before the test if [ $mm -eq $ii ]; so the test sees [ 123 -eq ] (with 123 probably some number picked from $1). That causes an error since the operator -eq is missing the other operand.
iiis undefined on the first iteration, but that's semantically zero; on subsequent iterations, it gets incremented. I don't think the logic is entirely correct, but with a few fixes, the loop would convert -- horribly clumsily -- from a month name to a month number. (Notice also how the month names use erratic capitalization and abbreviation conventions, and how July is incorrectly listed before June.)
– tripleee
Jun 16 '17 at 15:43
I guess withii=1instead ofi=1it would superficially work for many month names.
– tripleee
Jun 16 '17 at 15:47
mmis set before the loop, apparently to the month name.
– tripleee
Jun 16 '17 at 15:47
@tripleee, without changing fromi=1toii=1, I get an error in bash on the first loop, so I think it needs to be set prior to the first loop iteration as you subsequently noted.
– KevinO
Jun 16 '17 at 15:56
@tripleee, sorry, my bad on themm. But since$iiis unquoted, it resolves to nothing, so that still doesn't work... And even when quoted, I think the empty string would give an error from-eq.
– ilkkachu
Jun 16 '17 at 16:16
|
show 3 more comments
$1 is the first positional parameter, i.e. argument to the function. awk -F- sets awks field separator to a dash, and print $2 prints the second field. So from aa-bb-cc, you'd get bb.
Presumably the function expects to be called as getDateFormat something-2017-06 which looks odd, but the year is picked from the second dash-separated field.
$ii would refer to a variable, but it's not set before the test if [ $mm -eq $ii ]; so the test sees [ 123 -eq ] (with 123 probably some number picked from $1). That causes an error since the operator -eq is missing the other operand.
iiis undefined on the first iteration, but that's semantically zero; on subsequent iterations, it gets incremented. I don't think the logic is entirely correct, but with a few fixes, the loop would convert -- horribly clumsily -- from a month name to a month number. (Notice also how the month names use erratic capitalization and abbreviation conventions, and how July is incorrectly listed before June.)
– tripleee
Jun 16 '17 at 15:43
I guess withii=1instead ofi=1it would superficially work for many month names.
– tripleee
Jun 16 '17 at 15:47
mmis set before the loop, apparently to the month name.
– tripleee
Jun 16 '17 at 15:47
@tripleee, without changing fromi=1toii=1, I get an error in bash on the first loop, so I think it needs to be set prior to the first loop iteration as you subsequently noted.
– KevinO
Jun 16 '17 at 15:56
@tripleee, sorry, my bad on themm. But since$iiis unquoted, it resolves to nothing, so that still doesn't work... And even when quoted, I think the empty string would give an error from-eq.
– ilkkachu
Jun 16 '17 at 16:16
|
show 3 more comments
$1 is the first positional parameter, i.e. argument to the function. awk -F- sets awks field separator to a dash, and print $2 prints the second field. So from aa-bb-cc, you'd get bb.
Presumably the function expects to be called as getDateFormat something-2017-06 which looks odd, but the year is picked from the second dash-separated field.
$ii would refer to a variable, but it's not set before the test if [ $mm -eq $ii ]; so the test sees [ 123 -eq ] (with 123 probably some number picked from $1). That causes an error since the operator -eq is missing the other operand.
$1 is the first positional parameter, i.e. argument to the function. awk -F- sets awks field separator to a dash, and print $2 prints the second field. So from aa-bb-cc, you'd get bb.
Presumably the function expects to be called as getDateFormat something-2017-06 which looks odd, but the year is picked from the second dash-separated field.
$ii would refer to a variable, but it's not set before the test if [ $mm -eq $ii ]; so the test sees [ 123 -eq ] (with 123 probably some number picked from $1). That causes an error since the operator -eq is missing the other operand.
edited Jun 16 '17 at 16:12
answered Jun 16 '17 at 15:21
ilkkachuilkkachu
63.5k10104181
63.5k10104181
iiis undefined on the first iteration, but that's semantically zero; on subsequent iterations, it gets incremented. I don't think the logic is entirely correct, but with a few fixes, the loop would convert -- horribly clumsily -- from a month name to a month number. (Notice also how the month names use erratic capitalization and abbreviation conventions, and how July is incorrectly listed before June.)
– tripleee
Jun 16 '17 at 15:43
I guess withii=1instead ofi=1it would superficially work for many month names.
– tripleee
Jun 16 '17 at 15:47
mmis set before the loop, apparently to the month name.
– tripleee
Jun 16 '17 at 15:47
@tripleee, without changing fromi=1toii=1, I get an error in bash on the first loop, so I think it needs to be set prior to the first loop iteration as you subsequently noted.
– KevinO
Jun 16 '17 at 15:56
@tripleee, sorry, my bad on themm. But since$iiis unquoted, it resolves to nothing, so that still doesn't work... And even when quoted, I think the empty string would give an error from-eq.
– ilkkachu
Jun 16 '17 at 16:16
|
show 3 more comments
iiis undefined on the first iteration, but that's semantically zero; on subsequent iterations, it gets incremented. I don't think the logic is entirely correct, but with a few fixes, the loop would convert -- horribly clumsily -- from a month name to a month number. (Notice also how the month names use erratic capitalization and abbreviation conventions, and how July is incorrectly listed before June.)
– tripleee
Jun 16 '17 at 15:43
I guess withii=1instead ofi=1it would superficially work for many month names.
– tripleee
Jun 16 '17 at 15:47
mmis set before the loop, apparently to the month name.
– tripleee
Jun 16 '17 at 15:47
@tripleee, without changing fromi=1toii=1, I get an error in bash on the first loop, so I think it needs to be set prior to the first loop iteration as you subsequently noted.
– KevinO
Jun 16 '17 at 15:56
@tripleee, sorry, my bad on themm. But since$iiis unquoted, it resolves to nothing, so that still doesn't work... And even when quoted, I think the empty string would give an error from-eq.
– ilkkachu
Jun 16 '17 at 16:16
ii is undefined on the first iteration, but that's semantically zero; on subsequent iterations, it gets incremented. I don't think the logic is entirely correct, but with a few fixes, the loop would convert -- horribly clumsily -- from a month name to a month number. (Notice also how the month names use erratic capitalization and abbreviation conventions, and how July is incorrectly listed before June.)– tripleee
Jun 16 '17 at 15:43
ii is undefined on the first iteration, but that's semantically zero; on subsequent iterations, it gets incremented. I don't think the logic is entirely correct, but with a few fixes, the loop would convert -- horribly clumsily -- from a month name to a month number. (Notice also how the month names use erratic capitalization and abbreviation conventions, and how July is incorrectly listed before June.)– tripleee
Jun 16 '17 at 15:43
I guess with
ii=1 instead of i=1 it would superficially work for many month names.– tripleee
Jun 16 '17 at 15:47
I guess with
ii=1 instead of i=1 it would superficially work for many month names.– tripleee
Jun 16 '17 at 15:47
mm is set before the loop, apparently to the month name.– tripleee
Jun 16 '17 at 15:47
mm is set before the loop, apparently to the month name.– tripleee
Jun 16 '17 at 15:47
@tripleee, without changing from
i=1 to ii=1, I get an error in bash on the first loop, so I think it needs to be set prior to the first loop iteration as you subsequently noted.– KevinO
Jun 16 '17 at 15:56
@tripleee, without changing from
i=1 to ii=1, I get an error in bash on the first loop, so I think it needs to be set prior to the first loop iteration as you subsequently noted.– KevinO
Jun 16 '17 at 15:56
@tripleee, sorry, my bad on the
mm. But since $ii is unquoted, it resolves to nothing, so that still doesn't work... And even when quoted, I think the empty string would give an error from -eq.– ilkkachu
Jun 16 '17 at 16:16
@tripleee, sorry, my bad on the
mm. But since $ii is unquoted, it resolves to nothing, so that still doesn't work... And even when quoted, I think the empty string would give an error from -eq.– ilkkachu
Jun 16 '17 at 16:16
|
show 3 more comments
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f371535%2fplease-explain-below-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
One cannot explain this abomination of code. From uninitialized variables (
$iiused in a test) to inconsistent spelling and capitalization of the months, to an undocumented and clearly uncommon input requirement.– KevinO
Jun 16 '17 at 15:27