I'm facing this kind of error:
zsh: argument list too long: [command]
I need to launch a command via terminal that needs as argument a long string (it's about 1.4mb).
So instead of copy-paste the string into the terminal I actually save it on a file and then I take the content with cat file.txt.
So the command I launch in the end is:
bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=16593 -rpcuser=root -rpcpassword=root submitblock 'cat test.txt'
(where ' symbols before and after cat test.txt are `)
This, as I said before, leads me to the error zsh: argument list too long: bitcoin-cli.
I've already tried to follow this blog post:
Link
Even if it changed the setting returned by ulimit -a, it didn't solve my issue.
Does anyone knows a solution?
Thanks everyone!
The maximum length of a command is defined by the kern.argmax sysctl setting, which is not changeable. On my system (El Capitan) it's 256kB:
$ sysctl kern.argmax
kern.argmax: 262144
So I don't think you'll be able to specify your block on the command line. Maybe there's the possibility to load it from a file or from standard input?
Related
Context:
The problem comes from the work folder location: if I should work in a subfolder of a subfolder of a subfolder et cetera... The command line of the shell bask in Linux is so long that can use two lines to be correctly printed.
Question:
Is there a way of showing only the last (or the few last) working subfolder?
Example:
What is actually printed:
user#user-pc:~/Documents/robotic_arm/Monitoring/difference/develop/component/example/subfolder/subexample/module$
What I would love to see:
user#user-pc:~/.../subexample/module$
More Info:
Xubuntu 16.04
Terminator is used instead of the default "Linux Terminal Emulator"
I had a look on this Stackoverflow's question but it is for the input and not for the default line printed by the shell
Have a look at the PROMPTING section of man bash. You configure the prompt by setting PS1, and I suspect your current setting is something like this:
$ echo $PS1
\u#\h:\w\$
If you change it to
$ PS1='\u#\h:\W\$ '
it will only print the basename of the current working directory.
I do not know why but the previous answer does not work on my machine. However, an alternative solution that works fine is:
PROMPT_DIRTRIM=N
where N is the number of subfolders you want to see.
Example:
user#user-pc:~/Documents/robotic_arm/difference/develop/component/ $ PROMPT_DIRTRIM=2
user#user-pc:~/.../develop/component/ $
The solution was suggested by one of the answers above this question.
I googled this command but there was not.
grep -m 1 "\[{" xxx.txt > xxx.txt
However I typed this command, error didn't occured.
Actually, there was not also result of this command.
Please anyone explain me this command's working?
This command reads from and writes to the same file, but not in a left-to-right fashion. In fact > xxx.txt runs first, emptying the file before the grep command starts reading it. Therefore there is no output. You can fix this by storing the result in a temporary file and then renaming that file to the original name.
PS: Some commands, like sed, have an output file option which works around this issue by not relying on shell redirects.
I'm trying to use grep in my Mac Terminal window, and it's giving me that error message. What is that? I've never seen it before and Google is not helping. Looks like DIRAC3LE is some kind of Mac audio plugin -- but why would that interfere with grep?!? Thanks for any help!
Your shell is probably expanding * and there is a '--DIRAC3LE--' in the working directory. grep is then confusing the leading -- with command line options.
Try using
grep -r "string" .
This will recursively search for everything in the working directory.
Also try using "--" before the *. POSIX commands use this to indicate the end of the command line options to prevent such ambiguity (see comments for a reference).
I'm trying to write a script that contains this
screen -S demo -d -m which should start a new screen session named demo and detach it.
Putting screen -S demo -d -m in the command line works.
If I put it in a file named boot.sh, and run it ./boot.sh I get
Error: Unknown option m
Why does this work in the command line but not as a shell script?
This file was transferred from windows and had ctrl-M characters.
Running "screen" on my Linux machine, a bad option (Screen version 4.00.03jw4 (FAU) 2-May-06) gives the error,
Error: Unknown option -z"
while your description includes no dash before the offending option. I'd check that the characters in your script file are what you expect them to be. There are many characters that look like a dash but which are not.
cat -v boot.sh
may show something interesting as it'll show codes for non-ascii characters.
This may seem a little like the "make sure your printer is plugged in" kind of help, but anyway:
have you tried to check if the screen you're invoking from the script is the same as the one invoked from the command line ?
I'm thinking you may change the PATH variable inside your script somewhere and perhaps screen from the script would be something else (a different version, perhaps ?).
I recently discovered 'comint-show-output' in emacs shell mode, which jumps to the first line of shell output, which I find incredibly handy when looking at shell output that exceeds a screen length. The advantages of this command over scrolling with 'page up' are A) you don't have to scan with your eyes for the first line of the output B) you only have to hit the key combo once (instead of 'page up' a number of times which probably is not known beforehand).
I thought about ending all my commands with '| more' but actually this is not what I want since most of the time, I want to retain all output in the terminal buffer, and I usually want to see the end of the shell output first.
I use OSX. Is there a terminal app (on os x) and shell (on remote linux) combination equivalent (so I can do something similar without using emacs all the time - I know, crazy talk)? I normally use bash, but would be fine with switching shells just for this feature.
The way I do this sort of thing is by sending my output to a file and then watching the file as it is written. You still get the results of the command dumped to terminal history in real time and can still inspect the output's actual contents further after the fact (or in another terminal, etc...)
command > output &
tail -f output
head output
You could always do something in bash like this:
alias foo='!! | more'
which would make foo run the previous command with more. I'm not sure of any way to do exactly what you are suggesting.
If you're expecting a lot of output and don't want to run your command twice, you can use tee(1) to fork the output:
my-command | tee /tmp/my-command.log | less
This will pipe the output to a paginator (less), while simultaneously logging the output to a file (in this case, a file named /tmp/my-command.log). If you need to review the output after you've quit from less, you can just cat the log file instead of re-running the command.