kornShell and AIX unable to create an Array Variable
Clash Royale CLAN TAG#URR8PPP
LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`
I cannot use for loop as I need to check conditions with while as there are multiple conditions.
Trying to access the content using
$LS[$CNT]
CNT=`expr $CNT + 1`
I am unable to access the contents.
aix array
add a comment |
LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`
I cannot use for loop as I need to check conditions with while as there are multiple conditions.
Trying to access the content using
$LS[$CNT]
CNT=`expr $CNT + 1`
I am unable to access the contents.
aix array
add a comment |
LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`
I cannot use for loop as I need to check conditions with while as there are multiple conditions.
Trying to access the content using
$LS[$CNT]
CNT=`expr $CNT + 1`
I am unable to access the contents.
aix array
LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`
I cannot use for loop as I need to check conditions with while as there are multiple conditions.
Trying to access the content using
$LS[$CNT]
CNT=`expr $CNT + 1`
I am unable to access the contents.
aix array
aix array
edited Jan 12 at 1:08
Rui F Ribeiro
39.6k1479132
39.6k1479132
asked Jan 11 at 22:38
Bootham DeyyamBootham Deyyam
111
111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
We'll start with Do not parse the output of ls because it's always good to remind people of this.
Next note that the grep
probably isn't doing what you want; you likely want .ignore$
to make it skip files ending with ".ignore"
Since we're using ksh
you don't need to call expr
; you can just do let CNT=CNT+1
Now..
To set an array in ksh
you need to use set -A
syntax.
eg
set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')
Now $LS[0]
will be the first file, etc etc.
eg if we have
$ ls X
a b c
Then
$ set -A LS $(ls X)
$ echo $LS[0]
a
$ echo $LS[1]
b
$ echo $LS[2]
c
Thank you very much, this worked.
– Bootham Deyyam
Jan 13 at 19:33
add a comment |
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%2f494040%2fkornshell-and-aix-unable-to-create-an-array-variable%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
We'll start with Do not parse the output of ls because it's always good to remind people of this.
Next note that the grep
probably isn't doing what you want; you likely want .ignore$
to make it skip files ending with ".ignore"
Since we're using ksh
you don't need to call expr
; you can just do let CNT=CNT+1
Now..
To set an array in ksh
you need to use set -A
syntax.
eg
set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')
Now $LS[0]
will be the first file, etc etc.
eg if we have
$ ls X
a b c
Then
$ set -A LS $(ls X)
$ echo $LS[0]
a
$ echo $LS[1]
b
$ echo $LS[2]
c
Thank you very much, this worked.
– Bootham Deyyam
Jan 13 at 19:33
add a comment |
We'll start with Do not parse the output of ls because it's always good to remind people of this.
Next note that the grep
probably isn't doing what you want; you likely want .ignore$
to make it skip files ending with ".ignore"
Since we're using ksh
you don't need to call expr
; you can just do let CNT=CNT+1
Now..
To set an array in ksh
you need to use set -A
syntax.
eg
set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')
Now $LS[0]
will be the first file, etc etc.
eg if we have
$ ls X
a b c
Then
$ set -A LS $(ls X)
$ echo $LS[0]
a
$ echo $LS[1]
b
$ echo $LS[2]
c
Thank you very much, this worked.
– Bootham Deyyam
Jan 13 at 19:33
add a comment |
We'll start with Do not parse the output of ls because it's always good to remind people of this.
Next note that the grep
probably isn't doing what you want; you likely want .ignore$
to make it skip files ending with ".ignore"
Since we're using ksh
you don't need to call expr
; you can just do let CNT=CNT+1
Now..
To set an array in ksh
you need to use set -A
syntax.
eg
set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')
Now $LS[0]
will be the first file, etc etc.
eg if we have
$ ls X
a b c
Then
$ set -A LS $(ls X)
$ echo $LS[0]
a
$ echo $LS[1]
b
$ echo $LS[2]
c
We'll start with Do not parse the output of ls because it's always good to remind people of this.
Next note that the grep
probably isn't doing what you want; you likely want .ignore$
to make it skip files ending with ".ignore"
Since we're using ksh
you don't need to call expr
; you can just do let CNT=CNT+1
Now..
To set an array in ksh
you need to use set -A
syntax.
eg
set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')
Now $LS[0]
will be the first file, etc etc.
eg if we have
$ ls X
a b c
Then
$ set -A LS $(ls X)
$ echo $LS[0]
a
$ echo $LS[1]
b
$ echo $LS[2]
c
answered Jan 11 at 22:50
Stephen HarrisStephen Harris
25.5k24477
25.5k24477
Thank you very much, this worked.
– Bootham Deyyam
Jan 13 at 19:33
add a comment |
Thank you very much, this worked.
– Bootham Deyyam
Jan 13 at 19:33
Thank you very much, this worked.
– Bootham Deyyam
Jan 13 at 19:33
Thank you very much, this worked.
– Bootham Deyyam
Jan 13 at 19:33
add a comment |
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%2f494040%2fkornshell-and-aix-unable-to-create-an-array-variable%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