Solution for Argument list too long The Next CEO of Stack Overflowfind + xargs: argument line too longSolving “mv: Argument list too long”?xargs line too longbash: /usr/bin/perl: Argument list too long/usr/bin/awk: Argument list too longArgument list too long with just 5000 files/bin/cat: Argument list too longxargs: argument line too longArgument list is too long for /bin/awsbash: assign variable and print to stdout in same command
How to avoid supervisors with prejudiced views?
Won the lottery - how do I keep the money?
Proper way to express "He disappeared them"
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
What does "Its cash flow is deeply negative" mean?
Writing differences on a blackboard
"misplaced omit" error when >centering columns
Why isn't the Mueller report being released completely and unredacted?
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
RigExpert AA-35 - Interpreting The Information
How to get from Geneva Airport to Metabief, Doubs, France by public transport?
Is it convenient to ask the journal's editor for two additional days to complete a review?
Does soap repel water?
Can I use the load factor to estimate the lift?
Is it professional to write unrelated content in an almost-empty email?
How is this set of matrices closed under multiplication?
Can this equation be simplified further?
Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?
Domestic-to-international connection at Orlando (MCO)
What steps are necessary to read a Modern SSD in Medieval Europe?
Why is information "lost" when it got into a black hole?
How to invert MapIndexed on a ragged structure? How to construct a tree from rules?
Yu-Gi-Oh cards in Python 3
Solution for Argument list too long
The Next CEO of Stack Overflowfind + xargs: argument line too longSolving “mv: Argument list too long”?xargs line too longbash: /usr/bin/perl: Argument list too long/usr/bin/awk: Argument list too longArgument list too long with just 5000 files/bin/cat: Argument list too longxargs: argument line too longArgument list is too long for /bin/awsbash: assign variable and print to stdout in same command
I have the below shell script which reads a file, copies the content of the file to a variable and passes the variable as argument to another command.
declare -a arr=()
while IFS= read -r var
do
arr+=( $var )
done < "accounts.json"
args=''
for j in "$arr[@]"
do
args="$args $j"
done
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced",'""$args""']'
This works very well when the accounts.json file is small. But I get an error that says "Argument list too long" when the size of accounts.json is too large. I have tried xargs but to no success.
edit 1:
below is example json file with only two rows
["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]
Below is what a peer command would look like with actual data
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced","["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]"]'
linux bash xargs
New contributor
|
show 3 more comments
I have the below shell script which reads a file, copies the content of the file to a variable and passes the variable as argument to another command.
declare -a arr=()
while IFS= read -r var
do
arr+=( $var )
done < "accounts.json"
args=''
for j in "$arr[@]"
do
args="$args $j"
done
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced",'""$args""']'
This works very well when the accounts.json file is small. But I get an error that says "Argument list too long" when the size of accounts.json is too large. I have tried xargs but to no success.
edit 1:
below is example json file with only two rows
["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]
Below is what a peer command would look like with actual data
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced","["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]"]'
linux bash xargs
New contributor
1
You would not be able to usexargs
here as you (I assume) you need to give the complete JSON document in one go. Is that correct? Can thatpeer
command be made to read the document from a file instead from the command line? (Note: I'm unsure whatpeer
is).
– Kusalananda♦
2 days ago
Yes, I need the complete json document in one go. I cannot use the peer command to read document from a file. peer is not a native unix/linux command. It comes from Hyperledger fabric (a blockchain service).
– user344247
2 days ago
1
Please show a sample of the input file and show what the-c
argument is supposed to look like. I bet a simple jq script is all that's required. That would mean you don't need to break up the file into lines and then combine the lines into a string: jq would do that for you.
– glenn jackman
2 days ago
@glennjackman That wouldn't make the actual argument topeer
shorter in the end, would it?
– Kusalananda♦
2 days ago
@glennjackman. I have edited my question and added a few examples. Please don't worry about use of double quotes inside single quotes. I have made sure to have escape characters
– user344247
2 days ago
|
show 3 more comments
I have the below shell script which reads a file, copies the content of the file to a variable and passes the variable as argument to another command.
declare -a arr=()
while IFS= read -r var
do
arr+=( $var )
done < "accounts.json"
args=''
for j in "$arr[@]"
do
args="$args $j"
done
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced",'""$args""']'
This works very well when the accounts.json file is small. But I get an error that says "Argument list too long" when the size of accounts.json is too large. I have tried xargs but to no success.
edit 1:
below is example json file with only two rows
["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]
Below is what a peer command would look like with actual data
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced","["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]"]'
linux bash xargs
New contributor
I have the below shell script which reads a file, copies the content of the file to a variable and passes the variable as argument to another command.
declare -a arr=()
while IFS= read -r var
do
arr+=( $var )
done < "accounts.json"
args=''
for j in "$arr[@]"
do
args="$args $j"
done
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced",'""$args""']'
This works very well when the accounts.json file is small. But I get an error that says "Argument list too long" when the size of accounts.json is too large. I have tried xargs but to no success.
edit 1:
below is example json file with only two rows
["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]
Below is what a peer command would look like with actual data
peer chaincode invoke -n cc -C channel1 -c '"Args":["InitLedgerAdvanced","["accountID":"C682227132","accountStatus":"1",
"accountID":"C800427392","accountStatus":"1"]"]'
linux bash xargs
linux bash xargs
New contributor
New contributor
edited 2 days ago
Rui F Ribeiro
41.8k1483142
41.8k1483142
New contributor
asked 2 days ago
user344247user344247
63
63
New contributor
New contributor
1
You would not be able to usexargs
here as you (I assume) you need to give the complete JSON document in one go. Is that correct? Can thatpeer
command be made to read the document from a file instead from the command line? (Note: I'm unsure whatpeer
is).
– Kusalananda♦
2 days ago
Yes, I need the complete json document in one go. I cannot use the peer command to read document from a file. peer is not a native unix/linux command. It comes from Hyperledger fabric (a blockchain service).
– user344247
2 days ago
1
Please show a sample of the input file and show what the-c
argument is supposed to look like. I bet a simple jq script is all that's required. That would mean you don't need to break up the file into lines and then combine the lines into a string: jq would do that for you.
– glenn jackman
2 days ago
@glennjackman That wouldn't make the actual argument topeer
shorter in the end, would it?
– Kusalananda♦
2 days ago
@glennjackman. I have edited my question and added a few examples. Please don't worry about use of double quotes inside single quotes. I have made sure to have escape characters
– user344247
2 days ago
|
show 3 more comments
1
You would not be able to usexargs
here as you (I assume) you need to give the complete JSON document in one go. Is that correct? Can thatpeer
command be made to read the document from a file instead from the command line? (Note: I'm unsure whatpeer
is).
– Kusalananda♦
2 days ago
Yes, I need the complete json document in one go. I cannot use the peer command to read document from a file. peer is not a native unix/linux command. It comes from Hyperledger fabric (a blockchain service).
– user344247
2 days ago
1
Please show a sample of the input file and show what the-c
argument is supposed to look like. I bet a simple jq script is all that's required. That would mean you don't need to break up the file into lines and then combine the lines into a string: jq would do that for you.
– glenn jackman
2 days ago
@glennjackman That wouldn't make the actual argument topeer
shorter in the end, would it?
– Kusalananda♦
2 days ago
@glennjackman. I have edited my question and added a few examples. Please don't worry about use of double quotes inside single quotes. I have made sure to have escape characters
– user344247
2 days ago
1
1
You would not be able to use
xargs
here as you (I assume) you need to give the complete JSON document in one go. Is that correct? Can that peer
command be made to read the document from a file instead from the command line? (Note: I'm unsure what peer
is).– Kusalananda♦
2 days ago
You would not be able to use
xargs
here as you (I assume) you need to give the complete JSON document in one go. Is that correct? Can that peer
command be made to read the document from a file instead from the command line? (Note: I'm unsure what peer
is).– Kusalananda♦
2 days ago
Yes, I need the complete json document in one go. I cannot use the peer command to read document from a file. peer is not a native unix/linux command. It comes from Hyperledger fabric (a blockchain service).
– user344247
2 days ago
Yes, I need the complete json document in one go. I cannot use the peer command to read document from a file. peer is not a native unix/linux command. It comes from Hyperledger fabric (a blockchain service).
– user344247
2 days ago
1
1
Please show a sample of the input file and show what the
-c
argument is supposed to look like. I bet a simple jq script is all that's required. That would mean you don't need to break up the file into lines and then combine the lines into a string: jq would do that for you.– glenn jackman
2 days ago
Please show a sample of the input file and show what the
-c
argument is supposed to look like. I bet a simple jq script is all that's required. That would mean you don't need to break up the file into lines and then combine the lines into a string: jq would do that for you.– glenn jackman
2 days ago
@glennjackman That wouldn't make the actual argument to
peer
shorter in the end, would it?– Kusalananda♦
2 days ago
@glennjackman That wouldn't make the actual argument to
peer
shorter in the end, would it?– Kusalananda♦
2 days ago
@glennjackman. I have edited my question and added a few examples. Please don't worry about use of double quotes inside single quotes. I have made sure to have escape characters
– user344247
2 days ago
@glennjackman. I have edited my question and added a few examples. Please don't worry about use of double quotes inside single quotes. I have made sure to have escape characters
– user344247
2 days ago
|
show 3 more comments
1 Answer
1
active
oldest
votes
This might work
# slurp the accounts file into a variable
accounts=$(< accounts.json)
# create the json, escaping the accounts quotes along the way
printf -v json '"Args":["InitLedgerAdvanced","%s"]' "$accounts//"/\""
# and invoke the command
peer chaincode invoke -n cc -C channel1 -c "$json"
If that still gives you trouble, you'll have to find a way to pass the -c
argument to "peer" via stdin or a file, not as a command line argument.
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
);
);
user344247 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f509300%2fsolution-for-argument-list-too-long%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
This might work
# slurp the accounts file into a variable
accounts=$(< accounts.json)
# create the json, escaping the accounts quotes along the way
printf -v json '"Args":["InitLedgerAdvanced","%s"]' "$accounts//"/\""
# and invoke the command
peer chaincode invoke -n cc -C channel1 -c "$json"
If that still gives you trouble, you'll have to find a way to pass the -c
argument to "peer" via stdin or a file, not as a command line argument.
add a comment |
This might work
# slurp the accounts file into a variable
accounts=$(< accounts.json)
# create the json, escaping the accounts quotes along the way
printf -v json '"Args":["InitLedgerAdvanced","%s"]' "$accounts//"/\""
# and invoke the command
peer chaincode invoke -n cc -C channel1 -c "$json"
If that still gives you trouble, you'll have to find a way to pass the -c
argument to "peer" via stdin or a file, not as a command line argument.
add a comment |
This might work
# slurp the accounts file into a variable
accounts=$(< accounts.json)
# create the json, escaping the accounts quotes along the way
printf -v json '"Args":["InitLedgerAdvanced","%s"]' "$accounts//"/\""
# and invoke the command
peer chaincode invoke -n cc -C channel1 -c "$json"
If that still gives you trouble, you'll have to find a way to pass the -c
argument to "peer" via stdin or a file, not as a command line argument.
This might work
# slurp the accounts file into a variable
accounts=$(< accounts.json)
# create the json, escaping the accounts quotes along the way
printf -v json '"Args":["InitLedgerAdvanced","%s"]' "$accounts//"/\""
# and invoke the command
peer chaincode invoke -n cc -C channel1 -c "$json"
If that still gives you trouble, you'll have to find a way to pass the -c
argument to "peer" via stdin or a file, not as a command line argument.
answered 2 days ago
glenn jackmanglenn jackman
52.9k573114
52.9k573114
add a comment |
add a comment |
user344247 is a new contributor. Be nice, and check out our Code of Conduct.
user344247 is a new contributor. Be nice, and check out our Code of Conduct.
user344247 is a new contributor. Be nice, and check out our Code of Conduct.
user344247 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f509300%2fsolution-for-argument-list-too-long%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
1
You would not be able to use
xargs
here as you (I assume) you need to give the complete JSON document in one go. Is that correct? Can thatpeer
command be made to read the document from a file instead from the command line? (Note: I'm unsure whatpeer
is).– Kusalananda♦
2 days ago
Yes, I need the complete json document in one go. I cannot use the peer command to read document from a file. peer is not a native unix/linux command. It comes from Hyperledger fabric (a blockchain service).
– user344247
2 days ago
1
Please show a sample of the input file and show what the
-c
argument is supposed to look like. I bet a simple jq script is all that's required. That would mean you don't need to break up the file into lines and then combine the lines into a string: jq would do that for you.– glenn jackman
2 days ago
@glennjackman That wouldn't make the actual argument to
peer
shorter in the end, would it?– Kusalananda♦
2 days ago
@glennjackman. I have edited my question and added a few examples. Please don't worry about use of double quotes inside single quotes. I have made sure to have escape characters
– user344247
2 days ago