What is the convention for line wrapping in command-line instructions? [closed] - command-line

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I need to document some very long command line instructions. What convention should I use to indicate that the line is not broken?
For example, for the command:
fab --fabfile=create_virtualenv.py --hosts=<user#remote> create_virtualenv:base=<base_folder>,name=<ve_name>,requirements=<requirements_file>,packages=<package_folder>
I was thinking:
fab --fabfile=create_virtualenv.py --hosts=<user#remote> \\
create_virtualenv:base=<base_folder>,name=<ve_name>,\\
requirements=<requirements_file>,packages=<package_folder>
but that's just me making something up based on a half-forgotten example, and I can see potential for ambiguities regarding whitespace and punctuation.
A referenced standard would be best, or consistent, well-regarded implementation.

On Windows, I would use the same character that CMD.EXE uses for line continuation - the caret ^.
fab --fabfile=create_virtualenv.py --hosts=<user#remote> ^
create_virtualenv:base=<base_folder>,name=<ve_name>,^
requirements=<requirements_file>,packages=<package_folder>
See Long commands split over multiple lines in Windows Vista batch (.bat) file for more info. Be sure to read the first three answers, as they each have useful information.
On 'nix, I would use a single \ for the same reason. A double \\ would imply a backslash literal, so that is not good. But a single \ at the end implies line continuation.
fab --fabfile=create_virtualenv.py --hosts=<user#remote> \
create_virtualenv:base=<base_folder>,name=<ve_name>,\
requirements=<requirements_file>,packages=<package_folder>

Related

ANSI sequence to change terminal name [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I use a bash script (konsole-name.sh) to change a terminal name, like this:
#!/usr/bin/bash
echo -en "\e]30;$1\a"
and I wanted to use the same method from a perl script that I use to check the GPU temperature, so that it updates periodically the window title.
Yet I didnt find a way.
I tried both this:
$comm='echo -en "\e]30;T=$t\a"';
`$comm`;
and this, using my bash script:
$comm="konsole-name.sh T=$t";
`$comm`;
there is some way to do it?
The console escape sequences work by printing text to the terminal. In your case, the backticks gobble up the output of the script.
Most likely you just want print "\e]30;$1\a"; from within Perl:
my $title = "Fancy terminal title";
print "\e]30;${title}\a";

Double exclamation in fish shell [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
In zsh, I can execute them.
$ sleep 1
$ echo !$ # !$ equals 1
$ echo !! # !! equals sleep 1
But I can't execute them in fish shell.
Could tell me why and where the zsh documentation is?
This is history expansion, which has a lot more to it then those simple examples.
Fish supports none of it (and probably never will). The usual workaround is to use keybindings. By default, alt-up and alt-down should go through the history token-wise, so you can press alt-up once to get what is effectively !$.
If you wish to prepend something to a command from history, recall that command, go to the beginning (e.g. with ctrl-a) and insert what you want.
Other possibilities are functions to bind e.g. !! to something to insert the previous command or to make a command called !!.
This is still discussed in fish issue #288, though concensus seems to be against adding history expansion.

Sed: print 2 lines before a match [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to print the two previous lines before matches inside a file (for any match)
How to make it?
Thank you
The script:
sed -n "1N;2N;/XXX[^\n]*$/{h;s/\n[^\n]*$//;p;g};N;D"
works as follows:
Read the first three lines into the pattern space, 1N;2N
Search for the test string XXX in the last line, and if found: save pattern space in hold space h, delete last line s, print p, and then restore saved string g
Append the next line input to pattern space, N
Delete first line from pattern space and restart cycle, D, noting that 1N;2N is no longer applicable
See also similar SED: addressing two lines before match.
If you do not insist on using sed, use
grep -B 2

Comments are getting executed when I run the Perl Script [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Some of my perl statements are executed even after commenting. I tried all the delimiter #, /*..*/, //
Does anyone face the same issue or can anyone help me how to solve this issue?
Your question appears to be "How do I create a comment in Perl?"
perlsyn says thusly:
Text from a "#" character until the end of the line is a comment, and is ignored. Exceptions include "#" inside a string or regular expression.
For example,
print "apple\n"; # Keeps the doctor away.
Keep in mind that comments can only be used where whitespace is expected. For example, the following does not contain any comments since the # is part of the string literal.
print "apple # Keeps the doctor away.
orange
";

Searching through Stackoverflow.com from the commandline/bash [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
As the title says i am looking for a way to search through stackoverflow.com using only the command line specifically bash in linux.
Things I need to accomplish :
I just need to get the top 10 answers for my question or even top 5.
Plain Text Output , i.e. strip
HTML out if possible.
Also I would prefer if you didnt give a answer that required elinks or something similar.
here's a rough script to run from command line that does the job
wget 'http://stackoverflow.com/feeds/tag?tagnames=command-line&sort=newest' -qO - | perl -nle ' print $1 if /\<title[^>]+\>([^<]*)/;'|head
It grabs RSS output for a given tag (command-line here) and sort of parses it.
To be done properly one would probably want to parse XML in a better way or use some perl rss parser.