QuestionId
stringlengths
3
8
QuestionTitle
stringlengths
15
149
QuestionScore
int64
1
27.2k
QuestionCreatedUtc
stringdate
2008-08-01 18:33:08
2025-06-16 04:59:48
QuestionBodyHtml
stringlengths
40
28.2k
QuestionViewCount
int64
78
16.5M
QuestionOwnerUserId
float64
4
25.2M
QuestionLastActivityUtc
stringdate
2008-09-08 19:26:01
2026-01-24 22:40:25
AcceptedAnswerId
int64
266
79.7M
AnswerScore
int64
2
30.1k
AnswerCreatedUtc
stringdate
2008-08-01 23:40:28
2025-06-16 05:23:39
AnswerOwnerUserId
float64
1
29.5M
AnswerLastActivityUtc
stringdate
2008-08-01 23:40:28
2026-01-23 17:46:09
QuestionLink
stringlengths
31
36
AnswerLink
stringlengths
31
36
AnswerBodyHtml
stringlengths
35
33k
AnswerBodyPreview
stringlengths
35
400
AllTagIdsCsv
stringlengths
2
37
AllTagNamesCsv
stringlengths
2
106
MergedQuestion
stringlengths
74
28.4k
quality_filter
stringclasses
10 values
unique_id
int64
0
29k
tag_major_lang
stringclasses
10 values
MergedQuestion_md
stringlengths
60
28.1k
AnswerBodyHtml_md
stringlengths
14
29.2k
1673649
.vimrc action onclose
11
2009-11-04 13:08:07
<p>is it possible to use something like an "vim-close/exit"-Event to execute some last commands before vim quits?</p> <p>I use this lines in my config, to let vim set my screen-title:</p> <blockquote> <p>if $TERM=='xterm-color'</p> <pre><code> exe "set title titlestring=vim:%t" exe "set title t_ts=\&lt;ESC&gt;k t...
2,607
62,824
2014-05-15 03:16:31
1,673,687
12
2009-11-04 13:18:39
128,661
2009-11-04 13:28:48
https://stackoverflow.com/q/1673649
https://stackoverflow.com/a/1673687
<p>Yes, there is a "close-event" -- actually two of them.<br> To quote vim's <strong>:help {event}</strong>: </p> <pre><code> Startup and exit |VimEnter| after doing all the startup stuff |GUIEnter| after starting the GUI successfully |TermResponse| after the terminal response ...
<p>Yes, there is a "close-event" -- actually two of them.<br> To quote vim's <strong>:help {event}</strong>: </p> <pre><code> Startup and exit |VimEnter| after doing all the startup stuff |GUIEnter| after starting the GUI successfully |TermResponse| after the terminal response ...
370, 387
bash, vim
<h1>.vimrc action onclose</h1> <p>is it possible to use something like an "vim-close/exit"-Event to execute some last commands before vim quits?</p> <p>I use this lines in my config, to let vim set my screen-title:</p> <blockquote> <p>if $TERM=='xterm-color'</p> <pre><code> exe "set title titlestring=vim:%t" exe ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,772
bash
# .vimrc action onclose is it possible to use something like an "vim-close/exit"-Event to execute some last commands before vim quits? I use this lines in my config, to let vim set my screen-title: > if $TERM=='xterm-color' > > ``` > exe "set title titlestring=vim:%t" > exe "set title t_ts=\<ESC>k t_fs=\<ESC>\\" >...
Yes, there is a "close-event" -- actually two of them. To quote vim's **:help {event}**: ``` Startup and exit |VimEnter| after doing all the startup stuff |GUIEnter| after starting the GUI successfully |TermResponse| after the terminal response to |t_RV| is received |VimLeav...
65126606
How to remove all pipenv virtualenvs when the directory was deleted?
10
2020-12-03 13:08:14
<p>I have a directory <code>A/</code> containing a Pipfile and a Pipfile.lock obtained by running <code>pipenv install</code>. So this directory has a corresponding virtualenv at <code>/home/username/.local/share/virtualenvs/A-...</code>.</p> <p>Then I delete this <code>A/</code> directory. <strong>Is there a way to ch...
6,111
9,962,824
2022-04-02 18:41:27
67,209,898
12
2021-04-22 08:50:40
2,455,457
2022-04-02 18:41:27
https://stackoverflow.com/q/65126606
https://stackoverflow.com/a/67209898
<p><code>pipenv</code> has no special option for it. But you can use these bash scripts (I made them using the venvs directory <code>~/.local/share/virtualenvs/</code> so you should change it if your venvs folder is different)</p> <h1>PRINT useless venvs:</h1> <pre><code>for f in $(find ~/.local/share/virtualenvs/*/.pr...
<p><code>pipenv</code> has no special option for it. But you can use these bash scripts (I made them using the venvs directory <code>~/.local/share/virtualenvs/</code> so you should change it if your venvs folder is different)</p> <h1>PRINT useless venvs:</h1> <pre><code>for f in $(find ~/.local/share/virtualenvs/*/.pr...
387, 14529, 128625
bash, pipenv, virtualenv
<h1>How to remove all pipenv virtualenvs when the directory was deleted?</h1> <p>I have a directory <code>A/</code> containing a Pipfile and a Pipfile.lock obtained by running <code>pipenv install</code>. So this directory has a corresponding virtualenv at <code>/home/username/.local/share/virtualenvs/A-...</code>.</p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,773
bash
# How to remove all pipenv virtualenvs when the directory was deleted? I have a directory `A/` containing a Pipfile and a Pipfile.lock obtained by running `pipenv install`. So this directory has a corresponding virtualenv at `/home/username/.local/share/virtualenvs/A-...`. Then I delete this `A/` directory. **Is ther...
`pipenv` has no special option for it. But you can use these bash scripts (I made them using the venvs directory `~/.local/share/virtualenvs/` so you should change it if your venvs folder is different) # PRINT useless venvs: ``` for f in $(find ~/.local/share/virtualenvs/*/.project -type f); do proj_path="$(cat $f)" ...
56374777
How do I set an environment variable in the shebang (#!) of a script that will be run by Bash?
10
2019-05-30 08:49:29
<p>Or, why doesn't this work, assuming you correctly set the file as executable? (On my system it just hangs, but can be killed with ^C.)</p> <pre><code>#!/usr/bin/env TEST=TEST python print('hello') </code></pre> <p>While this does:</p> <pre><code>#!/usr/bin/env python print('hello') </code></pre> <p>As does this:...
4,926
1,901,658
2020-05-10 10:02:00
61,709,728
12
2020-05-10 09:24:50
13,510,460
2020-05-10 10:02:00
https://stackoverflow.com/q/56374777
https://stackoverflow.com/a/61709728
<p>Since version 8.30 env has the option -S, which make things work also in linux:</p> <p>Use</p> <pre><code>#!/usr/bin/env -S TEST=TEST python </code></pre>
<p>Since version 8.30 env has the option -S, which make things work also in linux:</p> <p>Use</p> <pre><code>#!/usr/bin/env -S TEST=TEST python </code></pre>
34, 387
bash, unix
<h1>How do I set an environment variable in the shebang (#!) of a script that will be run by Bash?</h1> <p>Or, why doesn't this work, assuming you correctly set the file as executable? (On my system it just hangs, but can be killed with ^C.)</p> <pre><code>#!/usr/bin/env TEST=TEST python print('hello') </code></pre> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,774
bash
# How do I set an environment variable in the shebang (#!) of a script that will be run by Bash? Or, why doesn't this work, assuming you correctly set the file as executable? (On my system it just hangs, but can be killed with ^C.) ``` #!/usr/bin/env TEST=TEST python print('hello') ``` While this does: ``` #!/usr/b...
Since version 8.30 env has the option -S, which make things work also in linux: Use ``` #!/usr/bin/env -S TEST=TEST python ```
61376154
How to install Microsoft Windows Terminal in Windows 10 version 1909
10
2020-04-22 22:28:02
<p><strong>[Note]</strong> <em>this is a historic problem that is specific to Windows 10 version 1909, which does not satisfy the Windows Terminal requirement by then. It would no longer be a problem for most nowadays systems.</em></p> <p>Alright, this should be a fairly simple question, but failing every possibilities...
31,927
2,125,837
2021-09-23 00:50:51
61,623,625
12
2020-05-05 21:45:44
6,654,942
2020-11-16 17:50:02
https://stackoverflow.com/q/61376154
https://stackoverflow.com/a/61623625
<p>Installing it straight from the Microsoft Store didn't work for me either. In Windows 10 1909, I did (it's an msix). Note that the appx commands are <em>gone</em> in powershell 7.1.</p> <pre><code>Add-AppxPackage Microsoft.WindowsTerminal_0.11.1191.0_8wekyb3d8bbwe.msixbundle </code></pre> <p>and it installed ok.</...
<p>Installing it straight from the Microsoft Store didn't work for me either. In Windows 10 1909, I did (it's an msix). Note that the appx commands are <em>gone</em> in powershell 7.1.</p> <pre><code>Add-AppxPackage Microsoft.WindowsTerminal_0.11.1191.0_8wekyb3d8bbwe.msixbundle </code></pre> <p>and it installed ok.</...
64, 526, 80758, 138178
chocolatey, powershell, windows, windows-terminal
<h1>How to install Microsoft Windows Terminal in Windows 10 version 1909</h1> <p><strong>[Note]</strong> <em>this is a historic problem that is specific to Windows 10 version 1909, which does not satisfy the Windows Terminal requirement by then. It would no longer be a problem for most nowadays systems.</em></p> <p>Alr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,775
bash
# How to install Microsoft Windows Terminal in Windows 10 version 1909 **[Note]** *this is a historic problem that is specific to Windows 10 version 1909, which does not satisfy the Windows Terminal requirement by then. It would no longer be a problem for most nowadays systems.* Alright, this should be a fairly simpl...
Installing it straight from the Microsoft Store didn't work for me either. In Windows 10 1909, I did (it's an msix). Note that the appx commands are *gone* in powershell 7.1. ``` Add-AppxPackage Microsoft.WindowsTerminal_0.11.1191.0_8wekyb3d8bbwe.msixbundle ``` and it installed ok. ``` get-appxpackage microsoft.wind...
57517345
How to check jq result is null or not?
10
2019-08-15 23:29:41
<p>I'm using jq to parse some JSON. I want to check whether a property exists or not. If it exists I always want to get the first element in the array. Based on this I want to use <code>if then ... else</code>.</p> <p>My code looks like this:</p> <pre><code>JSON_INPUT='{"var1":[{"foo":"bar"}],"var2":[{"fooooo":"baaaa...
17,857
2,757,155
2020-07-11 16:31:59
57,517,465
12
2019-08-15 23:48:43
3,776,858
2020-07-11 16:31:59
https://stackoverflow.com/q/57517345
https://stackoverflow.com/a/57517465
<blockquote> <p>Where is the error?</p> </blockquote> <p>Replace</p> <pre><code>[ -z &quot;${VAR2}&quot; ] </code></pre> <p>with</p> <pre><code>[ &quot;${VAR2}&quot; = &quot;null&quot; ] </code></pre> <p>because <code>jq</code> returns string <code>null</code> if <code>var2</code> is not found in JSON file.</p> <hr /> ...
<blockquote> <p>Where is the error?</p> </blockquote> <p>Replace</p> <pre><code>[ -z &quot;${VAR2}&quot; ] </code></pre> <p>with</p> <pre><code>[ &quot;${VAR2}&quot; = &quot;null&quot; ] </code></pre> <p>because <code>jq</code> returns string <code>null</code> if <code>var2</code> is not found in JSON file.</p> <hr /> ...
387, 390, 694, 1508, 105170
bash, jq, json, null, shell
<h1>How to check jq result is null or not?</h1> <p>I'm using jq to parse some JSON. I want to check whether a property exists or not. If it exists I always want to get the first element in the array. Based on this I want to use <code>if then ... else</code>.</p> <p>My code looks like this:</p> <pre><code>JSON_INPUT='...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,776
bash
# How to check jq result is null or not? I'm using jq to parse some JSON. I want to check whether a property exists or not. If it exists I always want to get the first element in the array. Based on this I want to use `if then ... else`. My code looks like this: ``` JSON_INPUT='{"var1":[{"foo":"bar"}],"var2":[{"fooo...
> Where is the error? Replace ``` [ -z "${VAR2}" ] ``` with ``` [ "${VAR2}" = "null" ] ``` because `jq` returns string `null` if `var2` is not found in JSON file. --- Or use `--exit-status`: ``` if echo "$JSON_INPUT" | jq --exit-status '.var2' >/dev/null; then echo "exists" else echo "does not exist" fi ``...
57056770
Vulnerability assessment enablement on Azure SQL server through ARM template
10
2019-07-16 11:59:39
<p>I have created my Azure SQL server through ARM templates. To enable the vulnerability assessment I need to enable Advanced data security. I use the following code in my ARM template inside the resource bracket of the SQL server resource to enable this.</p> <pre><code> { &quot;name&quot;: &quot;vu...
9,724
6,351,302
2021-03-10 11:47:19
57,408,182
12
2019-08-08 08:19:51
11,900,669
2019-08-08 08:19:51
https://stackoverflow.com/q/57056770
https://stackoverflow.com/a/57408182
<p>The issue you are having is caused by deploying an ARM template with Vulnerability Assessment, but without enabling Advanced Data Security first.</p> <p>You will have to deploy Advanced Data Security in the ARM template and add a dependency in the Vulnerability Assessment block, so it will only be deployed after Ad...
<p>The issue you are having is caused by deploying an ARM template with Vulnerability Assessment, but without enabling Advanced Data Security first.</p> <p>You will have to deploy Advanced Data Security in the ARM template and add a dependency in the Vulnerability Assessment block, so it will only be deployed after Ad...
526, 14158, 118486, 118726
azure, azure-rm-template, azure-sql-server, powershell
<h1>Vulnerability assessment enablement on Azure SQL server through ARM template</h1> <p>I have created my Azure SQL server through ARM templates. To enable the vulnerability assessment I need to enable Advanced data security. I use the following code in my ARM template inside the resource bracket of the SQL server res...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,777
bash
# Vulnerability assessment enablement on Azure SQL server through ARM template I have created my Azure SQL server through ARM templates. To enable the vulnerability assessment I need to enable Advanced data security. I use the following code in my ARM template inside the resource bracket of the SQL server resource to ...
The issue you are having is caused by deploying an ARM template with Vulnerability Assessment, but without enabling Advanced Data Security first. You will have to deploy Advanced Data Security in the ARM template and add a dependency in the Vulnerability Assessment block, so it will only be deployed after Advanced Dat...
54964666
bash shell reworking variable replace dots by underscore
10
2019-03-03 01:12:10
<p>I can't see to get it working :</p> <pre><code>echo $VERSIONNUMBER </code></pre> <p>i get : v0.9.3-beta</p> <pre><code>VERSIONNUMBERNAME=${VERSIONNUMBER:1} echo $VERSIONNUMBERNAME </code></pre> <p>I get : 0.9.3-beta</p> <pre><code>VERSION=${VERSIONNUMBERNAME/./_} echo $VERSION </code></pre> <p>I get : 0_9.3-be...
9,312
4,770,754
2022-05-10 12:45:43
54,972,920
12
2019-03-03 19:40:52
2,584,475
2019-03-03 19:40:52
https://stackoverflow.com/q/54964666
https://stackoverflow.com/a/54972920
<p>You can combine pattern substitution with <code>tr</code>:</p> <pre><code>VERSION=$( echo ${VERSIONNUMBER:1} | tr '.' '_' ) </code></pre>
<p>You can combine pattern substitution with <code>tr</code>:</p> <pre><code>VERSION=$( echo ${VERSIONNUMBER:1} | tr '.' '_' ) </code></pre>
387, 390, 531
bash, scripting, shell
<h1>bash shell reworking variable replace dots by underscore</h1> <p>I can't see to get it working :</p> <pre><code>echo $VERSIONNUMBER </code></pre> <p>i get : v0.9.3-beta</p> <pre><code>VERSIONNUMBERNAME=${VERSIONNUMBER:1} echo $VERSIONNUMBERNAME </code></pre> <p>I get : 0.9.3-beta</p> <pre><code>VERSION=${VERSI...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,778
bash
# bash shell reworking variable replace dots by underscore I can't see to get it working : ``` echo $VERSIONNUMBER ``` i get : v0.9.3-beta ``` VERSIONNUMBERNAME=${VERSIONNUMBER:1} echo $VERSIONNUMBERNAME ``` I get : 0.9.3-beta ``` VERSION=${VERSIONNUMBERNAME/./_} echo $VERSION ``` I get : 0_9.3-beta I want to h...
You can combine pattern substitution with `tr`: ``` VERSION=$( echo ${VERSIONNUMBER:1} | tr '.' '_' ) ```
48522415
Are the cmdlets in a pipeline executing in parallel?
10
2018-01-30 13:17:51
<p>I spotted an interesting statement in "PowerShell Notes for professionals" whitepaper - <strong>"In a pipeline series each function runs parallel to the others, like parallel threads"</strong>:</p> <p><a href="https://i.sstatic.net/7S8Oo.png" rel="noreferrer"><img src="https://i.sstatic.net/7S8Oo.png" alt="enter im...
2,383
1,022,219
2019-09-24 21:07:17
48,523,475
12
2018-01-30 14:12:38
712,649
2019-09-24 21:07:17
https://stackoverflow.com/q/48522415
https://stackoverflow.com/a/48523475
<h1>It's kinda true, but not really at all.</h1> <p>What do I mean with that? First, let's get your documentation question out of the way. The following is from paragraph §3.13 of the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=36389" rel="nofollow noreferrer">PowerShell version 3.0 Language Spec...
<h1>It's kinda true, but not really at all.</h1> <p>What do I mean with that? First, let's get your documentation question out of the way. The following is from paragraph §3.13 of the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=36389" rel="nofollow noreferrer">PowerShell version 3.0 Language Spec...
353, 526, 2844
parallel-processing, pipeline, powershell
<h1>Are the cmdlets in a pipeline executing in parallel?</h1> <p>I spotted an interesting statement in "PowerShell Notes for professionals" whitepaper - <strong>"In a pipeline series each function runs parallel to the others, like parallel threads"</strong>:</p> <p><a href="https://i.sstatic.net/7S8Oo.png" rel="norefe...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,779
bash
# Are the cmdlets in a pipeline executing in parallel? I spotted an interesting statement in "PowerShell Notes for professionals" whitepaper - **"In a pipeline series each function runs parallel to the others, like parallel threads"**: [![enter image description here](https://i.sstatic.net/7S8Oo.png)](https://i.sstat...
# It's kinda true, but not really at all. What do I mean with that? First, let's get your documentation question out of the way. The following is from paragraph §3.13 of the [PowerShell version 3.0 Language Specification](https://www.microsoft.com/en-us/download/details.aspx?id=36389): > If a command writes a single ...
47443380
Does "argument list too long" restriction apply to shell builtins?
10
2017-11-22 20:28:07
<p>I have browsed through many <a href="https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands">posts</a> on Stack Overflow as well as a few related communities regarding the <code>argument list too long</code> topic and I don't seem to clearly figure if the length restriction a...
4,051
6,862,601
2018-03-24 05:26:09
47,443,446
12
2017-11-22 20:33:03
14,122
2017-11-22 20:38:11
https://stackoverflow.com/q/47443380
https://stackoverflow.com/a/47443446
<p>In bash, the OS-enforced limitation on command-line length which causes the error <code>argument list too long</code> is not applied to shell builtins.</p> <p>This error is triggered when the <code>execve()</code> syscall returns the error code <code>E2BIG</code>. There is no <code>execve()</code> call involved whe...
<p>In bash, the OS-enforced limitation on command-line length which causes the error <code>argument list too long</code> is not applied to shell builtins.</p> <p>This error is triggered when the <code>execve()</code> syscall returns the error code <code>E2BIG</code>. There is no <code>execve()</code> call involved whe...
34, 58, 387, 390, 31134
bash, command-line-arguments, linux, shell, unix
<h1>Does "argument list too long" restriction apply to shell builtins?</h1> <p>I have browsed through many <a href="https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands">posts</a> on Stack Overflow as well as a few related communities regarding the <code>argument list too long...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,780
bash
# Does "argument list too long" restriction apply to shell builtins? I have browsed through many [posts](https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands) on Stack Overflow as well as a few related communities regarding the `argument list too long` topic and I don't seem ...
In bash, the OS-enforced limitation on command-line length which causes the error `argument list too long` is not applied to shell builtins. This error is triggered when the `execve()` syscall returns the error code `E2BIG`. There is no `execve()` call involved when invoking a builtin, so the error cannot take place. ...
45489008
Vim Opening File E325 Attention Error
10
2017-08-03 15:47:20
<p>On Git bash windows, I was editing .bash_profile file and then I decided not to save and closed the bash console. Now when I try to open the .bash_profile using vim, I get E325: Attention error. What should I do to fix this?</p>
23,925
1,546,003
2023-11-24 04:08:13
45,489,595
12
2017-08-03 16:15:08
813,602
2017-08-03 16:15:08
https://stackoverflow.com/q/45489008
https://stackoverflow.com/a/45489595
<p>By closing the console without exiting Vim first, the Vim process got killed, and Vim didn't have a chance to properly shut down. Vim uses <em>swap files</em> to store the last unpersisted changes to a buffer to avoid data loss in case of a crash; you can read the whole story at <code>:help E325</code>.</p> <p>In y...
<p>By closing the console without exiting Vim first, the Vim process got killed, and Vim didn't have a chance to properly shut down. Vim uses <em>swap files</em> to store the last unpersisted changes to a buffer to avoid data loss in case of a crash; you can read the whole story at <code>:help E325</code>.</p> <p>In y...
370, 61874
git-bash, vim
<h1>Vim Opening File E325 Attention Error</h1> <p>On Git bash windows, I was editing .bash_profile file and then I decided not to save and closed the bash console. Now when I try to open the .bash_profile using vim, I get E325: Attention error. What should I do to fix this?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,781
bash
# Vim Opening File E325 Attention Error On Git bash windows, I was editing .bash_profile file and then I decided not to save and closed the bash console. Now when I try to open the .bash_profile using vim, I get E325: Attention error. What should I do to fix this?
By closing the console without exiting Vim first, the Vim process got killed, and Vim didn't have a chance to properly shut down. Vim uses *swap files* to store the last unpersisted changes to a buffer to avoid data loss in case of a crash; you can read the whole story at `:help E325`. In your case, as you've consciou...
43565409
bash script - unable to set variable with double quotes in value
10
2017-04-22 22:41:53
<p>Need help in fixing this bash script to set a variable with a value including double quotes. Somehow I am defining this incorrectly as my values <code>foo</code> and <code>bar</code> are not enclosed in double quotes as needed.</p> <p>My script thus far:</p> <pre><code>#!/usr/local/bin/bash set -e set -x host='12...
25,389
2,045,872
2021-11-12 18:16:59
43,565,503
12
2017-04-22 22:55:47
6,281,755
2017-04-22 23:00:45
https://stackoverflow.com/q/43565409
https://stackoverflow.com/a/43565503
<p>In bash (and other POSIX shells), the following 2 states are equivalent:</p> <pre><code>_account=foo _account="foo" </code></pre> <p>What you want to do is to preserve the quotations, therefore you can do the following:</p> <pre><code>_account='"foo"' </code></pre>
<p>In bash (and other POSIX shells), the following 2 states are equivalent:</p> <pre><code>_account=foo _account="foo" </code></pre> <p>What you want to do is to preserve the quotations, therefore you can do the following:</p> <pre><code>_account='"foo"' </code></pre>
34, 387, 390, 4804, 10804
bash, escaping, quoting, shell, unix
<h1>bash script - unable to set variable with double quotes in value</h1> <p>Need help in fixing this bash script to set a variable with a value including double quotes. Somehow I am defining this incorrectly as my values <code>foo</code> and <code>bar</code> are not enclosed in double quotes as needed.</p> <p>My scri...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,782
bash
# bash script - unable to set variable with double quotes in value Need help in fixing this bash script to set a variable with a value including double quotes. Somehow I am defining this incorrectly as my values `foo` and `bar` are not enclosed in double quotes as needed. My script thus far: ``` #!/usr/local/bin/bas...
In bash (and other POSIX shells), the following 2 states are equivalent: ``` _account=foo _account="foo" ``` What you want to do is to preserve the quotations, therefore you can do the following: ``` _account='"foo"' ```
40599282
How to run PowerShell with admin privileges from current folder?
10
2016-11-14 22:58:02
<p>How can I run PowerShell from Context menu (holding the shift key) in current folder with admin privileges? Is there a simpler way than type in any code to windows registry?</p>
13,698
5,468,913
2024-04-04 01:39:55
40,599,283
12
2016-11-14 22:58:02
5,468,913
2024-04-04 01:39:55
https://stackoverflow.com/q/40599282
https://stackoverflow.com/a/40599283
<p>The script below can be pasted into any file with reg extension and run. After that, you will be able to run powershell with admin privileges from current open folder. To do this, you have to hold shift and then right click on empty space in the folder.</p> <p>Code:</p> <pre><code>Windows Registry Editor Version 5.0...
<p>The script below can be pasted into any file with reg extension and run. After that, you will be able to run powershell with admin privileges from current open folder. To do this, you have to hold shift and then right click on empty space in the folder.</p> <p>Code:</p> <pre><code>Windows Registry Editor Version 5.0...
64, 526, 5623
administrator, powershell, windows
<h1>How to run PowerShell with admin privileges from current folder?</h1> <p>How can I run PowerShell from Context menu (holding the shift key) in current folder with admin privileges? Is there a simpler way than type in any code to windows registry?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,783
bash
# How to run PowerShell with admin privileges from current folder? How can I run PowerShell from Context menu (holding the shift key) in current folder with admin privileges? Is there a simpler way than type in any code to windows registry?
The script below can be pasted into any file with reg extension and run. After that, you will be able to run powershell with admin privileges from current open folder. To do this, you have to hold shift and then right click on empty space in the folder. Code: ``` Windows Registry Editor Version 5.00 [HKEY_CLASSES_RO...
40370854
How does the Get-ChildItem -Exclude Parameter work?
10
2016-11-02 00:52:18
<p>How does the Get-ChildItem -Exclude parameter work? What rules does it follow?</p> <p>The Get-Help for Get-ChildItem isn't detailed at all:</p> <blockquote> <p>Omits the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as "*.txt". Wildcards are...
7,413
216,440
2017-04-09 06:28:21
40,373,837
12
2016-11-02 06:40:10
5,233,410
2016-11-02 06:57:55
https://stackoverflow.com/q/40370854
https://stackoverflow.com/a/40373837
<p><code>Exclude</code> omits child objects based on the <a href="https://msdn.microsoft.com/en-us/library/system.io.filesysteminfo.name(v=vs.110).aspx" rel="noreferrer">Name</a>, </p> <blockquote> <p>For files, gets the name of the file. For directories, gets the name of the last directory in the hierarchy if a h...
<p><code>Exclude</code> omits child objects based on the <a href="https://msdn.microsoft.com/en-us/library/system.io.filesysteminfo.name(v=vs.110).aspx" rel="noreferrer">Name</a>, </p> <blockquote> <p>For files, gets the name of the file. For directories, gets the name of the last directory in the hierarchy if a h...
526
powershell
<h1>How does the Get-ChildItem -Exclude Parameter work?</h1> <p>How does the Get-ChildItem -Exclude parameter work? What rules does it follow?</p> <p>The Get-Help for Get-ChildItem isn't detailed at all:</p> <blockquote> <p>Omits the specified items. The value of this parameter qualifies the Path parameter. Ente...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,784
bash
# How does the Get-ChildItem -Exclude Parameter work? How does the Get-ChildItem -Exclude parameter work? What rules does it follow? The Get-Help for Get-ChildItem isn't detailed at all: > Omits the specified items. The value of this parameter qualifies the > Path parameter. Enter a path element or pattern, such as ...
`Exclude` omits child objects based on the [Name](https://msdn.microsoft.com/en-us/library/system.io.filesysteminfo.name(v=vs.110).aspx), > For files, gets the name of the file. For directories, gets the name > of the last directory in the hierarchy if a hierarchy exists. > Otherwise, the Name property gets the name o...
40032420
Using Get-ChildItem to retrieve folder,name,fullname
10
2016-10-13 23:04:38
<p>I'm currently using this script to pull the Name,Folder,Foldername from a given path:</p> <pre><code> Get-ChildItem "C:\user\desktop" | Select Name, ` @{ n = 'Folder'; e = { Convert-Path $_.PSParentPath } }, ` @{ n = 'Foldername'; e = { ($_.PSPath -split '[\\]')[-2] } } , @{ n = 'Fullname'; e = { Convert-P...
110,056
6,917,873
2023-09-15 12:19:31
40,033,010
12
2016-10-14 00:14:13
45,375
2023-09-15 12:19:31
https://stackoverflow.com/q/40032420
https://stackoverflow.com/a/40033010
<p>You mistakenly referenced <code>PSParentPath</code> when you meant <code>PSPath</code> to get the full name (full filesystem path):</p> <pre class="lang-bash prettyprint-override"><code>Get-ChildItem &quot;C:\user\desktop&quot; | Select Name, ` @{ n = 'Folder'; e = { Convert-Path $_.PSParentPath } }, ` @{ n = '...
<p>You mistakenly referenced <code>PSParentPath</code> when you meant <code>PSPath</code> to get the full name (full filesystem path):</p> <pre class="lang-bash prettyprint-override"><code>Get-ChildItem &quot;C:\user\desktop&quot; | Select Name, ` @{ n = 'Folder'; e = { Convert-Path $_.PSParentPath } }, ` @{ n = '...
526
powershell
<h1>Using Get-ChildItem to retrieve folder,name,fullname</h1> <p>I'm currently using this script to pull the Name,Folder,Foldername from a given path:</p> <pre><code> Get-ChildItem "C:\user\desktop" | Select Name, ` @{ n = 'Folder'; e = { Convert-Path $_.PSParentPath } }, ` @{ n = 'Foldername'; e = { ($_.PSPath...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,785
bash
# Using Get-ChildItem to retrieve folder,name,fullname I'm currently using this script to pull the Name,Folder,Foldername from a given path: ``` Get-ChildItem "C:\user\desktop" | Select Name, ` @{ n = 'Folder'; e = { Convert-Path $_.PSParentPath } }, ` @{ n = 'Foldername'; e = { ($_.PSPath -split '[\\]')[-2] ...
You mistakenly referenced `PSParentPath` when you meant `PSPath` to get the full name (full filesystem path): ``` Get-ChildItem "C:\user\desktop" | Select Name, ` @{ n = 'Folder'; e = { Convert-Path $_.PSParentPath } }, ` @{ n = 'Foldername'; e = { ($_.PSPath -split '[\\]')[-2] } } , @{ n = 'Fullname'; e = { Con...
39001517
Features obligatory for TERM=dumb terminal
10
2016-08-17 16:09:27
<p>I am looking to implement a remote client in <a href="/questions/tagged/golang" class="post-tag" title="show questions tagged &#39;golang&#39;" rel="tag">golang</a> which connects to Linux through <code>nc</code> and starts <code>bash</code>. So I need to tell <code>bash</code> what features I can parse from the <co...
16,917
239,247
2023-08-14 08:05:39
39,005,551
12
2016-08-17 20:18:07
4,518,274
2016-08-17 20:24:06
https://stackoverflow.com/q/39001517
https://stackoverflow.com/a/39005551
<p>Going to the source can help. The terminal database has comments. Here is a <a href="http://invisible-island.net/ncurses/terminfo.src.html#tic-dumb" rel="noreferrer">slice from that</a>:</p> <pre><code>#### Specials # # Special &quot;terminals&quot;. These are used to label tty lines when you don't # know what ki...
<p>Going to the source can help. The terminal database has comments. Here is a <a href="http://invisible-island.net/ncurses/terminfo.src.html#tic-dumb" rel="noreferrer">slice from that</a>:</p> <pre><code>#### Specials # # Special &quot;terminals&quot;. These are used to label tty lines when you don't # know what ki...
58, 390, 391, 15627, 31089
go, linux, shell, terminal, terminfo
<h1>Features obligatory for TERM=dumb terminal</h1> <p>I am looking to implement a remote client in <a href="/questions/tagged/golang" class="post-tag" title="show questions tagged &#39;golang&#39;" rel="tag">golang</a> which connects to Linux through <code>nc</code> and starts <code>bash</code>. So I need to tell <cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,786
bash
# Features obligatory for TERM=dumb terminal I am looking to implement a remote client in [golang](/questions/tagged/golang "show questions tagged 'golang'") which connects to Linux through `nc` and starts `bash`. So I need to tell `bash` what features I can parse from the `stdout` that it sends to me, and how I am go...
Going to the source can help. The terminal database has comments. Here is a [slice from that](http://invisible-island.net/ncurses/terminfo.src.html#tic-dumb): ``` #### Specials # # Special "terminals". These are used to label tty lines when you don't # know what kind of terminal is on it. The characteristics of an u...
34144681
Conditionally omit a command line option in bash
10
2015-12-07 22:39:42
<p>I have a long command which I want to modify in a certain case to either include an option or not.</p> <p>E.g. </p> <pre><code>java -jar compiler.jar --externs "$externs" --foo "another" --bar "more" </code></pre> <p>where I want the <code>--externs "$externs"</code> to be omitted completely if <code>$externs...
1,799
2,407,870
2019-04-19 02:40:51
34,144,799
12
2015-12-07 22:48:58
14,122
2015-12-07 23:06:11
https://stackoverflow.com/q/34144681
https://stackoverflow.com/a/34144799
<p>This is what the <code>${key:+WORDS}</code> expansion is for:</p> <pre><code>java ... ${externs:+--externs "$externs"} </code></pre> <hr> <p>It's also a common idiom to use an array for the purpose:</p> <pre><code>args=( ) if [[ $externs ]]; then args+=( --externs "$externs" ) fi java ... "${args[@]}" </code>...
<p>This is what the <code>${key:+WORDS}</code> expansion is for:</p> <pre><code>java ... ${externs:+--externs "$externs"} </code></pre> <hr> <p>It's also a common idiom to use an array for the purpose:</p> <pre><code>args=( ) if [[ $externs ]]; then args+=( --externs "$externs" ) fi java ... "${args[@]}" </code>...
387, 31134
bash, command-line-arguments
<h1>Conditionally omit a command line option in bash</h1> <p>I have a long command which I want to modify in a certain case to either include an option or not.</p> <p>E.g. </p> <pre><code>java -jar compiler.jar --externs "$externs" --foo "another" --bar "more" </code></pre> <p>where I want the <code>--externs "$...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,787
bash
# Conditionally omit a command line option in bash I have a long command which I want to modify in a certain case to either include an option or not. E.g. ``` java -jar compiler.jar --externs "$externs" --foo "another" --bar "more" ``` where I want the `--externs "$externs"` to be omitted completely if `$extern...
This is what the `${key:+WORDS}` expansion is for: ``` java ... ${externs:+--externs "$externs"} ``` --- It's also a common idiom to use an array for the purpose: ``` args=( ) if [[ $externs ]]; then args+=( --externs "$externs" ) fi java ... "${args[@]}" ```
32143894
In Powershell, how can i get a Base64encoded memorystream of a local zip file?
10
2015-08-21 15:15:10
<p>i've been trying to use the AWS Update-LMFunctionCode to deploy my file to an existing lambda function in AWS. </p> <p>Differing from the Publish-LMFunction where I can provide just a path to the zipFile (-FunctionZip), the Update-LMFunction wants a memorystream for its -Zipfile argument.</p> <p>is there an exampl...
8,136
13,100
2015-08-21 17:45:33
32,146,403
12
2015-08-21 17:45:33
3,587,167
2015-08-21 17:45:33
https://stackoverflow.com/q/32143894
https://stackoverflow.com/a/32146403
<p>Try using the <code>CopyTo</code> method to copy from one stream to another:</p> <pre><code>try { $zipFilePath = "index.zip" $zipFileItem = Get-Item -Path $zipFilePath $fileStream = $zipFileItem.OpenRead() $memoryStream = New-Object System.IO.MemoryStream $fileStream.CopyTo($memoryStream) U...
<p>Try using the <code>CopyTo</code> method to copy from one stream to another:</p> <pre><code>try { $zipFilePath = "index.zip" $zipFileItem = Get-Item -Path $zipFilePath $fileStream = $zipFileItem.OpenRead() $memoryStream = New-Object System.IO.MemoryStream $fileStream.CopyTo($memoryStream) U...
526, 33388, 100823, 108737
amazon-web-services, aws-lambda, aws-powershell, powershell
<h1>In Powershell, how can i get a Base64encoded memorystream of a local zip file?</h1> <p>i've been trying to use the AWS Update-LMFunctionCode to deploy my file to an existing lambda function in AWS. </p> <p>Differing from the Publish-LMFunction where I can provide just a path to the zipFile (-FunctionZip), the Upda...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,788
bash
# In Powershell, how can i get a Base64encoded memorystream of a local zip file? i've been trying to use the AWS Update-LMFunctionCode to deploy my file to an existing lambda function in AWS. Differing from the Publish-LMFunction where I can provide just a path to the zipFile (-FunctionZip), the Update-LMFunction wan...
Try using the `CopyTo` method to copy from one stream to another: ``` try { $zipFilePath = "index.zip" $zipFileItem = Get-Item -Path $zipFilePath $fileStream = $zipFileItem.OpenRead() $memoryStream = New-Object System.IO.MemoryStream $fileStream.CopyTo($memoryStream) Update-LMFunctionCode -Fun...
2097904
How to prevent from closing out-gridview when a script finishes
10
2010-01-19 23:05:36
<p>I have a script that presents results using <code>out-gridview</code>. Here is a simple example:</p> <pre><code>"hello world" | out-gridview </code></pre> <p>When I run the script using <em>Run with PowerShell</em>, it will open gridview and close it immediately after it is opened. (I think this is because gridvie...
14,350
121,968
2021-12-23 03:50:37
32,140,269
12
2015-08-21 12:23:28
5,251,896
2015-08-21 14:52:06
https://stackoverflow.com/q/2097904
https://stackoverflow.com/a/32140269
<p>How about:</p> <pre><code>"hello world" | out-gridview -wait </code></pre> <p>According to <a href="https://technet.microsoft.com/en-us/library/hh849920.aspx" rel="noreferrer">the documentation of <code>Out-GridView</code></a>, the option <code>-Wait</code> prevents Windows PowerShell from closing until the Out-Gr...
<p>How about:</p> <pre><code>"hello world" | out-gridview -wait </code></pre> <p>According to <a href="https://technet.microsoft.com/en-us/library/hh849920.aspx" rel="noreferrer">the documentation of <code>Out-GridView</code></a>, the option <code>-Wait</code> prevents Windows PowerShell from closing until the Out-Gr...
526, 1655
gridview, powershell
<h1>How to prevent from closing out-gridview when a script finishes</h1> <p>I have a script that presents results using <code>out-gridview</code>. Here is a simple example:</p> <pre><code>"hello world" | out-gridview </code></pre> <p>When I run the script using <em>Run with PowerShell</em>, it will open gridview and ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,789
bash
# How to prevent from closing out-gridview when a script finishes I have a script that presents results using `out-gridview`. Here is a simple example: ``` "hello world" | out-gridview ``` When I run the script using *Run with PowerShell*, it will open gridview and close it immediately after it is opened. (I think t...
How about: ``` "hello world" | out-gridview -wait ``` According to [the documentation of `Out-GridView`](https://technet.microsoft.com/en-us/library/hh849920.aspx), the option `-Wait` prevents Windows PowerShell from closing until the Out-GridView window is closed. It is available in Windows PowerShell 3.0.
31949541
Print Local Group Members in PowerShell 5.0
10
2015-08-11 18:39:46
<p>I use the following code to determine members of the local Administrators group:</p> <pre><code>$obj_group = [ADSI]"WinNT://localhost/Administrators,group" $members=@($obj_group.Invoke("Members"))|foreach{$_.GetType().InvokeMember("Name","GetProperty",$null,$_,$null)} Write-Output "Current local Administrators: $me...
6,213
21,962
2024-07-05 11:27:51
32,121,238
12
2015-08-20 14:40:09
2,001,273
2015-08-20 14:40:09
https://stackoverflow.com/q/31949541
https://stackoverflow.com/a/32121238
<p>Ran into this issue myself and figured out a workaround (tested in windows 10 and 8.1)</p> <pre><code>$obj_group = [ADSI]"WinNT://localhost/Administrators,group" $members= @($obj_group.psbase.Invoke("Members")) | foreach{([ADSI]$_).InvokeGet("Name")} Write-Output "Current local Administrators: $members" </code></pr...
<p>Ran into this issue myself and figured out a workaround (tested in windows 10 and 8.1)</p> <pre><code>$obj_group = [ADSI]"WinNT://localhost/Administrators,group" $members= @($obj_group.psbase.Invoke("Members")) | foreach{([ADSI]$_).InvokeGet("Name")} Write-Output "Current local Administrators: $members" </code></pr...
526, 6282, 10401, 107329, 108010
active-directory, adsi, powershell, powershell-5.0, windows-10
<h1>Print Local Group Members in PowerShell 5.0</h1> <p>I use the following code to determine members of the local Administrators group:</p> <pre><code>$obj_group = [ADSI]"WinNT://localhost/Administrators,group" $members=@($obj_group.Invoke("Members"))|foreach{$_.GetType().InvokeMember("Name","GetProperty",$null,$_,$n...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,790
bash
# Print Local Group Members in PowerShell 5.0 I use the following code to determine members of the local Administrators group: ``` $obj_group = [ADSI]"WinNT://localhost/Administrators,group" $members=@($obj_group.Invoke("Members"))|foreach{$_.GetType().InvokeMember("Name","GetProperty",$null,$_,$null)} Write-Output "...
Ran into this issue myself and figured out a workaround (tested in windows 10 and 8.1) ``` $obj_group = [ADSI]"WinNT://localhost/Administrators,group" $members= @($obj_group.psbase.Invoke("Members")) | foreach{([ADSI]$_).InvokeGet("Name")} Write-Output "Current local Administrators: $members" ```
13995715
Bash while loop wait until task has completed
10
2012-12-21 19:01:49
<p>I have a bash script that I created to process videos from within a folder and it's subfolders:</p> <pre><code>find . -type f -name '*.mkv' | while read file; do ffmpeg -i $file ... done </code></pre> <p>The problem: Instead of the while loop waiting ffmpeg to complete, it continues iterate through the loop. The...
7,250
246,795
2015-07-30 20:42:08
31,733,643
12
2015-07-30 20:42:08
246,795
2015-07-30 20:42:08
https://stackoverflow.com/q/13995715
https://stackoverflow.com/a/31733643
<p>I realize I posted this a while ago but I found the solution. Thanks for all of the responses. Providing the -nostdin param to ffmpeg will do the trick. It will process only the current file before moving onto the next file for processing.</p> <p>ffmpeg's -nostdin option avoids attempting to read user input from st...
<p>I realize I posted this a while ago but I found the solution. Thanks for all of the responses. Providing the -nostdin param to ffmpeg will do the trick. It will process only the current file before moving onto the next file for processing.</p> <p>ffmpeg's -nostdin option avoids attempting to read user input from st...
387, 3847, 17310
bash, ffmpeg, while-loop
<h1>Bash while loop wait until task has completed</h1> <p>I have a bash script that I created to process videos from within a folder and it's subfolders:</p> <pre><code>find . -type f -name '*.mkv' | while read file; do ffmpeg -i $file ... done </code></pre> <p>The problem: Instead of the while loop waiting ffmpeg ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,791
bash
# Bash while loop wait until task has completed I have a bash script that I created to process videos from within a folder and it's subfolders: ``` find . -type f -name '*.mkv' | while read file; do ffmpeg -i $file ... done ``` The problem: Instead of the while loop waiting ffmpeg to complete, it continues iterate...
I realize I posted this a while ago but I found the solution. Thanks for all of the responses. Providing the -nostdin param to ffmpeg will do the trick. It will process only the current file before moving onto the next file for processing. ffmpeg's -nostdin option avoids attempting to read user input from stdin otherw...
31293635
How to store output from printf with formatting in a variable?
10
2015-07-08 13:06:51
<p>I would like to store the output of <code>printf</code> with formatting in a variable, but it strips off the formatting for some reason.</p> <p>This is the correct output</p> <pre><code>$ printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %" File system Free Refquot...
12,383
3,293,148
2015-07-08 13:19:58
31,293,735
12
2015-07-08 13:10:56
130,641
2015-07-08 13:10:56
https://stackoverflow.com/q/31293635
https://stackoverflow.com/a/31293735
<p><code>echo</code> will print each of it's arguments in order, separated by one space. You are passing a bunch of different arguments to <code>echo</code>.</p> <p>The simple solution is to quote <code>$A</code>:</p> <pre><code>A=$(printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %") echo "$A" </co...
<p><code>echo</code> will print each of it's arguments in order, separated by one space. You are passing a bunch of different arguments to <code>echo</code>.</p> <p>The simple solution is to quote <code>$A</code>:</p> <pre><code>A=$(printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %") echo "$A" </co...
58, 387, 1156, 13824
bash, echo, linux, printf
<h1>How to store output from printf with formatting in a variable?</h1> <p>I would like to store the output of <code>printf</code> with formatting in a variable, but it strips off the formatting for some reason.</p> <p>This is the correct output</p> <pre><code>$ printf "%-40s %8s %9s %7s" "File system" "Free" "Refqu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,792
bash
# How to store output from printf with formatting in a variable? I would like to store the output of `printf` with formatting in a variable, but it strips off the formatting for some reason. This is the correct output ``` $ printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %" File system ...
`echo` will print each of it's arguments in order, separated by one space. You are passing a bunch of different arguments to `echo`. The simple solution is to quote `$A`: ``` A=$(printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %") echo "$A" ```
30792435
Implement the subcommand pattern in PowerShell
10
2015-06-11 22:21:31
<p>Is it possible to implement the subcommand pattern in PowerShell? Something like:</p> <pre><code>command [subcommand] [options] [files] </code></pre> <p>Examples: Git, svn, Homebrew</p> <p>What would be the general architecture? A single function that delegates the actual work to script blocks? Each subcommand...
6,897
134,367
2024-02-16 04:33:08
30,795,074
12
2015-06-12 03:58:26
323,582
2024-02-16 04:33:08
https://stackoverflow.com/q/30792435
https://stackoverflow.com/a/30795074
<p>I thought of this pattern and found two ways of doing this. I did not find real applications in my practice, so the research is rather academic. But the scripts below work fine.</p> <p>An existing tool which implements this pattern (in its own way) is <a href="https://github.com/lukesampson/scoop" rel="nofollow nore...
<p>I thought of this pattern and found two ways of doing this. I did not find real applications in my practice, so the research is rather academic. But the scripts below work fine.</p> <p>An existing tool which implements this pattern (in its own way) is <a href="https://github.com/lukesampson/scoop" rel="nofollow nore...
526, 73157
powershell, powershell-3.0
<h1>Implement the subcommand pattern in PowerShell</h1> <p>Is it possible to implement the subcommand pattern in PowerShell? Something like:</p> <pre><code>command [subcommand] [options] [files] </code></pre> <p>Examples: Git, svn, Homebrew</p> <p>What would be the general architecture? A single function that dele...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,793
bash
# Implement the subcommand pattern in PowerShell Is it possible to implement the subcommand pattern in PowerShell? Something like: ``` command [subcommand] [options] [files] ``` Examples: Git, svn, Homebrew What would be the general architecture? A single function that delegates the actual work to script blocks? Ea...
I thought of this pattern and found two ways of doing this. I did not find real applications in my practice, so the research is rather academic. But the scripts below work fine. An existing tool which implements this pattern (in its own way) is [scoop](https://github.com/lukesampson/scoop). --- The pattern *subcomma...
29628635
Why is `source /home/vagrant/.bashrc` not working in a Vagrant shell provisioning script?
10
2015-04-14 13:28:17
<p>I'm <a href="https://stackoverflow.com/questions/29569573/updating-bashrc-and-environment-variables-during-vagrant-provisioning">having problems</a> with a shell provisioning script used by Vagrant, as it's not executing <code>source /home/vagrant/.bashrc</code>. I've reduced the problem down to this...</p> <p>With...
2,658
250,962
2015-04-14 13:51:11
29,629,200
12
2015-04-14 13:51:11
144,913
2015-04-14 13:51:11
https://stackoverflow.com/q/29628635
https://stackoverflow.com/a/29629200
<p>You need to remove the “exit if not running interactively” bit (e.g. <code>[ -z "$PS1" ] &amp;&amp; return</code>) from the top of your <code>.bashrc</code>.</p>
<p>You need to remove the “exit if not running interactively” bit (e.g. <code>[ -z "$PS1" ] &amp;&amp; return</code>) from the top of your <code>.bashrc</code>.</p>
390, 66981
shell, vagrant
<h1>Why is `source /home/vagrant/.bashrc` not working in a Vagrant shell provisioning script?</h1> <p>I'm <a href="https://stackoverflow.com/questions/29569573/updating-bashrc-and-environment-variables-during-vagrant-provisioning">having problems</a> with a shell provisioning script used by Vagrant, as it's not executi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,794
bash
# Why is `source /home/vagrant/.bashrc` not working in a Vagrant shell provisioning script? I'm [having problems](https://stackoverflow.com/questions/29569573/updating-bashrc-and-environment-variables-during-vagrant-provisioning) with a shell provisioning script used by Vagrant, as it's not executing `source /home/vag...
You need to remove the “exit if not running interactively” bit (e.g. `[ -z "$PS1" ] && return`) from the top of your `.bashrc`.
29321171
How to send custom signal to bash daemon process?
10
2015-03-22 21:10:40
<p>I have simple bash daemon running (with root privileges ) in background which suppose to do <code>action1</code> or/and <code>action2</code> when notified.</p> <p>How do I notify it/send some kind of signal on which it will react?</p> <p>I've tried scenarios with checking file change every 1 sec or more often, but...
9,620
1,770,582
2015-03-28 18:47:18
29,321,172
12
2015-03-22 21:16:01
3,476,849
2015-03-22 21:16:01
https://stackoverflow.com/q/29321171
https://stackoverflow.com/a/29321172
<p>You can send signals to a process using the <code>kill</code> command. There is a range of standard signals as well as two user defined signals, which you can let your script handle whichever way you prefer. Here is how this could look in a script</p> <pre><code>#!/bin/bash handler(){ echo "Handler was called"...
<p>You can send signals to a process using the <code>kill</code> command. There is a range of standard signals as well as two user defined signals, which you can let your script handle whichever way you prefer. Here is how this could look in a script</p> <pre><code>#!/bin/bash handler(){ echo "Handler was called"...
387, 2481, 2510
bash, daemon, signals
<h1>How to send custom signal to bash daemon process?</h1> <p>I have simple bash daemon running (with root privileges ) in background which suppose to do <code>action1</code> or/and <code>action2</code> when notified.</p> <p>How do I notify it/send some kind of signal on which it will react?</p> <p>I've tried scenari...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,795
bash
# How to send custom signal to bash daemon process? I have simple bash daemon running (with root privileges ) in background which suppose to do `action1` or/and `action2` when notified. How do I notify it/send some kind of signal on which it will react? I've tried scenarios with checking file change every 1 sec or m...
You can send signals to a process using the `kill` command. There is a range of standard signals as well as two user defined signals, which you can let your script handle whichever way you prefer. Here is how this could look in a script ``` #!/bin/bash handler(){ echo "Handler was called" } trap handler USR1 wh...
26078533
How to pass SQL query to psql as a argument containing double quotes
10
2014-09-27 19:46:43
<p>I am trying to:</p> <pre><code>psql -c "COPY ( SELECT * FROM "Users" LIMIT 10 ) TO STDOUT WITH CSV HEADER" &gt; out.csv </code></pre> <p>However double quotes inside query (<code>"Users"</code>) are removed and psql returns error that <code>Relation users does not exist</code>. I tried to escape quotes like this <...
5,988
606,521
2014-09-27 21:10:53
26,078,903
12
2014-09-27 20:26:35
606,521
2014-09-27 21:10:53
https://stackoverflow.com/q/26078533
https://stackoverflow.com/a/26078903
<p>And here is the right answer (it works for me):</p> <pre><code>echo 'COPY ( SELECT * FROM "Users" LIMIT 10 ) TO STDOUT WITH CSV HEADER' | psql &gt; out.csv </code></pre> <p>And even better (it allows to use single and double quotes without any escaping):</p> <pre><code>psql &gt; out.csv &lt;&lt;EOT COPY (SELECT i...
<p>And here is the right answer (it works for me):</p> <pre><code>echo 'COPY ( SELECT * FROM "Users" LIMIT 10 ) TO STDOUT WITH CSV HEADER' | psql &gt; out.csv </code></pre> <p>And even better (it allows to use single and double quotes without any escaping):</p> <pre><code>psql &gt; out.csv &lt;&lt;EOT COPY (SELECT i...
256, 369, 387, 82549
bash, macos, postgresql, psql
<h1>How to pass SQL query to psql as a argument containing double quotes</h1> <p>I am trying to:</p> <pre><code>psql -c "COPY ( SELECT * FROM "Users" LIMIT 10 ) TO STDOUT WITH CSV HEADER" &gt; out.csv </code></pre> <p>However double quotes inside query (<code>"Users"</code>) are removed and psql returns error that <c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,796
bash
# How to pass SQL query to psql as a argument containing double quotes I am trying to: ``` psql -c "COPY ( SELECT * FROM "Users" LIMIT 10 ) TO STDOUT WITH CSV HEADER" > out.csv ``` However double quotes inside query (`"Users"`) are removed and psql returns error that `Relation users does not exist`. I tried to escap...
And here is the right answer (it works for me): ``` echo 'COPY ( SELECT * FROM "Users" LIMIT 10 ) TO STDOUT WITH CSV HEADER' | psql > out.csv ``` And even better (it allows to use single and double quotes without any escaping): ``` psql > out.csv <<EOT COPY (SELECT id, email, "displayName", "firstName", "lastName", ...
25656667
mongodb debugging - ReferenceError: console is not defined
10
2014-09-04 03:05:04
<p>I got <code>js</code> file to run within <code>mongodb</code> where I got <code>console.log</code> expression for debugging:</p> <pre><code>use test; db.city.find().snapshot().forEach(function(city){ var Pos = city.Pos; if (Pos) { longLat = Pos.split(" "); console.log("longLat"); // f...
6,612
1,024,794
2018-06-12 19:50:06
25,656,873
12
2014-09-04 03:34:37
2,313,887
2014-09-04 03:34:37
https://stackoverflow.com/q/25656667
https://stackoverflow.com/a/25656873
<p>Use the <code>print</code> or <code>printjson</code> methods instead. These are used to emit just like console.log() within the shell:</p> <pre class="lang-js prettyprint-override"><code> if (Pos) { longLat = Pos.split(" "); print("longLat"); // for debugging ---------------------------- ...
<p>Use the <code>print</code> or <code>printjson</code> methods instead. These are used to emit just like console.log() within the shell:</p> <pre class="lang-js prettyprint-override"><code> if (Pos) { longLat = Pos.split(" "); print("longLat"); // for debugging ---------------------------- ...
3, 30073, 79553
javascript, mongodb, mongodb-shell
<h1>mongodb debugging - ReferenceError: console is not defined</h1> <p>I got <code>js</code> file to run within <code>mongodb</code> where I got <code>console.log</code> expression for debugging:</p> <pre><code>use test; db.city.find().snapshot().forEach(function(city){ var Pos = city.Pos; if (Pos) { ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,797
bash
# mongodb debugging - ReferenceError: console is not defined I got `js` file to run within `mongodb` where I got `console.log` expression for debugging: ``` use test; db.city.find().snapshot().forEach(function(city){ var Pos = city.Pos; if (Pos) { longLat = Pos.split(" "); console.log("l...
Use the `print` or `printjson` methods instead. These are used to emit just like console.log() within the shell: ``` if (Pos) { longLat = Pos.split(" "); print("longLat"); // for debugging ---------------------------- printjson(longLat); ```
24524505
How to build-run vNext application from Windows Powershell?
10
2014-07-02 06:44:14
<p>I'm trying to build a console application in .NET vNext from Windows PowerShell. So far I have upgraded the package by </p> <blockquote> <p>kvm upgrade</p> </blockquote> <p>from which I got package version "KRE-svr50-x86.1.0.0-alpha3-10070" and also checked the "alias" to conform the version.</p> <p>Now, I wrot...
1,236
2,587,755
2015-02-10 05:41:12
24,558,383
12
2014-07-03 15:56:49
3,796,568
2014-07-03 15:56:49
https://stackoverflow.com/q/24524505
https://stackoverflow.com/a/24558383
<p>Your problem is related to nuget configuration.</p> <p>To see the way it works go to your project.json folder and do a "kpm restore". you will see:</p> <blockquote> <p>Unable to locate System.Console >= 4.0.0.0</p> </blockquote> <p>This happends because the kpm uses a different nugget repository namely: <a href...
<p>Your problem is related to nuget configuration.</p> <p>To see the way it works go to your project.json folder and do a "kpm restore". you will see:</p> <blockquote> <p>Unable to locate System.Console >= 4.0.0.0</p> </blockquote> <p>This happends because the kpm uses a different nugget repository namely: <a href...
9, 526, 117274
asp.net-core, c#, powershell
<h1>How to build-run vNext application from Windows Powershell?</h1> <p>I'm trying to build a console application in .NET vNext from Windows PowerShell. So far I have upgraded the package by </p> <blockquote> <p>kvm upgrade</p> </blockquote> <p>from which I got package version "KRE-svr50-x86.1.0.0-alpha3-10070" and...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,798
bash
# How to build-run vNext application from Windows Powershell? I'm trying to build a console application in .NET vNext from Windows PowerShell. So far I have upgraded the package by > kvm upgrade from which I got package version "KRE-svr50-x86.1.0.0-alpha3-10070" and also checked the "alias" to conform the version. ...
Your problem is related to nuget configuration. To see the way it works go to your project.json folder and do a "kpm restore". you will see: > Unable to locate System.Console >= 4.0.0.0 This happends because the kpm uses a different nugget repository namely: <https://www.myget.org/F/aspnetvnext/> That repository ha...
19962645
bash function grep --exclude-dir not working
10
2013-11-13 19:28:11
<p>I have the following function defined in my .bashrc, but for some reason the --exclude-dir option is not excluding the .git directory. Can anyone see what I've done wrong? I'm using Ubuntu 13.10 if that helps.</p> <pre><code>function fif # find in files { pattern=${1?" Usage: fif &lt;word_pattern&gt; [files pa...
11,975
448,749
2017-09-22 00:58:13
19,965,417
12
2013-11-13 22:08:49
368,630
2013-11-13 22:08:49
https://stackoverflow.com/q/19962645
https://stackoverflow.com/a/19965417
<p>Do a <code>man grep</code> on your system, and see what version you have. Your version of grep may not be able to use <code>--exclude-dirs</code>.</p> <p>You're really better off using <code>find</code> to find the files you want, then use <code>grep</code> to parse them:</p> <pre><code>$ find . -name '.git' -type...
<p>Do a <code>man grep</code> on your system, and see what version you have. Your version of grep may not be able to use <code>--exclude-dirs</code>.</p> <p>You're really better off using <code>find</code> to find the files you want, then use <code>grep</code> to parse them:</p> <pre><code>$ find . -name '.git' -type...
387, 1271, 10193
bash, find, grep
<h1>bash function grep --exclude-dir not working</h1> <p>I have the following function defined in my .bashrc, but for some reason the --exclude-dir option is not excluding the .git directory. Can anyone see what I've done wrong? I'm using Ubuntu 13.10 if that helps.</p> <pre><code>function fif # find in files { pa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,799
bash
# bash function grep --exclude-dir not working I have the following function defined in my .bashrc, but for some reason the --exclude-dir option is not excluding the .git directory. Can anyone see what I've done wrong? I'm using Ubuntu 13.10 if that helps. ``` function fif # find in files { pattern=${1?" Usage: fi...
Do a `man grep` on your system, and see what version you have. Your version of grep may not be able to use `--exclude-dirs`. You're really better off using `find` to find the files you want, then use `grep` to parse them: ``` $ find . -name '.git' -type d -prune \ -o -name "*.min.*" -prune \ -o -type f -exe...
19762365
sed help: matching and replacing a literal "\n" (not the newline)
10
2013-11-04 05:51:45
<p>i have a file which contains several instances of <strong>\n</strong>.</p> <p>i would like to replace them with actual newlines, but sed doesn't recognize the <strong>\n</strong>.</p> <p>i tried</p> <pre><code>sed -r -e 's/\n/\n/' sed -r -e 's/\\n/\n/' sed -r -e 's/[\n]/\n/' </code></pre> <p>and many other ways ...
9,003
2,951,533
2021-08-29 07:04:46
19,762,404
12
2013-11-04 05:55:04
2,477,215
2013-11-04 05:55:04
https://stackoverflow.com/q/19762365
https://stackoverflow.com/a/19762404
<p>Can you please try this</p> <pre><code>sed -i 's/\\n/\n/g' input_filename </code></pre>
<p>Can you please try this</p> <pre><code>sed -i 's/\\n/\n/g' input_filename </code></pre>
58, 387, 3705, 5282, 12282
bash, linux, newline, pattern-matching, sed
<h1>sed help: matching and replacing a literal "\n" (not the newline)</h1> <p>i have a file which contains several instances of <strong>\n</strong>.</p> <p>i would like to replace them with actual newlines, but sed doesn't recognize the <strong>\n</strong>.</p> <p>i tried</p> <pre><code>sed -r -e 's/\n/\n/' sed -r -...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,800
bash
# sed help: matching and replacing a literal "\n" (not the newline) i have a file which contains several instances of **\n**. i would like to replace them with actual newlines, but sed doesn't recognize the **\n**. i tried ``` sed -r -e 's/\n/\n/' sed -r -e 's/\\n/\n/' sed -r -e 's/[\n]/\n/' ``` and many other way...
Can you please try this ``` sed -i 's/\\n/\n/g' input_filename ```
19524723
Pipe an input to C++ cin from Bash
10
2013-10-22 17:40:30
<p>I'm trying to write a simple Bash script to compile my C++ code, in this case it's a very simple program that just reads input into a vector and then prints the content of the vector.</p> <p>C++ code:</p> <pre><code> #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;vector&gt; using na...
17,552
136,935
2013-10-22 18:05:56
19,524,936
12
2013-10-22 17:51:59
315,052
2013-10-22 17:51:59
https://stackoverflow.com/q/19524723
https://stackoverflow.com/a/19524936
<p>You have to first compile the program to create an executable. Then, you run the executable. Unlike a scripting language's interpreter, <code>g++</code> does not interpret the source file, but compiles the source to create binary images.</p> <pre><code>#! /bin/bash g++ main.cpp ./a.out &lt; "input.txt" &gt; "output...
<p>You have to first compile the program to create an executable. Then, you run the executable. Unlike a scripting language's interpreter, <code>g++</code> does not interpret the source file, but compiles the source to create binary images.</p> <pre><code>#! /bin/bash g++ main.cpp ./a.out &lt; "input.txt" &gt; "output...
10, 387, 5486, 5813, 9754
bash, c++, cin, input, pipe
<h1>Pipe an input to C++ cin from Bash</h1> <p>I'm trying to write a simple Bash script to compile my C++ code, in this case it's a very simple program that just reads input into a vector and then prints the content of the vector.</p> <p>C++ code:</p> <pre><code> #include &lt;string&gt; #include &lt;iostream&g...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,801
bash
# Pipe an input to C++ cin from Bash I'm trying to write a simple Bash script to compile my C++ code, in this case it's a very simple program that just reads input into a vector and then prints the content of the vector. C++ code: ``` #include <string> #include <iostream> #include <vector> using nam...
You have to first compile the program to create an executable. Then, you run the executable. Unlike a scripting language's interpreter, `g++` does not interpret the source file, but compiles the source to create binary images. ``` #! /bin/bash g++ main.cpp ./a.out < "input.txt" > "output.txt" ```
19182286
How to run SQL in shell script
10
2013-10-04 13:21:05
<p>How do you run a SQL command in a shell script while setting a variable? I had tried this method and it isn't executing the command, it is thinking the command is just a string.</p> <pre><code>#!/bin/ksh variable1=`sqlplus -s username/pw@oracle_instance &lt;&lt;EOF SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OF...
203,692
338,387
2020-08-04 16:05:32
19,182,287
12
2013-10-04 13:21:05
338,387
2013-10-04 13:21:05
https://stackoverflow.com/q/19182286
https://stackoverflow.com/a/19182287
<pre><code>#!/bin/ksh variable1=$( echo "set feed off set pages 0 select count(*) from table; exit " | sqlplus -s username/password@oracle_instance ) echo "found count = $variable1" </code></pre>
<pre><code>#!/bin/ksh variable1=$( echo "set feed off set pages 0 select count(*) from table; exit " | sqlplus -s username/password@oracle_instance ) echo "found count = $variable1" </code></pre>
22, 34, 390, 165558
oracle-database, shell, sql, unix
<h1>How to run SQL in shell script</h1> <p>How do you run a SQL command in a shell script while setting a variable? I had tried this method and it isn't executing the command, it is thinking the command is just a string.</p> <pre><code>#!/bin/ksh variable1=`sqlplus -s username/pw@oracle_instance &lt;&lt;EOF SET PAGES...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,802
bash
# How to run SQL in shell script How do you run a SQL command in a shell script while setting a variable? I had tried this method and it isn't executing the command, it is thinking the command is just a string. ``` #!/bin/ksh variable1=`sqlplus -s username/pw@oracle_instance <<EOF SET PAGESIZE 0 FEEDBACK OFF VERIFY O...
``` #!/bin/ksh variable1=$( echo "set feed off set pages 0 select count(*) from table; exit " | sqlplus -s username/password@oracle_instance ) echo "found count = $variable1" ```
16649467
Parsing/passing command line arguments to a bash script - what is the difference between "$@" and "$*"?
10
2013-05-20 12:23:19
<p>I am using a bash script to call and execute a <code>.jar</code> file from any location without having to constantly enter its explicit path.</p> <p>The <code>.jar</code> requires additional variable parameters to be specified at execution, and as these can be anything, they cannot be hard coded into the script.</p...
13,271
2,329,155
2024-10-01 17:20:12
16,649,550
12
2013-05-20 12:28:40
1,030,675
2024-10-01 17:20:12
https://stackoverflow.com/q/16649467
https://stackoverflow.com/a/16649550
<p><code>&quot;$@&quot;</code> corresponds to <code>&quot;$1&quot; &quot;$2&quot; &quot;$3&quot;</code> etc. <code>&quot;$*&quot;</code> corresponds to <code>&quot;$1 $2 $3&quot;</code> which you do not seem to need. (In fact, it's <code>&quot;$1${IFS:0:1}$2${IFS:0:1}$3&quot;</code>, but if you don't change <code>$IFS<...
<p><code>&quot;$@&quot;</code> corresponds to <code>&quot;$1&quot; &quot;$2&quot; &quot;$3&quot;</code> etc. <code>&quot;$*&quot;</code> corresponds to <code>&quot;$1 $2 $3&quot;</code> which you do not seem to need. (In fact, it's <code>&quot;$1${IFS:0:1}$2${IFS:0:1}$3&quot;</code>, but if you don't change <code>$IFS<...
387, 2313, 18362, 31134
argument-passing, arguments, bash, command-line-arguments
<h1>Parsing/passing command line arguments to a bash script - what is the difference between "$@" and "$*"?</h1> <p>I am using a bash script to call and execute a <code>.jar</code> file from any location without having to constantly enter its explicit path.</p> <p>The <code>.jar</code> requires additional variable par...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,803
bash
# Parsing/passing command line arguments to a bash script - what is the difference between "$@" and "$*"? I am using a bash script to call and execute a `.jar` file from any location without having to constantly enter its explicit path. The `.jar` requires additional variable parameters to be specified at execution, ...
`"$@"` corresponds to `"$1" "$2" "$3"` etc. `"$*"` corresponds to `"$1 $2 $3"` which you do not seem to need. (In fact, it's `"$1${IFS:0:1}$2${IFS:0:1}$3"`, but if you don't change `$IFS`, it exapnds to the same string). Without quotes, there is no difference, they both correspond to `$1 $2 $3` etc.
15500204
Makefile: Passing command line arguments to file inside Makefile
10
2013-03-19 12:58:15
<p>Inside my Makfile I have the following, </p> <pre><code>smktestrun: smktest @../projects/test.sh </code></pre> <p>And I call this using: </p> <pre><code>Make smktestrun </code></pre> <p>But sometimes I need to pass an parameter/argument along with this file (test.sh)</p> <p>So basically I would like: </p> ...
23,023
966,739
2013-03-19 17:22:46
15,500,301
12
2013-03-19 13:03:05
1,126,841
2013-03-19 13:03:05
https://stackoverflow.com/q/15500204
https://stackoverflow.com/a/15500301
<p>Something like</p> <pre><code>smktestrun: smktest @../projects/test.sh $(TESTARGS) </code></pre> <p>Then call the Makefile with</p> <pre><code>$ make smktestrun TESTARGS="-abc" </code></pre>
<p>Something like</p> <pre><code>smktestrun: smktest @../projects/test.sh $(TESTARGS) </code></pre> <p>Then call the Makefile with</p> <pre><code>$ make smktestrun TESTARGS="-abc" </code></pre>
390, 4301, 31134
command-line-arguments, makefile, shell
<h1>Makefile: Passing command line arguments to file inside Makefile</h1> <p>Inside my Makfile I have the following, </p> <pre><code>smktestrun: smktest @../projects/test.sh </code></pre> <p>And I call this using: </p> <pre><code>Make smktestrun </code></pre> <p>But sometimes I need to pass an parameter/argumen...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,804
bash
# Makefile: Passing command line arguments to file inside Makefile Inside my Makfile I have the following, ``` smktestrun: smktest @../projects/test.sh ``` And I call this using: ``` Make smktestrun ``` But sometimes I need to pass an parameter/argument along with this file (test.sh) So basically I would like...
Something like ``` smktestrun: smktest @../projects/test.sh $(TESTARGS) ``` Then call the Makefile with ``` $ make smktestrun TESTARGS="-abc" ```
15382728
Passing "native" object to background jobs
10
2013-03-13 10:29:37
<p>Here is what I'd like to achieve in one way or another. </p> <p>I have a custom assembly defining some objects. In my script, I create a custom object that I'd like to pass to a script block, keeping that object behavior.</p> <pre><code>Add-Type -AssemblyName MyCustomDLL $global:object = new-object MyCustomDLL.My...
5,403
311,712
2013-03-13 13:43:41
15,387,081
12
2013-03-13 13:43:41
323,582
2013-03-13 13:43:41
https://stackoverflow.com/q/15382728
https://stackoverflow.com/a/15387081
<p>Instead of background jobs you may use <code>PowerShell</code> with <code>BeginInvoke</code>, <code>EndInvoke</code>. Here is the simple but working example of passing a live object in a "job", changing it there, getting the results:</p> <pre><code># live object to be passed in a job and changed there $liveObject =...
<p>Instead of background jobs you may use <code>PowerShell</code> with <code>BeginInvoke</code>, <code>EndInvoke</code>. Here is the simple but working example of passing a live object in a "job", changing it there, getting the results:</p> <pre><code># live object to be passed in a job and changed there $liveObject =...
526, 2182, 77232
powershell, psobject, scope
<h1>Passing "native" object to background jobs</h1> <p>Here is what I'd like to achieve in one way or another. </p> <p>I have a custom assembly defining some objects. In my script, I create a custom object that I'd like to pass to a script block, keeping that object behavior.</p> <pre><code>Add-Type -AssemblyName MyC...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,805
bash
# Passing "native" object to background jobs Here is what I'd like to achieve in one way or another. I have a custom assembly defining some objects. In my script, I create a custom object that I'd like to pass to a script block, keeping that object behavior. ``` Add-Type -AssemblyName MyCustomDLL $global:object = n...
Instead of background jobs you may use `PowerShell` with `BeginInvoke`, `EndInvoke`. Here is the simple but working example of passing a live object in a "job", changing it there, getting the results: ``` # live object to be passed in a job and changed there $liveObject = @{ data = 42} # job script $script = { pa...
11987761
How to find date wise history of commands being fired
10
2012-08-16 13:03:35
<p>How can I make the history command display the date and time information in addition to the command line?</p>
22,071
290,535
2018-08-17 17:31:34
11,987,907
12
2012-08-16 13:10:49
556,072
2012-08-16 14:15:32
https://stackoverflow.com/q/11987761
https://stackoverflow.com/a/11987907
<p>The history of executed commands is stored by your shell. Try adding something like this to you <code>~/.bashrc</code></p> <pre><code>export HISTTIMEFORMAT="%m/%d - %H:%M:%S: " </code></pre> <p>It will change the <code>HISTTIMEFORMAT</code> variable and bash will store a timestamp in its history accordingly. Then ...
<p>The history of executed commands is stored by your shell. Try adding something like this to you <code>~/.bashrc</code></p> <pre><code>export HISTTIMEFORMAT="%m/%d - %H:%M:%S: " </code></pre> <p>It will change the <code>HISTTIMEFORMAT</code> variable and bash will store a timestamp in its history accordingly. Then ...
387, 1318
bash, history
<h1>How to find date wise history of commands being fired</h1> <p>How can I make the history command display the date and time information in addition to the command line?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,806
bash
# How to find date wise history of commands being fired How can I make the history command display the date and time information in addition to the command line?
The history of executed commands is stored by your shell. Try adding something like this to you `~/.bashrc` ``` export HISTTIMEFORMAT="%m/%d - %H:%M:%S: " ``` It will change the `HISTTIMEFORMAT` variable and bash will store a timestamp in its history accordingly. Then your history will look like this ``` 487 08/16 ...
11976861
Bash: What's the difference between "rm -d" and "rm -R"?
10
2012-08-15 20:34:58
<h1>Questions</h1> <ul> <li>What is the difference between the <code>rm -d</code> and <code>rm -R</code> commands in Bash?</li> <li>Which one should I use?</li> </ul> <h1>Details</h1> <p>According to the man page for the <code>rm</code> command:</p> <ul> <li><code>rm -d</code> attempts to remove directories as well...
13,952
560,642
2016-08-06 10:29:08
11,976,889
12
2012-08-15 20:37:48
1,126,841
2012-08-15 20:37:48
https://stackoverflow.com/q/11976861
https://stackoverflow.com/a/11976889
<p>Ordinarily, <code>rm</code> will not remove a directory, even if it is empty. <code>rm -d</code> just makes <code>rm</code> act like <code>rmdir</code>. It still refuses to remove the directory if it isn't empty, but will do so if it is empty.</p> <p><code>rm -R</code> is the full recursive delete, removing the dir...
<p>Ordinarily, <code>rm</code> will not remove a directory, even if it is empty. <code>rm -d</code> just makes <code>rm</code> act like <code>rmdir</code>. It still refuses to remove the directory if it isn't empty, but will do so if it is empty.</p> <p><code>rm -R</code> is the full recursive delete, removing the dir...
387, 391, 5610
bash, rm, terminal
<h1>Bash: What's the difference between "rm -d" and "rm -R"?</h1> <h1>Questions</h1> <ul> <li>What is the difference between the <code>rm -d</code> and <code>rm -R</code> commands in Bash?</li> <li>Which one should I use?</li> </ul> <h1>Details</h1> <p>According to the man page for the <code>rm</code> command:</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,807
bash
# Bash: What's the difference between "rm -d" and "rm -R"? # Questions - What is the difference between the `rm -d` and `rm -R` commands in Bash? - Which one should I use? # Details According to the man page for the `rm` command: - `rm -d` attempts to remove directories as well as other types of files. - `rm -R`...
Ordinarily, `rm` will not remove a directory, even if it is empty. `rm -d` just makes `rm` act like `rmdir`. It still refuses to remove the directory if it isn't empty, but will do so if it is empty. `rm -R` is the full recursive delete, removing the directory and all its contents. I've never used `-d`, as I didn't k...
11375426
How to remove duplicates from a file and write to the same file?
10
2012-07-07 13:31:10
<p>I know my title is not much self-explanatory but let me try to explain it here.</p> <p>I have a file name <code>test.txt</code> which has some duplicate lines. Now, what I want to do is remove those duplicate lines and at the same time <code>update test.txt</code> with the new content.</p> <p><strong>test.txt</str...
6,820
933,999
2015-04-20 12:22:38
11,375,474
12
2012-07-07 13:37:33
967,492
2012-07-07 13:37:33
https://stackoverflow.com/q/11375426
https://stackoverflow.com/a/11375474
<p>This might work for you:</p> <pre><code>sort -u -o test.txt test.txt </code></pre>
<p>This might work for you:</p> <pre><code>sort -u -o test.txt test.txt </code></pre>
134, 387, 5310, 12147, 12189
bash, duplicates, file, in-place, sorting
<h1>How to remove duplicates from a file and write to the same file?</h1> <p>I know my title is not much self-explanatory but let me try to explain it here.</p> <p>I have a file name <code>test.txt</code> which has some duplicate lines. Now, what I want to do is remove those duplicate lines and at the same time <code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,808
bash
# How to remove duplicates from a file and write to the same file? I know my title is not much self-explanatory but let me try to explain it here. I have a file name `test.txt` which has some duplicate lines. Now, what I want to do is remove those duplicate lines and at the same time `update test.txt` with the new co...
This might work for you: ``` sort -u -o test.txt test.txt ```
10536089
BASH: When reading user input, Enter brings new line
10
2012-05-10 14:23:16
<p>I need following sample bash script to behave as follows:</p> <pre class="lang-sh prettyprint-override"><code>echo -e "Enter name: \c" read U_IP_NAME echo -e "You said your name is : $U_IP_NAME" </code></pre> <p>This will output to:</p> <pre><code>Enter name: Alok You said your name is : Alok </code></pre> <p>Bu...
9,845
1,387,333
2012-05-10 17:22:15
10,536,829
12
2012-05-10 15:02:12
45,249
2012-05-10 15:02:12
https://stackoverflow.com/q/10536089
https://stackoverflow.com/a/10536829
<p>You want to move the cursor up one line. This is achieved with <code>tput cuu1</code>:</p> <pre><code>echo -e "Enter name: \c" read U_IP_NAME tput cuu1 echo -e "Your said your name is : $U_IP_NAME" </code></pre> <p>More info with <code>man tput</code> and <code>man terminfo</code>.</p>
<p>You want to move the cursor up one line. This is achieved with <code>tput cuu1</code>:</p> <pre><code>echo -e "Enter name: \c" read U_IP_NAME tput cuu1 echo -e "Your said your name is : $U_IP_NAME" </code></pre> <p>More info with <code>man tput</code> and <code>man terminfo</code>.</p>
387
bash
<h1>BASH: When reading user input, Enter brings new line</h1> <p>I need following sample bash script to behave as follows:</p> <pre class="lang-sh prettyprint-override"><code>echo -e "Enter name: \c" read U_IP_NAME echo -e "You said your name is : $U_IP_NAME" </code></pre> <p>This will output to:</p> <pre><code>Ente...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,809
bash
# BASH: When reading user input, Enter brings new line I need following sample bash script to behave as follows: ``` echo -e "Enter name: \c" read U_IP_NAME echo -e "You said your name is : $U_IP_NAME" ``` This will output to: ``` Enter name: Alok You said your name is : Alok ``` But it I want it to be: ``` You s...
You want to move the cursor up one line. This is achieved with `tput cuu1`: ``` echo -e "Enter name: \c" read U_IP_NAME tput cuu1 echo -e "Your said your name is : $U_IP_NAME" ``` More info with `man tput` and `man terminfo`.
10497425
Is it possible to use $array=() in bash?
10
2012-05-08 11:08:39
<p>Two things, first this is my first question in this forum and I do apologise if the formating is all over the place. Second I have not written that many bash scripts, and it tend to be quite a long time between the scripts I produce. </p> <p>That said, here is my question. </p> <p>Is it possible to do something li...
24,087
1,362,043
2019-05-18 18:34:44
10,497,539
12
2012-05-08 11:16:10
1,172,428
2012-05-08 11:16:10
https://stackoverflow.com/q/10497425
https://stackoverflow.com/a/10497539
<p>Probably the simplest thing to do is just <code>unset</code> them. An unset variable will act identically to an empty array in most contexts, and <code>unset $array</code> ought to work fine.</p>
<p>Probably the simplest thing to do is just <code>unset</code> them. An unset variable will act identically to an empty array in most contexts, and <code>unset $array</code> ought to work fine.</p>
114, 387
arrays, bash
<h1>Is it possible to use $array=() in bash?</h1> <p>Two things, first this is my first question in this forum and I do apologise if the formating is all over the place. Second I have not written that many bash scripts, and it tend to be quite a long time between the scripts I produce. </p> <p>That said, here is my qu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,810
bash
# Is it possible to use $array=() in bash? Two things, first this is my first question in this forum and I do apologise if the formating is all over the place. Second I have not written that many bash scripts, and it tend to be quite a long time between the scripts I produce. That said, here is my question. Is it po...
Probably the simplest thing to do is just `unset` them. An unset variable will act identically to an empty array in most contexts, and `unset $array` ought to work fine.
9394629
How to check if file is being used by another process - Powershell
10
2012-02-22 12:21:48
<p>I am trying to find a solution which will check whether a file is being used by another process. I don't want to read the contents of the file, as on a 7GB document, this could take a while. Currently I am using the function mentioned below, which is not ideal as the script takes about 5 - 10 minutes to retrieve a ...
45,217
983,965
2022-04-20 05:16:56
9,411,199
12
2012-02-23 10:29:58
983,965
2012-02-23 10:29:58
https://stackoverflow.com/q/9394629
https://stackoverflow.com/a/9411199
<p>Created a function which solves the above problem:</p> <pre><code> function checkFileStatus($filePath) { write-host (getDateTime) "[ACTION][FILECHECK] Checking if" $filePath "is locked" $fileInfo = New-Object System.IO.FileInfo $filePath try { $fileStream = $fileInf...
<p>Created a function which solves the above problem:</p> <pre><code> function checkFileStatus($filePath) { write-host (getDateTime) "[ACTION][FILECHECK] Checking if" $filePath "is locked" $fileInfo = New-Object System.IO.FileInfo $filePath try { $fileStream = $fileInf...
1, 526, 5310
.net, file, powershell
<h1>How to check if file is being used by another process - Powershell</h1> <p>I am trying to find a solution which will check whether a file is being used by another process. I don't want to read the contents of the file, as on a 7GB document, this could take a while. Currently I am using the function mentioned below,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,811
bash
# How to check if file is being used by another process - Powershell I am trying to find a solution which will check whether a file is being used by another process. I don't want to read the contents of the file, as on a 7GB document, this could take a while. Currently I am using the function mentioned below, which is...
Created a function which solves the above problem: ``` function checkFileStatus($filePath) { write-host (getDateTime) "[ACTION][FILECHECK] Checking if" $filePath "is locked" $fileInfo = New-Object System.IO.FileInfo $filePath try { $fileStream = $fileInfo.Open( [Syste...
8917480
Bash completion - how to get rid of unneeded tab presses?
10
2012-01-18 21:12:30
<p>I use </p> <pre><code>cur="${COMP_WORDS[COMP_CWORD]}" opts=`sqlite3 test.db "${QUERY[COMP_CWORD]}"` SAVEIFS="$IFS" IFS=$'\n' COMPREPLY=( $(compgen -S"'" -P"'" -W "${opts}" $cur) ) IFS="$SAVEIFS" </code></pre> <p>to get possible variants from the database and complete them with <kbd>TAB</kbd>. As long as thes...
1,918
976,641
2012-01-18 22:01:26
8,918,119
12
2012-01-18 22:01:26
26,428
2012-01-18 22:01:26
https://stackoverflow.com/q/8917480
https://stackoverflow.com/a/8918119
<p>You can try:</p> <pre><code>bind 'set show-all-if-ambiguous on' </code></pre> <p>From <code>man bash</code>:</p> <pre><code> show-all-if-ambiguous (Off) This alters the default behavior of the completion functions. If set to on, words which have more than one possible completion cause the ...
<p>You can try:</p> <pre><code>bind 'set show-all-if-ambiguous on' </code></pre> <p>From <code>man bash</code>:</p> <pre><code> show-all-if-ambiguous (Off) This alters the default behavior of the completion functions. If set to on, words which have more than one possible completion cause the ...
387, 390, 59778
bash, bash-completion, shell
<h1>Bash completion - how to get rid of unneeded tab presses?</h1> <p>I use </p> <pre><code>cur="${COMP_WORDS[COMP_CWORD]}" opts=`sqlite3 test.db "${QUERY[COMP_CWORD]}"` SAVEIFS="$IFS" IFS=$'\n' COMPREPLY=( $(compgen -S"'" -P"'" -W "${opts}" $cur) ) IFS="$SAVEIFS" </code></pre> <p>to get possible variants from ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,812
bash
# Bash completion - how to get rid of unneeded tab presses? I use ``` cur="${COMP_WORDS[COMP_CWORD]}" opts=`sqlite3 test.db "${QUERY[COMP_CWORD]}"` SAVEIFS="$IFS" IFS=$'\n' COMPREPLY=( $(compgen -S"'" -P"'" -W "${opts}" $cur) ) IFS="$SAVEIFS" ``` to get possible variants from the database and complete them wit...
You can try: ``` bind 'set show-all-if-ambiguous on' ``` From `man bash`: ``` show-all-if-ambiguous (Off) This alters the default behavior of the completion functions. If set to on, words which have more than one possible completion cause the matches to be listed immediately inste...
8736856
Counting characters, words, length of the words and total length in a sentence
10
2012-01-05 02:21:08
<p>I have to write a script that takes a sentence and prints the word count, character count (excluding the spaces), length of each word and the length. I know that there exist <code>wc -m</code> to counter number of characters in the word, but how to make use of it in script?</p> <pre><code>#!/bin/bash mystring="one...
77,971
1,098,207
2018-12-10 13:17:22
8,736,953
12
2012-01-05 02:40:45
493,161
2012-01-05 02:50:27
https://stackoverflow.com/q/8736856
https://stackoverflow.com/a/8736953
<p>riffing on Jaypal Singh's answer:</p> <pre><code>jcomeau@intrepid:~$ mystring="one two three four five" jcomeau@intrepid:~$ echo "string length: ${#mystring}" string length: 23 jcomeau@intrepid:~$ echo -n "lengths of words: "; i=0; for token in $mystring; do echo -n "${#token} "; i=$((i+1)); done; echo; echo "word ...
<p>riffing on Jaypal Singh's answer:</p> <pre><code>jcomeau@intrepid:~$ mystring="one two three four five" jcomeau@intrepid:~$ echo "string length: ${#mystring}" string length: 23 jcomeau@intrepid:~$ echo -n "lengths of words: "; i=0; for token in $mystring; do echo -n "${#token} "; i=$((i+1)); done; echo; echo "word ...
390, 39056
shell, wc
<h1>Counting characters, words, length of the words and total length in a sentence</h1> <p>I have to write a script that takes a sentence and prints the word count, character count (excluding the spaces), length of each word and the length. I know that there exist <code>wc -m</code> to counter number of characters in t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,813
bash
# Counting characters, words, length of the words and total length in a sentence I have to write a script that takes a sentence and prints the word count, character count (excluding the spaces), length of each word and the length. I know that there exist `wc -m` to counter number of characters in the word, but how to ...
riffing on Jaypal Singh's answer: ``` jcomeau@intrepid:~$ mystring="one two three four five" jcomeau@intrepid:~$ echo "string length: ${#mystring}" string length: 23 jcomeau@intrepid:~$ echo -n "lengths of words: "; i=0; for token in $mystring; do echo -n "${#token} "; i=$((i+1)); done; echo; echo "word count: $i" len...
7988306
How to use an enum type in powershell when configuring IIS using the powershell snapin
10
2011-11-02 22:52:33
<p>I am using the IIS Powershell snapin to configure a new web application from scratch. I am new to PS. The following script will not workl as PS is not recognising the ManagedPipelineMode enum. If I change the value to 0 it will work. How can I get PS to understand th enum. I tried the Add-Type cmdlet and also load t...
5,593
11,711
2018-02-27 11:33:04
7,988,493
12
2011-11-02 23:16:20
526,535
2011-11-02 23:46:03
https://stackoverflow.com/q/7988306
https://stackoverflow.com/a/7988493
<p>It is expecting an integer, even though the underlying property is of type <code>ManagaedPipelineMode</code>. You can do below however:</p> <pre><code>$AppPool | Set-ItemProperty -Name "managedPipelineMode" -Value ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::Classic) </code></pre> <p>PS: </p> <p>Ins...
<p>It is expecting an integer, even though the underlying property is of type <code>ManagaedPipelineMode</code>. You can do below however:</p> <pre><code>$AppPool | Set-ItemProperty -Name "managedPipelineMode" -Value ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::Classic) </code></pre> <p>PS: </p> <p>Ins...
526, 1301
iis-7, powershell
<h1>How to use an enum type in powershell when configuring IIS using the powershell snapin</h1> <p>I am using the IIS Powershell snapin to configure a new web application from scratch. I am new to PS. The following script will not workl as PS is not recognising the ManagedPipelineMode enum. If I change the value to 0 i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,814
bash
# How to use an enum type in powershell when configuring IIS using the powershell snapin I am using the IIS Powershell snapin to configure a new web application from scratch. I am new to PS. The following script will not workl as PS is not recognising the ManagedPipelineMode enum. If I change the value to 0 it will wo...
It is expecting an integer, even though the underlying property is of type `ManagaedPipelineMode`. You can do below however: ``` $AppPool | Set-ItemProperty -Name "managedPipelineMode" -Value ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::Classic) ``` PS: Instead of ``` $AppPool = Get-ChildItem iis:\app...
6762531
How to build and run a shell command based on the contents of several lines in Vim?
10
2011-07-20 13:12:35
<p>A frequently used feature of Vim for me is filtering a file (or a selection of text) through an external command and replace the selection with the result, e.g.:</p> <pre><code>:'&lt;,&gt;'!sort </code></pre> <p>so</p> <pre><code>c b a </code></pre> <p>will be sorted and will result in</p> <pre><code>a b c </code></...
6,062
139,990
2021-01-26 05:59:36
6,763,730
12
2011-07-20 14:43:35
438,329
2011-07-20 16:23:26
https://stackoverflow.com/q/6762531
https://stackoverflow.com/a/6763730
<p>I suggest you use <code>xargs -L1</code></p> <p>Example:</p> <pre><code>:%!xargs -L1 wc -l </code></pre> <p>Basically <code>xargs [cmd]</code> will run the following <code>[cmd]</code> with multiple parameters from multiple lines. But with the <code>-L1</code> argument the <code>[cmd]</code> will be executed comm...
<p>I suggest you use <code>xargs -L1</code></p> <p>Example:</p> <pre><code>:%!xargs -L1 wc -l </code></pre> <p>Basically <code>xargs [cmd]</code> will run the following <code>[cmd]</code> with multiple parameters from multiple lines. But with the <code>-L1</code> argument the <code>[cmd]</code> will be executed comm...
370, 390, 531
scripting, shell, vim
<h1>How to build and run a shell command based on the contents of several lines in Vim?</h1> <p>A frequently used feature of Vim for me is filtering a file (or a selection of text) through an external command and replace the selection with the result, e.g.:</p> <pre><code>:'&lt;,&gt;'!sort </code></pre> <p>so</p> <pre>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,815
bash
# How to build and run a shell command based on the contents of several lines in Vim? A frequently used feature of Vim for me is filtering a file (or a selection of text) through an external command and replace the selection with the result, e.g.: ``` :'<,>'!sort ``` so ``` c b a ``` will be sorted and will result...
I suggest you use `xargs -L1` Example: ``` :%!xargs -L1 wc -l ``` Basically `xargs [cmd]` will run the following `[cmd]` with multiple parameters from multiple lines. But with the `-L1` argument the `[cmd]` will be executed command for each line. If you need to supply a certain order to the arguments for your comma...
6149238
Bash script for converting IP Addr string to Hexadecimal format
10
2011-05-27 07:37:19
<p><code> IP_ADDR=192.168.1.128</p> <p>printf '%02X' ${IP_ADDR//./ }; echo </code></p> <p>Can some one explain how this simple oneliner converts IP_ADDR to hexadecimal format? I am banging my head trying to find some documentation about this behavior.</p>
13,585
462,228
2018-01-17 17:01:24
6,149,254
12
2011-05-27 07:40:23
20,862
2011-05-27 07:40:23
https://stackoverflow.com/q/6149238
https://stackoverflow.com/a/6149254
<p><a href="http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html" rel="noreferrer">Shell Parameter Expansion</a></p> <pre><code>$ IP_ADDR=192.168.1.128 $ echo ${IP_ADDR//./ } 192 168 1 128 $ printf '%02X' 192 168 1 128 ; echo C0A80180 </code></pre>
<p><a href="http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html" rel="noreferrer">Shell Parameter Expansion</a></p> <pre><code>$ IP_ADDR=192.168.1.128 $ echo ${IP_ADDR//./ } 192 168 1 128 $ printf '%02X' 192 168 1 128 ; echo C0A80180 </code></pre>
387
bash
<h1>Bash script for converting IP Addr string to Hexadecimal format</h1> <p><code> IP_ADDR=192.168.1.128</p> <p>printf '%02X' ${IP_ADDR//./ }; echo </code></p> <p>Can some one explain how this simple oneliner converts IP_ADDR to hexadecimal format? I am banging my head trying to find some documentation about this beh...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,816
bash
# Bash script for converting IP Addr string to Hexadecimal format `IP_ADDR=192.168.1.128` printf '%02X' ${IP_ADDR//./ }; echo Can some one explain how this simple oneliner converts IP_ADDR to hexadecimal format? I am banging my head trying to find some documentation about this behavior.
[Shell Parameter Expansion](http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html) ``` $ IP_ADDR=192.168.1.128 $ echo ${IP_ADDR//./ } 192 168 1 128 $ printf '%02X' 192 168 1 128 ; echo C0A80180 ```
5123423
Error restoring database backup to new database with smo and powershell
10
2011-02-25 22:30:54
<p>Taking a database backup from another server I'm trying to restore to sqlexpress on the localhost. This restore will work via the gui but I'm having issues restoring it with powershell. I get the following error message:</p> <pre><code>Exception calling "SqlRestore" with "1" argument(s): "Restore failed for Serve...
11,362
104,783
2015-02-02 23:26:19
5,125,109
12
2011-02-26 04:39:16
368,847
2011-02-26 04:39:16
https://stackoverflow.com/q/5123423
https://stackoverflow.com/a/5125109
<p>I have a very similar script to yours, with a few noteworthy differences:</p> <ul> <li>Before calling <code>SqlRestore</code>, I make a call to <code>$server.KillAllProcesses($databaseName)</code>.</li> <li>I have <code>$smoRestore.NoRecovery = $false</code>, instead of <code>$true</code></li> <li>I have <code>$smo...
<p>I have a very similar script to yours, with a few noteworthy differences:</p> <ul> <li>Before calling <code>SqlRestore</code>, I make a call to <code>$server.KillAllProcesses($databaseName)</code>.</li> <li>I have <code>$smoRestore.NoRecovery = $false</code>, instead of <code>$true</code></li> <li>I have <code>$smo...
22, 72, 526, 3123, 5377
powershell, restore, smo, sql, sql-server
<h1>Error restoring database backup to new database with smo and powershell</h1> <p>Taking a database backup from another server I'm trying to restore to sqlexpress on the localhost. This restore will work via the gui but I'm having issues restoring it with powershell. I get the following error message:</p> <pre><co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,817
bash
# Error restoring database backup to new database with smo and powershell Taking a database backup from another server I'm trying to restore to sqlexpress on the localhost. This restore will work via the gui but I'm having issues restoring it with powershell. I get the following error message: ``` Exception calling "...
I have a very similar script to yours, with a few noteworthy differences: - Before calling `SqlRestore`, I make a call to `$server.KillAllProcesses($databaseName)`. - I have `$smoRestore.NoRecovery = $false`, instead of `$true` - I have `$smoRestore.FileNumber = 1`, which you don't have at all. I think this correspond...
5012958
What is the advantage of pathmunge over grep?
10
2011-02-16 05:50:52
<p>Currently working on Solaris 10 in the bash shell. While looking at a script, I noticed the pathmunge procedure set up to avoid duplication of folder paths in the PATH (it also seems to have the feature to add the necessary folder at the beginning or the end of the PATH).</p> <p>Apart from the ability to append/pre...
8,214
502,914
2019-06-11 14:17:55
5,013,051
12
2011-02-16 06:06:17
582,542
2019-06-11 14:17:55
https://stackoverflow.com/q/5012958
https://stackoverflow.com/a/5013051
<p>Until 2012, pathmunge used to use grep itself. (Well, egrep, to be precise.)</p> <p>In Red Hat, CentOS, etc. pathmunge is defined in <code>/etc/profile</code>:</p> <pre><code>pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PAT...
<p>Until 2012, pathmunge used to use grep itself. (Well, egrep, to be precise.)</p> <p>In Red Hat, CentOS, etc. pathmunge is defined in <code>/etc/profile</code>:</p> <pre><code>pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PAT...
387, 12147
bash, duplicates
<h1>What is the advantage of pathmunge over grep?</h1> <p>Currently working on Solaris 10 in the bash shell. While looking at a script, I noticed the pathmunge procedure set up to avoid duplication of folder paths in the PATH (it also seems to have the feature to add the necessary folder at the beginning or the end of ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,818
bash
# What is the advantage of pathmunge over grep? Currently working on Solaris 10 in the bash shell. While looking at a script, I noticed the pathmunge procedure set up to avoid duplication of folder paths in the PATH (it also seems to have the feature to add the necessary folder at the beginning or the end of the PATH)...
Until 2012, pathmunge used to use grep itself. (Well, egrep, to be precise.) In Red Hat, CentOS, etc. pathmunge is defined in `/etc/profile`: ``` pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else ...
4497817
Save stdout, stderr and stdout+stderr synchronously
10
2010-12-21 09:29:46
<p>For testing purposes, I would like to save stdout and stderr <em>separately</em> for inspection by subsequent code. For example, a test run with erroneous input should result in output to stderr, but nothing on stdout, while a test run with correct input should result in output to stdout, but nothing to stderr. The ...
6,243
96,588
2011-05-11 18:11:52
4,498,456
12
2010-12-21 10:48:37
26,428
2010-12-21 10:48:37
https://stackoverflow.com/q/4497817
https://stackoverflow.com/a/4498456
<p>Please see <a href="http://mywiki.wooledge.org/BashFAQ/106" rel="noreferrer">BashFAQ/106</a>. It's not easy to have your cake and eat it, too.</p> <p>From that page:</p> <blockquote> <p>But some people won't accept either the loss of separation between stdout and stderr, or the desynchronization of lines. They a...
<p>Please see <a href="http://mywiki.wooledge.org/BashFAQ/106" rel="noreferrer">BashFAQ/106</a>. It's not easy to have your cake and eat it, too.</p> <p>From that page:</p> <blockquote> <p>But some people won't accept either the loss of separation between stdout and stderr, or the desynchronization of lines. They a...
387, 31901
bash, http-redirect
<h1>Save stdout, stderr and stdout+stderr synchronously</h1> <p>For testing purposes, I would like to save stdout and stderr <em>separately</em> for inspection by subsequent code. For example, a test run with erroneous input should result in output to stderr, but nothing on stdout, while a test run with correct input s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,819
bash
# Save stdout, stderr and stdout+stderr synchronously For testing purposes, I would like to save stdout and stderr *separately* for inspection by subsequent code. For example, a test run with erroneous input should result in output to stderr, but nothing on stdout, while a test run with correct input should result in ...
Please see [BashFAQ/106](http://mywiki.wooledge.org/BashFAQ/106). It's not easy to have your cake and eat it, too. From that page: > But some people won't accept either the loss of separation between stdout and stderr, or the desynchronization of lines. They are purists, and so they ask for the most difficult form of...
2511496
How to use file contents as command-line arguments?
10
2010-03-24 21:20:38
<p>I'd like to use arguments from file as command-line arguments for some commands like gcc or ls.</p> <p>For example <code>gcc -o output -Wall -Werro</code></p> <p>as file consist of:</p> <blockquote> <p>-o output -Wall -Werro</p> </blockquote> <p>Used for gcc command-line call.</p>
10,001
301,210
2012-03-22 02:50:14
2,511,528
12
2010-03-24 21:26:12
116,908
2010-03-24 23:59:49
https://stackoverflow.com/q/2511496
https://stackoverflow.com/a/2511528
<p>You can use <code>xargs</code>:</p> <pre><code>cat optionsfile | xargs gcc </code></pre> <p>Edit: I've been downvoted because Laurent doesn't know how <code>xargs</code> works, so here's the proof:</p> <pre><code>$ echo "-o output -Wall -Werro" &gt; optionsfile $ cat optionsfile | xargs -t gcc gcc -o output -Wal...
<p>You can use <code>xargs</code>:</p> <pre><code>cat optionsfile | xargs gcc </code></pre> <p>Edit: I've been downvoted because Laurent doesn't know how <code>xargs</code> works, so here's the proof:</p> <pre><code>$ echo "-o output -Wall -Werro" &gt; optionsfile $ cat optionsfile | xargs -t gcc gcc -o output -Wal...
58, 387
bash, linux
<h1>How to use file contents as command-line arguments?</h1> <p>I'd like to use arguments from file as command-line arguments for some commands like gcc or ls.</p> <p>For example <code>gcc -o output -Wall -Werro</code></p> <p>as file consist of:</p> <blockquote> <p>-o output -Wall -Werro</p> </blockquote> <p>Used...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,820
bash
# How to use file contents as command-line arguments? I'd like to use arguments from file as command-line arguments for some commands like gcc or ls. For example `gcc -o output -Wall -Werro` as file consist of: > -o output -Wall -Werro Used for gcc command-line call.
You can use `xargs`: ``` cat optionsfile | xargs gcc ``` Edit: I've been downvoted because Laurent doesn't know how `xargs` works, so here's the proof: ``` $ echo "-o output -Wall -Werro" > optionsfile $ cat optionsfile | xargs -t gcc gcc -o output -Wall -Werro i686-apple-darwin10-gcc-4.2.1: no input files ``` The ...
683811
Does PowerShell support OOP?
10
2009-03-25 22:40:57
<p>What is about such concepts as Class, Interface, Mixin in PowerShell? Does it support OOP? If so, where can I read about this?</p>
10,328
62,192
2018-02-18 22:19:53
683,829
12
2009-03-25 22:49:31
5,314
2009-03-25 22:49:31
https://stackoverflow.com/q/683811
https://stackoverflow.com/a/683829
<p>You can define new types in PowerShell v2.0 using the <code>Add-Type</code> cmdlet:</p> <blockquote> <p><strong>DETAILED DESCRIPTION</strong></p> <p>The Add-Type cmdlet lets you define a .NET class in your Windows PowerShell session. You can then instantiate objects (by using the New-Object cmdlet) and use t...
<p>You can define new types in PowerShell v2.0 using the <code>Add-Type</code> cmdlet:</p> <blockquote> <p><strong>DETAILED DESCRIPTION</strong></p> <p>The Add-Type cmdlet lets you define a .NET class in your Windows PowerShell session. You can then instantiate objects (by using the New-Object cmdlet) and use t...
137, 526
oop, powershell
<h1>Does PowerShell support OOP?</h1> <p>What is about such concepts as Class, Interface, Mixin in PowerShell? Does it support OOP? If so, where can I read about this?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,821
bash
# Does PowerShell support OOP? What is about such concepts as Class, Interface, Mixin in PowerShell? Does it support OOP? If so, where can I read about this?
You can define new types in PowerShell v2.0 using the `Add-Type` cmdlet: > **DETAILED DESCRIPTION** > > The Add-Type cmdlet lets you define a .NET class in your Windows PowerShell session. You can then instantiate objects (by using the New-Object cmdlet) and use the objects, just as you would use any .NET ob > ject. I...
75235592
How to view entire array in MongoDB shell without truncation?
9
2023-01-25 14:42:02
<p>I am trying to find out the distinct values of a field using the <code>db.collections.distinct(&lt;field&gt;)</code>command.</p> <p>The above command retrieves all the distinct values of the given field inside an array. But as I have 12k documents all the values are not getting displayed in my console.</p> <p>This i...
1,894
18,017,663
2024-04-04 15:26:45
75,235,976
12
2023-01-25 15:11:26
3,027,266
2023-01-25 15:11:26
https://stackoverflow.com/q/75235592
https://stackoverflow.com/a/75235976
<p>The <code>mongosh</code> is a Node.js environment. There are several solutions, e.g. <code>JSON.stringify</code> the array or use <a href="https://nodejs.org/api/util.html#utilinspectobject-options" rel="noreferrer">util.inspect</a>.</p> <pre><code>JSON.stringify(db.collections.distinct(&lt;field&gt;)) util.inspect...
<p>The <code>mongosh</code> is a Node.js environment. There are several solutions, e.g. <code>JSON.stringify</code> the array or use <a href="https://nodejs.org/api/util.html#utilinspectobject-options" rel="noreferrer">util.inspect</a>.</p> <pre><code>JSON.stringify(db.collections.distinct(&lt;field&gt;)) util.inspect...
30073, 69521
mongodb, mongo-shell
<h1>How to view entire array in MongoDB shell without truncation?</h1> <p>I am trying to find out the distinct values of a field using the <code>db.collections.distinct(&lt;field&gt;)</code>command.</p> <p>The above command retrieves all the distinct values of the given field inside an array. But as I have 12k document...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,822
bash
# How to view entire array in MongoDB shell without truncation? I am trying to find out the distinct values of a field using the `db.collections.distinct(<field>)`command. The above command retrieves all the distinct values of the given field inside an array. But as I have 12k documents all the values are not getting...
The `mongosh` is a Node.js environment. There are several solutions, e.g. `JSON.stringify` the array or use [util.inspect](https://nodejs.org/api/util.html#utilinspectobject-options). ``` JSON.stringify(db.collections.distinct(<field>)) util.inspect(db.collections.distinct(<field>), { maxArrayLength: null }) ```
73734301
Toggle Dark/Light Mode in Windows 10 automatically by time of day (without modifying or changing theme!)
9
2022-09-15 16:05:12
<p>Nowadays most devices allow for an automatic toggle of Dark/Light mode, however Windows 10 doesn't seem to have such a feature. Is there a way to accomplish this? Using the Task Scheduler for example?</p> <p>There seem to be many examples on how to change the windows &quot;theme&quot; programmatically, but not the l...
8,152
1,605,873
2023-06-16 06:00:27
73,734,302
12
2022-09-15 16:05:12
1,605,873
2022-11-21 14:43:37
https://stackoverflow.com/q/73734301
https://stackoverflow.com/a/73734302
<p>Yes, there is!</p> <p>It can be a bit tricky to pull off seamesly, but it can be done with the following steps:</p> <p>Open Task Scheduler and create a new task with the following settings:</p> <p><em>General</em></p> <p><a href="https://i.sstatic.net/mrw8h.png" rel="noreferrer"><img src="https://i.sstatic.net/mrw8h...
<p>Yes, there is!</p> <p>It can be a bit tricky to pull off seamesly, but it can be done with the following steps:</p> <p>Open Task Scheduler and create a new task with the following settings:</p> <p><em>General</em></p> <p><a href="https://i.sstatic.net/mrw8h.png" rel="noreferrer"><img src="https://i.sstatic.net/mrw8h...
526, 7672, 9299, 107329, 146293
darkmode, powershell, scheduled-tasks, scheduler, windows-10
<h1>Toggle Dark/Light Mode in Windows 10 automatically by time of day (without modifying or changing theme!)</h1> <p>Nowadays most devices allow for an automatic toggle of Dark/Light mode, however Windows 10 doesn't seem to have such a feature. Is there a way to accomplish this? Using the Task Scheduler for example?</p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,823
bash
# Toggle Dark/Light Mode in Windows 10 automatically by time of day (without modifying or changing theme!) Nowadays most devices allow for an automatic toggle of Dark/Light mode, however Windows 10 doesn't seem to have such a feature. Is there a way to accomplish this? Using the Task Scheduler for example? There seem...
Yes, there is! It can be a bit tricky to pull off seamesly, but it can be done with the following steps: Open Task Scheduler and create a new task with the following settings: *General* [![General task settings](https://i.sstatic.net/mrw8h.png)](https://i.sstatic.net/mrw8h.png) - "Run whether user is logged in or ...
68958466
PowerShell: Import-Module or Add-Type for .NET assemblies?
9
2021-08-27 19:25:37
<p>I'm using PowerShell 5.1, Windows 10 x64.</p> <p>Which of these 2 cmdlets should I use to load .NET assemblies (in particular .NET Framework 4+ assemblies) into PowerShell? What's the core difference between them? I want to load assemblies for accessing types, creating objects, calling methods, etc.</p> <p>I haven't...
11,673
16,759,994
2021-08-27 20:53:01
68,959,247
12
2021-08-27 20:53:01
7,411,885
2021-08-27 20:53:01
https://stackoverflow.com/q/68958466
https://stackoverflow.com/a/68959247
<p>Powershell has three main ways to import classes, not counting .net methods like <code>reflection.assembly</code>. In general, all of them will do what you need just fine, but have extra features:</p> <h2>Import-Module</h2> <p>has by far the most flexibility, and can import basic Modules (usually .psd1 or .psm1 file...
<p>Powershell has three main ways to import classes, not counting .net methods like <code>reflection.assembly</code>. In general, all of them will do what you need just fine, but have extra features:</p> <h2>Import-Module</h2> <p>has by far the most flexibility, and can import basic Modules (usually .psd1 or .psm1 file...
1, 9, 526, 9650, 149764
.net, .net-4.0, c#, powershell, powershell-5.1
<h1>PowerShell: Import-Module or Add-Type for .NET assemblies?</h1> <p>I'm using PowerShell 5.1, Windows 10 x64.</p> <p>Which of these 2 cmdlets should I use to load .NET assemblies (in particular .NET Framework 4+ assemblies) into PowerShell? What's the core difference between them? I want to load assemblies for acces...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,825
bash
# PowerShell: Import-Module or Add-Type for .NET assemblies? I'm using PowerShell 5.1, Windows 10 x64. Which of these 2 cmdlets should I use to load .NET assemblies (in particular .NET Framework 4+ assemblies) into PowerShell? What's the core difference between them? I want to load assemblies for accessing types, cre...
Powershell has three main ways to import classes, not counting .net methods like `reflection.assembly`. In general, all of them will do what you need just fine, but have extra features: ## Import-Module has by far the most flexibility, and can import basic Modules (usually .psd1 or .psm1 files) and their required ass...
64034156
Troubleshooting ssh login failure for AWS EC2 using powershell
9
2020-09-23 18:26:24
<p><em><strong>Short problem description:</strong></em> I had created two new AWS EC2 server instances on Redhat Linux and Ubuntu operating system. I was trying to login to it through SSH via Putty but was getting errors(detailed errors further in question). This is just a short description.</p> <p><em><strong>Detailed...
1,706
5,866,580
2020-09-24 07:33:02
64,034,157
12
2020-09-23 18:26:24
5,866,580
2020-09-24 00:14:10
https://stackoverflow.com/q/64034156
https://stackoverflow.com/a/64034157
<p><em><strong>Initial troubleshooting:</strong></em></p> <ol> <li>My very initial thought was that it could be control M characters in .pem file OR in private key. But when checked key looked fine.</li> <li>Then I thought it could be inbound rule issue, that we are NOT allowed to do ssh to aws server but NO I was wron...
<p><em><strong>Initial troubleshooting:</strong></em></p> <ol> <li>My very initial thought was that it could be control M characters in .pem file OR in private key. But when checked key looked fine.</li> <li>Then I thought it could be inbound rule issue, that we are NOT allowed to do ssh to aws server but NO I was wron...
386, 390, 526, 12375, 33388
amazon-ec2, amazon-web-services, powershell, shell, ssh
<h1>Troubleshooting ssh login failure for AWS EC2 using powershell</h1> <p><em><strong>Short problem description:</strong></em> I had created two new AWS EC2 server instances on Redhat Linux and Ubuntu operating system. I was trying to login to it through SSH via Putty but was getting errors(detailed errors further in ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,826
bash
# Troubleshooting ssh login failure for AWS EC2 using powershell ***Short problem description:*** I had created two new AWS EC2 server instances on Redhat Linux and Ubuntu operating system. I was trying to login to it through SSH via Putty but was getting errors(detailed errors further in question). This is just a sho...
***Initial troubleshooting:*** 1. My very initial thought was that it could be control M characters in .pem file OR in private key. But when checked key looked fine. 2. Then I thought it could be inbound rule issue, that we are NOT allowed to do ssh to aws server but NO I was wrong when I checked configuration of serv...
57116144
dash '-' after #!/bin/sh -
9
2019-07-19 16:09:07
<p>I have been working on a few scripts on CentOS 7 and sometimes I see:</p> <pre><code>#!/bin/sh - </code></pre> <p>on the first line. Looking at the man page for <code>sh</code> I see the following under the <code>Special Parameters</code></p> <pre><code> - Expands to the current option flags as specified...
2,540
158,787
2019-07-19 19:10:06
57,116,674
12
2019-07-19 16:49:33
147,356
2019-07-19 16:56:11
https://stackoverflow.com/q/57116144
https://stackoverflow.com/a/57116674
<p>The documentation you are reading has nothing to do with the command line you're looking at: it's referring to special variables. In this case, if you run <code>echo $-</code> you will see "the current option flags as specified upon invocation...".</p> <p>If you take a look at the <code>OPTIONS</code> part of t...
<p>The documentation you are reading has nothing to do with the command line you're looking at: it's referring to special variables. In this case, if you run <code>echo $-</code> you will see "the current option flags as specified upon invocation...".</p> <p>If you take a look at the <code>OPTIONS</code> part of t...
390, 4956, 10327
centos, sh, shell
<h1>dash '-' after #!/bin/sh -</h1> <p>I have been working on a few scripts on CentOS 7 and sometimes I see:</p> <pre><code>#!/bin/sh - </code></pre> <p>on the first line. Looking at the man page for <code>sh</code> I see the following under the <code>Special Parameters</code></p> <pre><code> - Expands to th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,827
bash
# dash '-' after #!/bin/sh - I have been working on a few scripts on CentOS 7 and sometimes I see: ``` #!/bin/sh - ``` on the first line. Looking at the man page for `sh` I see the following under the `Special Parameters` ``` - Expands to the current option flags as specified upon invocation, b...
The documentation you are reading has nothing to do with the command line you're looking at: it's referring to special variables. In this case, if you run `echo $-` you will see "the current option flags as specified upon invocation...". If you take a look at the `OPTIONS` part of the `bash` man page, you will find: ...
54036380
How to get variables from config file in powershell
9
2019-01-04 09:42:26
<p>How can i get variables from a config file in XML ?</p> <p>I am actualy doing this using a .txt config file.</p> <p>There is my actual code : </p> <p>Config.txt</p> <pre><code>[Repertoire de SPO (generalement C:\SPO)] destinationn="C:\SPO" [Nom du sous repertoire de SPO (generalement : SPO1)] sous_destination="...
22,772
8,761,070
2020-03-27 03:10:42
54,036,821
12
2019-01-04 10:09:27
6,579,295
2019-01-04 10:09:27
https://stackoverflow.com/q/54036380
https://stackoverflow.com/a/54036821
<p>Xml is much easier to parse with PowerShell. See following example with comments:</p> <pre><code>#Translated XML config @' &lt;root&gt; &lt;destinationn&gt;C:\SPO&lt;/destinationn&gt; &lt;sous_destination&gt;SPO1&lt;/sous_destination&gt; &lt;version&gt;1812.4&lt;/version&gt; &lt;applicationPoolName&gt;SPO_A...
<p>Xml is much easier to parse with PowerShell. See following example with comments:</p> <pre><code>#Translated XML config @' &lt;root&gt; &lt;destinationn&gt;C:\SPO&lt;/destinationn&gt; &lt;sous_destination&gt;SPO1&lt;/sous_destination&gt; &lt;version&gt;1812.4&lt;/version&gt; &lt;applicationPoolName&gt;SPO_A...
360, 526, 3574
config, parameters, powershell
<h1>How to get variables from config file in powershell</h1> <p>How can i get variables from a config file in XML ?</p> <p>I am actualy doing this using a .txt config file.</p> <p>There is my actual code : </p> <p>Config.txt</p> <pre><code>[Repertoire de SPO (generalement C:\SPO)] destinationn="C:\SPO" [Nom du sou...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,828
bash
# How to get variables from config file in powershell How can i get variables from a config file in XML ? I am actualy doing this using a .txt config file. There is my actual code : Config.txt ``` [Repertoire de SPO (generalement C:\SPO)] destinationn="C:\SPO" [Nom du sous repertoire de SPO (generalement : SPO1)]...
Xml is much easier to parse with PowerShell. See following example with comments: ``` #Translated XML config @' <root> <destinationn>C:\SPO</destinationn> <sous_destination>SPO1</sous_destination> <version>1812.4</version> <applicationPoolName>SPO_ADV</applicationPoolName> <livraisonn>\\path\to\somewhere</li...
50067877
Delete a specific line from a 12GB file
9
2018-04-27 17:58:22
<p>I'm trying to delete a specific line from a 12GB text file.</p> <p>I do not have the <code>sed -i</code> option available on HP-UX, and other options like saving to a temporary file aren't working because I have only 20GB space available with 12 GB already used by the text file.</p> <p>Considering the space requir...
394
435,559
2018-04-28 21:12:07
50,068,760
12
2018-04-27 19:01:55
589,924
2018-04-28 21:12:07
https://stackoverflow.com/q/50067877
https://stackoverflow.com/a/50068760
<p>Tie::File is never the answer.</p> <ul> <li>It's <em>insanely</em> slow.</li> <li>It can use up more memory than just slurping the entire file into memory, even if you limit the size of its buffer.</li> </ul> <p>You are encountering both of those problems. You encounter every line of the file, so Tie::File will re...
<p>Tie::File is never the answer.</p> <ul> <li>It's <em>insanely</em> slow.</li> <li>It can use up more memory than just slurping the entire file into memory, even if you limit the size of its buffer.</li> </ul> <p>You are encountering both of those problems. You encounter every line of the file, so Tie::File will re...
34, 387, 580, 5310
bash, file, perl, unix
<h1>Delete a specific line from a 12GB file</h1> <p>I'm trying to delete a specific line from a 12GB text file.</p> <p>I do not have the <code>sed -i</code> option available on HP-UX, and other options like saving to a temporary file aren't working because I have only 20GB space available with 12 GB already used by th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,829
bash
# Delete a specific line from a 12GB file I'm trying to delete a specific line from a 12GB text file. I do not have the `sed -i` option available on HP-UX, and other options like saving to a temporary file aren't working because I have only 20GB space available with 12 GB already used by the text file. Considering t...
Tie::File is never the answer. - It's *insanely* slow. - It can use up more memory than just slurping the entire file into memory, even if you limit the size of its buffer. You are encountering both of those problems. You encounter every line of the file, so Tie::File will read the entire file and store the index of ...
48960190
Powershell Set-MpPreference -DisableRealtimeMonitoring $true not working correctly
9
2018-02-24 06:53:38
<p>I must warn you I don't use powershell much. I am trying to turn off windows defender real time protection via powershell I found the command <code>Set-MpPreference -DisableRealtimeMonitoring $true</code> and tried it in admin privileges only to get this</p> <blockquote> <p>Set-MpPreference : Operation failed wit...
61,988
9,381,567
2025-10-04 19:16:11
48,976,055
12
2018-02-25 16:56:52
45,375
2023-10-25 02:14:08
https://stackoverflow.com/q/48960190
https://stackoverflow.com/a/48976055
<p>The problem is that the <strong>Windows Defender antivirus services seem to be <em>persistently disabled</em> on your machine</strong>.</p> <p>It's unfortunate that the <code>Set-MpPreference</code> cmdlet reports this in such an obscure fashion.</p> <p>To fix this problem, <strong><em>re-enable</em> the Windows Def...
<p>The problem is that the <strong>Windows Defender antivirus services seem to be <em>persistently disabled</em> on your machine</strong>.</p> <p>It's unfortunate that the <code>Set-MpPreference</code> cmdlet reports this in such an obscure fashion.</p> <p>To fix this problem, <strong><em>re-enable</em> the Windows Def...
136, 526, 2631, 119343
cmd, powershell, security, windows-defender
<h1>Powershell Set-MpPreference -DisableRealtimeMonitoring $true not working correctly</h1> <p>I must warn you I don't use powershell much. I am trying to turn off windows defender real time protection via powershell I found the command <code>Set-MpPreference -DisableRealtimeMonitoring $true</code> and tried it in admi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,830
bash
# Powershell Set-MpPreference -DisableRealtimeMonitoring $true not working correctly I must warn you I don't use powershell much. I am trying to turn off windows defender real time protection via powershell I found the command `Set-MpPreference -DisableRealtimeMonitoring $true` and tried it in admin privileges only to...
The problem is that the **Windows Defender antivirus services seem to be *persistently disabled* on your machine**. It's unfortunate that the `Set-MpPreference` cmdlet reports this in such an obscure fashion. To fix this problem, ***re-enable* the Windows Defender antivirus services**: The easiest way to do this is ...
48967892
Find command regextype difference between 'posix-extended' and 'posix-egrep'
9
2018-02-24 21:39:14
<p>The title really says it all. Can anyone point me to where I could find descriptions of the different regex types available to the find command. I'm able to find a list of them but no explanations or comparisons. In particular, what could the difference be between 'posix-egrep' and 'posix-extended,' since egrep is a...
4,469
4,403,787
2018-11-27 17:24:35
48,967,991
12
2018-02-24 21:51:15
3,040,064
2018-02-24 21:51:15
https://stackoverflow.com/q/48967892
https://stackoverflow.com/a/48967991
<p>Let me guide through you how you should use linux's documentation to self-answer questions like this by showing you how exactly I locate information.</p> <ol> <li>I run <code>man find</code> to see some basic information of regular expression type by searching the keyword, <code>regular</code>, then I see this:</li...
<p>Let me guide through you how you should use linux's documentation to self-answer questions like this by showing you how exactly I locate information.</p> <ol> <li>I run <code>man find</code> to see some basic information of regular expression type by searching the keyword, <code>regular</code>, then I see this:</li...
18, 390, 1271, 10327
grep, regex, sh, shell
<h1>Find command regextype difference between 'posix-extended' and 'posix-egrep'</h1> <p>The title really says it all. Can anyone point me to where I could find descriptions of the different regex types available to the find command. I'm able to find a list of them but no explanations or comparisons. In particular, wha...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,831
bash
# Find command regextype difference between 'posix-extended' and 'posix-egrep' The title really says it all. Can anyone point me to where I could find descriptions of the different regex types available to the find command. I'm able to find a list of them but no explanations or comparisons. In particular, what could t...
Let me guide through you how you should use linux's documentation to self-answer questions like this by showing you how exactly I locate information. 1. I run `man find` to see some basic information of regular expression type by searching the keyword, `regular`, then I see this: > -regextype type > > Changes the reg...
47639770
Is there a relatively straightforward way to finalize a CD or DVD in C# or PowerShell?
9
2017-12-04 18:34:10
<p>First, some clarification of terms. By <strong>finalize,</strong> I don't mean closing a session; I mean writing a lead-out to a CD or DVD in such a way that information can no longer be added to it via the usual means (Roxio, Nero, Windows Explorer, etc.)</p> <p>I've done a fair amount of research on this. There ...
6,711
102,937
2021-02-17 01:22:12
48,198,360
12
2018-01-11 00:51:37
5,209,322
2018-01-11 05:36:04
https://stackoverflow.com/q/47639770
https://stackoverflow.com/a/48198360
<p>The <code>ForceMediaToBeClosed</code> property of <code>IDiscFormat2Data</code> <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa364886.aspx" rel="noreferrer">controls whether the IMAPI finalizes the disc</a> after the <em>next</em> write: </p> <blockquote> <p>Set to VARIANT_TRUE to mark the di...
<p>The <code>ForceMediaToBeClosed</code> property of <code>IDiscFormat2Data</code> <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa364886.aspx" rel="noreferrer">controls whether the IMAPI finalizes the disc</a> after the <em>next</em> write: </p> <blockquote> <p>Set to VARIANT_TRUE to mark the di...
9, 526, 31319
c#, imapi, powershell
<h1>Is there a relatively straightforward way to finalize a CD or DVD in C# or PowerShell?</h1> <p>First, some clarification of terms. By <strong>finalize,</strong> I don't mean closing a session; I mean writing a lead-out to a CD or DVD in such a way that information can no longer be added to it via the usual means (...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,832
bash
# Is there a relatively straightforward way to finalize a CD or DVD in C# or PowerShell? First, some clarification of terms. By **finalize,** I don't mean closing a session; I mean writing a lead-out to a CD or DVD in such a way that information can no longer be added to it via the usual means (Roxio, Nero, Windows Ex...
The `ForceMediaToBeClosed` property of `IDiscFormat2Data` [controls whether the IMAPI finalizes the disc](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364886.aspx) after the *next* write: > Set to VARIANT_TRUE to mark the disc as closed to prohibit additional writes when the next write session ends. The...
47212149
Getting error: bash: parse_git_branch: command not found
9
2017-11-09 21:49:16
<p>I am running the command:</p> <pre><code>sudo bash </code></pre> <p>But I keep getting an error on my terminal that says, </p> <pre><code>bash: parse_git_branch: command not found </code></pre> <p>Here is my <code>.bash_profile</code> file</p> <pre><code>parse_git_branch() { git branch 2&gt; /dev/null | sed...
9,667
8,141,672
2023-12-04 04:25:27
47,212,660
12
2017-11-09 22:27:37
1,126,841
2017-11-09 22:27:37
https://stackoverflow.com/q/47212149
https://stackoverflow.com/a/47212660
<p>The problem is that <code>parse_git_branch</code> is defined in <code>.bash_profile</code>, but not exported. When you run <code>sudo bash</code>, it starts an <em>nonlogin</em> shell that sources <code>.bashrc</code> instead of <code>.bash_profile</code>. <code>PS1</code> was exported and so is defined in the new s...
<p>The problem is that <code>parse_git_branch</code> is defined in <code>.bash_profile</code>, but not exported. When you run <code>sudo bash</code>, it starts an <em>nonlogin</em> shell that sources <code>.bashrc</code> instead of <code>.bash_profile</code>. <code>PS1</code> was exported and so is defined in the new s...
369, 387, 1674, 61874
bash, git-bash, macos, sudo
<h1>Getting error: bash: parse_git_branch: command not found</h1> <p>I am running the command:</p> <pre><code>sudo bash </code></pre> <p>But I keep getting an error on my terminal that says, </p> <pre><code>bash: parse_git_branch: command not found </code></pre> <p>Here is my <code>.bash_profile</code> file</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,833
bash
# Getting error: bash: parse_git_branch: command not found I am running the command: ``` sudo bash ``` But I keep getting an error on my terminal that says, ``` bash: parse_git_branch: command not found ``` Here is my `.bash_profile` file ``` parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e...
The problem is that `parse_git_branch` is defined in `.bash_profile`, but not exported. When you run `sudo bash`, it starts an *nonlogin* shell that sources `.bashrc` instead of `.bash_profile`. `PS1` was exported and so is defined in the new shell, but `parse_git_branch` is not. Typically, you would define both `PS1`...
45104509
Powershell Finally block skipped with Ctrl-C
9
2017-07-14 13:41:14
<p>I'm writing a monitoring script in Powershell using a Try/Finally to log a message should the script end. The script is intended to run indefinitely, so I want a way to track unintended exiting.</p> <p>Every other StackOverflow post and <a href="https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShe...
8,149
4,739,755
2024-06-11 21:05:15
45,105,609
12
2017-07-14 14:36:22
1,627,055
2017-11-24 16:08:39
https://stackoverflow.com/q/45104509
https://stackoverflow.com/a/45105609
<p>The proper answer is that <kbd>Ctrl</kbd>+<kbd>C</kbd> breaks pipeline, as is also stated in that link, and <code>echo</code> uses the pipeline to process its output. Therefore, once you <kbd>Ctrl</kbd>+<kbd>C</kbd>, writing to the pipeline causes the script block to err, and to not process any further commands. The...
<p>The proper answer is that <kbd>Ctrl</kbd>+<kbd>C</kbd> breaks pipeline, as is also stated in that link, and <code>echo</code> uses the pipeline to process its output. Therefore, once you <kbd>Ctrl</kbd>+<kbd>C</kbd>, writing to the pipeline causes the script block to err, and to not process any further commands. The...
526, 50963, 73157
powershell, powershell-3.0, try-finally
<h1>Powershell Finally block skipped with Ctrl-C</h1> <p>I'm writing a monitoring script in Powershell using a Try/Finally to log a message should the script end. The script is intended to run indefinitely, so I want a way to track unintended exiting.</p> <p>Every other StackOverflow post and <a href="https://msdn.mic...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,834
bash
# Powershell Finally block skipped with Ctrl-C I'm writing a monitoring script in Powershell using a Try/Finally to log a message should the script end. The script is intended to run indefinitely, so I want a way to track unintended exiting. Every other StackOverflow post and [Help page](https://msdn.microsoft.com/po...
The proper answer is that `Ctrl`+`C` breaks pipeline, as is also stated in that link, and `echo` uses the pipeline to process its output. Therefore, once you `Ctrl`+`C`, writing to the pipeline causes the script block to err, and to not process any further commands. Therefore, do not use commands that send output to st...
44779000
Powershell Connection to Oracle Database
9
2017-06-27 11:20:46
<p>I'm having trouble connecting to an Oracle database from Powershell using the <code>Oracle.ManagedDataAccess.dll</code>.</p> <p>I followed <a href="https://blogs.technet.microsoft.com/heyscriptingguy/2012/12/04/use-oracle-odp-net-and-powershell-to-simplify-data-access/" rel="noreferrer">this</a> tutorial on Technet...
81,381
6,485,881
2024-05-09 11:13:14
44,804,696
12
2017-06-28 14:00:43
6,485,881
2017-06-28 14:00:43
https://stackoverflow.com/q/44779000
https://stackoverflow.com/a/44804696
<p><em>Im not sure if this is technically a solution - I'd classify it more as a workaround, but it worked for me.</em></p> <hr> <p>After doing some more research I found a suitable alternative to the <code>Oracle.ManagedDataAccess.dll</code>. I found the <a href="https://msdn.microsoft.com/en-US/library/system.data....
<p><em>Im not sure if this is technically a solution - I'd classify it more as a workaround, but it worked for me.</em></p> <hr> <p>After doing some more research I found a suitable alternative to the <code>Oracle.ManagedDataAccess.dll</code>. I found the <a href="https://msdn.microsoft.com/en-US/library/system.data....
526, 165558
oracle-database, powershell
<h1>Powershell Connection to Oracle Database</h1> <p>I'm having trouble connecting to an Oracle database from Powershell using the <code>Oracle.ManagedDataAccess.dll</code>.</p> <p>I followed <a href="https://blogs.technet.microsoft.com/heyscriptingguy/2012/12/04/use-oracle-odp-net-and-powershell-to-simplify-data-acce...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,835
bash
# Powershell Connection to Oracle Database I'm having trouble connecting to an Oracle database from Powershell using the `Oracle.ManagedDataAccess.dll`. I followed [this](https://blogs.technet.microsoft.com/heyscriptingguy/2012/12/04/use-oracle-odp-net-and-powershell-to-simplify-data-access/) tutorial on Technet and ...
*Im not sure if this is technically a solution - I'd classify it more as a workaround, but it worked for me.* --- After doing some more research I found a suitable alternative to the `Oracle.ManagedDataAccess.dll`. I found the [System.Data.OracleClient](https://msdn.microsoft.com/en-US/library/system.data.oracleclien...
44207548
How to filter files in llvm-cov code coverage report?
9
2017-05-26 17:54:06
<p>From the <a href="http://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-show" rel="noreferrer">llvm-cov docs</a>:</p> <blockquote> <p><code> llvm-cov show [options] -instr-profile PROFILE BIN [-object BIN,...] [[-object BIN]] [SOURCES] </code></p> <p>The llvm-cov show command shows line by line covera...
8,622
438,063
2022-11-24 03:32:38
44,657,938
12
2017-06-20 16:03:06
265,521
2017-06-21 10:15:14
https://stackoverflow.com/q/44207548
https://stackoverflow.com/a/44657938
<p>It's badly worded but <code>SOURCES</code> is actually a list of file names, not the name of a file containing a list of filenames.</p> <p>They need to be the paths to the actual source files on disk. It doesn't support wildcards or regex unfortunately.</p> <p>Edit: By reading the source I have discovered that you...
<p>It's badly worded but <code>SOURCES</code> is actually a list of file names, not the name of a file containing a list of filenames.</p> <p>They need to be the paths to the actual source files on disk. It doesn't support wildcards or regex unfortunately.</p> <p>Edit: By reading the source I have discovered that you...
387, 908, 3315, 112928
bash, code-coverage, llvm-cov, xcode
<h1>How to filter files in llvm-cov code coverage report?</h1> <p>From the <a href="http://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-show" rel="noreferrer">llvm-cov docs</a>:</p> <blockquote> <p><code> llvm-cov show [options] -instr-profile PROFILE BIN [-object BIN,...] [[-object BIN]] [SOURCES] </code><...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,836
bash
# How to filter files in llvm-cov code coverage report? From the [llvm-cov docs](http://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-show): > `llvm-cov show [options] -instr-profile PROFILE BIN [-object BIN,...] [[-object BIN]] [SOURCES]` > > The llvm-cov show command shows line by line coverage of the binaries ...
It's badly worded but `SOURCES` is actually a list of file names, not the name of a file containing a list of filenames. They need to be the paths to the actual source files on disk. It doesn't support wildcards or regex unfortunately. Edit: By reading the source I have discovered that you can also list directories a...
43129163
Powershell - Invoke-WebRequest to a URL with literal '/' (%2F) in it
9
2017-03-30 22:05:25
<p>I have been trying to access a URL with a <code>/</code> character in it from powershell, using the following command (it's a query to a gitlab server to retrieve a project called <code>"foo/bar"</code>): </p> <pre><code>Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose </code></pre> <p>Now,...
11,738
1,731,397
2019-07-09 22:05:56
43,135,803
12
2017-03-31 08:17:22
7,715,547
2017-03-31 08:17:22
https://stackoverflow.com/q/43129163
https://stackoverflow.com/a/43135803
<p>Try the URL through this function</p> <pre><code>function fixuri($uri){ $UnEscapeDotsAndSlashes = 0x2000000; $SimpleUserSyntax = 0x20000; $type = $uri.GetType(); $fieldInfo = $type.GetField("m_Syntax", ([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)); $uriPa...
<p>Try the URL through this function</p> <pre><code>function fixuri($uri){ $UnEscapeDotsAndSlashes = 0x2000000; $SimpleUserSyntax = 0x20000; $type = $uri.GetType(); $fieldInfo = $type.GetField("m_Syntax", ([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)); $uriPa...
365, 526, 6443, 8023
powershell, url, urlencode, webrequest
<h1>Powershell - Invoke-WebRequest to a URL with literal '/' (%2F) in it</h1> <p>I have been trying to access a URL with a <code>/</code> character in it from powershell, using the following command (it's a query to a gitlab server to retrieve a project called <code>"foo/bar"</code>): </p> <pre><code>Invoke-WebReques...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,837
bash
# Powershell - Invoke-WebRequest to a URL with literal '/' (%2F) in it I have been trying to access a URL with a `/` character in it from powershell, using the following command (it's a query to a gitlab server to retrieve a project called `"foo/bar"`): ``` Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fb...
Try the URL through this function ``` function fixuri($uri){ $UnEscapeDotsAndSlashes = 0x2000000; $SimpleUserSyntax = 0x20000; $type = $uri.GetType(); $fieldInfo = $type.GetField("m_Syntax", ([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)); $uriParser = $fieldI...
42257450
How does Docker run a command without invoking a command shell?
9
2017-02-15 18:34:07
<p>I'm learning about Docker at the moment, and going through the <a href="https://docs.docker.com/engine/reference/builder/" rel="noreferrer">Dockerfile reference</a>, specifically the <a href="https://docs.docker.com/engine/reference/builder/#/run" rel="noreferrer"><strong><code>RUN</code></strong></a> instruction. T...
5,492
2,317,532
2019-05-18 16:47:31
42,257,653
12
2017-02-15 18:44:40
1,220,089
2019-05-18 16:47:31
https://stackoverflow.com/q/42257450
https://stackoverflow.com/a/42257653
<p>If I understand your question correctly, you're asking how something can be run (specifically in the context of docker) without invoking a command shell.</p> <p>The way things are run in the linux kernel are usually using <a href="https://linux.die.net/man/3/exec" rel="noreferrer">the <code>exec</code> family of sy...
<p>If I understand your question correctly, you're asking how something can be run (specifically in the context of docker) without invoking a command shell.</p> <p>The way things are run in the linux kernel are usually using <a href="https://linux.die.net/man/3/exec" rel="noreferrer">the <code>exec</code> family of sy...
390, 90304, 108477
docker, dockerfile, shell
<h1>How does Docker run a command without invoking a command shell?</h1> <p>I'm learning about Docker at the moment, and going through the <a href="https://docs.docker.com/engine/reference/builder/" rel="noreferrer">Dockerfile reference</a>, specifically the <a href="https://docs.docker.com/engine/reference/builder/#/r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,838
bash
# How does Docker run a command without invoking a command shell? I'm learning about Docker at the moment, and going through the [Dockerfile reference](https://docs.docker.com/engine/reference/builder/), specifically the [**`RUN`**](https://docs.docker.com/engine/reference/builder/#/run) instruction. There are two for...
If I understand your question correctly, you're asking how something can be run (specifically in the context of docker) without invoking a command shell. The way things are run in the linux kernel are usually using [the `exec` family of system calls.](https://linux.die.net/man/3/exec) You pass it the path to the exec...
42108296
How to supply argument to value of New-Alias command?
9
2017-02-08 08:39:28
<p>I wish <code>Get-ChildItem -force</code> to get executed when I type <code>ll</code> and I have this in my <code>profile.ps1</code>:</p> <pre><code>New-Alias -Name ll -Value Get-ChildItem -force </code></pre> <p>However, when I type <code>ll</code>, I can see that the <code>-force</code> argument is not being used...
3,732
2,448,495
2023-06-02 04:44:54
42,108,380
12
2017-02-08 08:44:50
73,070
2017-02-08 08:50:10
https://stackoverflow.com/q/42108296
https://stackoverflow.com/a/42108380
<p>You cannot do that with aliases. Aliases are really just different names for commands, they cannot include arguments.</p> <p>What you <em>can</em> do, however, is, write a function instead of using an alias:</p> <pre><code>function ll { Get-ChildItem -Force @args } </code></pre> <p>You won't get tab completion ...
<p>You cannot do that with aliases. Aliases are really just different names for commands, they cannot include arguments.</p> <p>What you <em>can</em> do, however, is, write a function instead of using an alias:</p> <pre><code>function ll { Get-ChildItem -Force @args } </code></pre> <p>You won't get tab completion ...
526
powershell
<h1>How to supply argument to value of New-Alias command?</h1> <p>I wish <code>Get-ChildItem -force</code> to get executed when I type <code>ll</code> and I have this in my <code>profile.ps1</code>:</p> <pre><code>New-Alias -Name ll -Value Get-ChildItem -force </code></pre> <p>However, when I type <code>ll</code>, I ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,839
bash
# How to supply argument to value of New-Alias command? I wish `Get-ChildItem -force` to get executed when I type `ll` and I have this in my `profile.ps1`: ``` New-Alias -Name ll -Value Get-ChildItem -force ``` However, when I type `ll`, I can see that the `-force` argument is not being used. What am I doing wrong? ...
You cannot do that with aliases. Aliases are really just different names for commands, they cannot include arguments. What you *can* do, however, is, write a function instead of using an alias: ``` function ll { Get-ChildItem -Force @args } ``` You won't get tab completion for arguments in that case, though, as th...
41307313
Custom git command autocompletion
9
2016-12-23 20:09:24
<p>I have implemented a custom git command by writing a shell script located in <code>/usr/local/bin</code>. It works fine, but I would like the script to autocomplete branches in the command line, just like <code>git checkout [TAB][TAB]</code>. How could this be done?</p> <p>EDIT: Just adding some context: git allows...
2,600
4,802,825
2021-01-18 20:43:53
41,307,951
12
2016-12-23 21:16:48
4,802,825
2016-12-23 21:16:48
https://stackoverflow.com/q/41307313
https://stackoverflow.com/a/41307951
<p>Figured it out. I needed to download git bash completion (<a href="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash" rel="noreferrer">here</a>), create a new file in <code>/etc/bash_completion.d</code> with the following contents:</p> <pre><code>source ~/.git-completion.bash _...
<p>Figured it out. I needed to download git bash completion (<a href="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash" rel="noreferrer">here</a>), create a new file in <code>/etc/bash_completion.d</code> with the following contents:</p> <pre><code>source ~/.git-completion.bash _...
58, 119, 390
git, linux, shell
<h1>Custom git command autocompletion</h1> <p>I have implemented a custom git command by writing a shell script located in <code>/usr/local/bin</code>. It works fine, but I would like the script to autocomplete branches in the command line, just like <code>git checkout [TAB][TAB]</code>. How could this be done?</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,840
bash
# Custom git command autocompletion I have implemented a custom git command by writing a shell script located in `/usr/local/bin`. It works fine, but I would like the script to autocomplete branches in the command line, just like `git checkout [TAB][TAB]`. How could this be done? EDIT: Just adding some context: git a...
Figured it out. I needed to download git bash completion ([here](https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash)), create a new file in `/etc/bash_completion.d` with the following contents: ``` source ~/.git-completion.bash _git_install () { __gitcomp_nl "$(__git_refs)" } ```...
41151579
Why is this Bash function within a git alias executing twice, and why does adding `exit` fix it?
9
2016-12-14 20:27:13
<p>If I fail to explicitly call <a href="http://pubs.opengroup.org/onlinepubs/009695399/utilities/exit.html" rel="nofollow noreferrer"><code>exit</code></a> for certain function-based Bash scripts then there are additional unexpected executions for some functions. What is causing this? The behavior was first noticed wh...
836
2,446,574
2019-08-05 17:00:52
41,305,925
12
2016-12-23 18:01:57
1,815,797
2016-12-23 18:01:57
https://stackoverflow.com/q/41151579
https://stackoverflow.com/a/41305925
<p>That's because of the way <code>git</code> handles aliases:</p> <p>Given an alias</p> <pre> [alias] myalias = !<em>string</em> </pre> <p>where <code><em>string</em></code> is any string that represents some code, when calling <code>git myalias <em>args</em></code> where <code><em>args</em></code> is a (possib...
<p>That's because of the way <code>git</code> handles aliases:</p> <p>Given an alias</p> <pre> [alias] myalias = !<em>string</em> </pre> <p>where <code><em>string</em></code> is any string that represents some code, when calling <code>git myalias <em>args</em></code> where <code><em>args</em></code> is a (possib...
119, 387, 390, 1448, 10871
alias, bash, exit, git, shell
<h1>Why is this Bash function within a git alias executing twice, and why does adding `exit` fix it?</h1> <p>If I fail to explicitly call <a href="http://pubs.opengroup.org/onlinepubs/009695399/utilities/exit.html" rel="nofollow noreferrer"><code>exit</code></a> for certain function-based Bash scripts then there are ad...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,841
bash
# Why is this Bash function within a git alias executing twice, and why does adding `exit` fix it? If I fail to explicitly call [`exit`](http://pubs.opengroup.org/onlinepubs/009695399/utilities/exit.html) for certain function-based Bash scripts then there are additional unexpected executions for some functions. What i...
That's because of the way `git` handles aliases: Given an alias ``` [alias] myalias = !string ``` where `string` is any string that represents some code, when calling `git myalias args` where `args` is a (possibly empty) list of arguments, `git` will execute: ``` sh -c 'string "$@"' 'string' args ``` For e...
39445968
BASH - getting UID on shell script does not work
9
2016-09-12 08:16:06
<p>Hi I have a question about bash.</p> <p>and I'm new to it.</p> <p>I made a file named "test.sh" and its contents is</p> <pre><code>#!/bin/bash set -x echo $UID echo "$UID" echo "$(id -u)" </code></pre> <p>and the result is blank!! nothing shows up</p> <p>However, when i just type "echo $UID" on terminal it show...
23,623
4,247,432
2016-09-28 16:10:13
39,446,268
12
2016-09-12 08:34:52
1,344,961
2016-09-28 16:10:13
https://stackoverflow.com/q/39445968
https://stackoverflow.com/a/39446268
<p><code>$UID</code> is a Bash variable that is not set under <code>sh</code>, that may be why it outputs blank lines.</p> <p>Try <code>bash test.sh</code> or make your script executable with <code>chmod u+x test.sh</code>, the program defined in shebang will then be used (<code>/bin/bash</code>)</p>
<p><code>$UID</code> is a Bash variable that is not set under <code>sh</code>, that may be why it outputs blank lines.</p> <p>Try <code>bash test.sh</code> or make your script executable with <code>chmod u+x test.sh</code>, the program defined in shebang will then be used (<code>/bin/bash</code>)</p>
387, 390
bash, shell
<h1>BASH - getting UID on shell script does not work</h1> <p>Hi I have a question about bash.</p> <p>and I'm new to it.</p> <p>I made a file named "test.sh" and its contents is</p> <pre><code>#!/bin/bash set -x echo $UID echo "$UID" echo "$(id -u)" </code></pre> <p>and the result is blank!! nothing shows up</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,842
bash
# BASH - getting UID on shell script does not work Hi I have a question about bash. and I'm new to it. I made a file named "test.sh" and its contents is ``` #!/bin/bash set -x echo $UID echo "$UID" echo "$(id -u)" ``` and the result is blank!! nothing shows up However, when i just type "echo $UID" on terminal it ...
`$UID` is a Bash variable that is not set under `sh`, that may be why it outputs blank lines. Try `bash test.sh` or make your script executable with `chmod u+x test.sh`, the program defined in shebang will then be used (`/bin/bash`)
38307078
Linux - Shell script run curl command in parallel
9
2016-07-11 12:34:58
<p>I would like to create linux shell script to run CURL command in parallel </p> <p>For example: I have three command like </p> <ol> <li>curl -s <a href="http://localhost/process.php?id=1" rel="noreferrer">http://localhost/process.php?id=1</a></li> <li>curl -s <a href="http://localhost/process.php?id=2" rel="norefer...
15,502
4,773,217
2016-07-11 12:39:22
38,307,180
12
2016-07-11 12:39:22
6,329,633
2016-07-11 12:39:22
https://stackoverflow.com/q/38307078
https://stackoverflow.com/a/38307180
<p>I think a bash script like:</p> <pre><code>#!/bin/bash curl -s http://localhost/process.php?id=1 &amp; curl -s http://localhost/process.php?id=2 &amp; curl -s http://localhost/process.php?id=3 &amp; </code></pre> <p>However, this is starting all tasks as background processes. Don't know how crucial simultaneous s...
<p>I think a bash script like:</p> <pre><code>#!/bin/bash curl -s http://localhost/process.php?id=1 &amp; curl -s http://localhost/process.php?id=2 &amp; curl -s http://localhost/process.php?id=3 &amp; </code></pre> <p>However, this is starting all tasks as background processes. Don't know how crucial simultaneous s...
58, 390
linux, shell
<h1>Linux - Shell script run curl command in parallel</h1> <p>I would like to create linux shell script to run CURL command in parallel </p> <p>For example: I have three command like </p> <ol> <li>curl -s <a href="http://localhost/process.php?id=1" rel="noreferrer">http://localhost/process.php?id=1</a></li> <li>curl ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,843
bash
# Linux - Shell script run curl command in parallel I would like to create linux shell script to run CURL command in parallel For example: I have three command like 1. curl -s <http://localhost/process.php?id=1> 2. curl -s <http://localhost/process.php?id=2> 3. curl -s <http://localhost/process.php?id=3> I want to ...
I think a bash script like: ``` #!/bin/bash curl -s http://localhost/process.php?id=1 & curl -s http://localhost/process.php?id=2 & curl -s http://localhost/process.php?id=3 & ``` However, this is starting all tasks as background processes. Don't know how crucial simultaneous starting of the process is.
37474439
Run PHP Artisan Without Change Directory
9
2016-05-27 03:38:39
<p>How to run command php artisan serve without change to the proect directory?</p> <p>I try to run this command but nothing happen</p> <pre><code>php /home/john/Documents/project/ artisan serve --port=1111 </code></pre> <p>I want to insert this command to alisases at bash aliases so i don't need to insert the port ...
4,013
4,860,664
2016-05-27 03:41:41
37,474,462
12
2016-05-27 03:41:41
1,227,923
2016-05-27 03:41:41
https://stackoverflow.com/q/37474439
https://stackoverflow.com/a/37474462
<p>Try to remove space:</p> <pre><code>php /home/john/Documents/project/artisan serve --port=1111 </code></pre>
<p>Try to remove space:</p> <pre><code>php /home/john/Documents/project/artisan serve --port=1111 </code></pre>
5, 387, 75151, 138708
bash, laravel, laravel-artisan, php
<h1>Run PHP Artisan Without Change Directory</h1> <p>How to run command php artisan serve without change to the proect directory?</p> <p>I try to run this command but nothing happen</p> <pre><code>php /home/john/Documents/project/ artisan serve --port=1111 </code></pre> <p>I want to insert this command to alisases a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,844
bash
# Run PHP Artisan Without Change Directory How to run command php artisan serve without change to the proect directory? I try to run this command but nothing happen ``` php /home/john/Documents/project/ artisan serve --port=1111 ``` I want to insert this command to alisases at bash aliases so i don't need to insert...
Try to remove space: ``` php /home/john/Documents/project/artisan serve --port=1111 ```
34427146
What's the point of eval/bash -c as opposed to just evaluating a variable?
9
2015-12-23 01:22:24
<p>Suppose you have the following command stored in a variable:</p> <pre><code>COMMAND='echo hello' </code></pre> <p>What's the difference between</p> <pre><code>$ eval "$COMMAND" hello $ bash -c "$COMMAND" hello $ $COMMAND hello </code></pre> <p>? Why is the last version almost never used if it is shorter and (a...
1,008
4,077,294
2016-10-04 14:50:04
34,427,499
12
2015-12-23 02:06:56
14,122
2016-10-04 14:50:04
https://stackoverflow.com/q/34427146
https://stackoverflow.com/a/34427499
<p>The third form is not at all like the other two -- but to understand why, we need to go into the order of operations when bash in interpreting a command, and look at which of those are followed when each method is in use.</p> <h1>Bash Parsing Stages</h1> <ol> <li>Quote Processing</li> <li>Splitting Into Commands</...
<p>The third form is not at all like the other two -- but to understand why, we need to go into the order of operations when bash in interpreting a command, and look at which of those are followed when each method is in use.</p> <h1>Bash Parsing Stages</h1> <ol> <li>Quote Processing</li> <li>Splitting Into Commands</...
34, 58, 387, 390, 10327
bash, linux, sh, shell, unix
<h1>What's the point of eval/bash -c as opposed to just evaluating a variable?</h1> <p>Suppose you have the following command stored in a variable:</p> <pre><code>COMMAND='echo hello' </code></pre> <p>What's the difference between</p> <pre><code>$ eval "$COMMAND" hello $ bash -c "$COMMAND" hello $ $COMMAND hello <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,845
bash
# What's the point of eval/bash -c as opposed to just evaluating a variable? Suppose you have the following command stored in a variable: ``` COMMAND='echo hello' ``` What's the difference between ``` $ eval "$COMMAND" hello $ bash -c "$COMMAND" hello $ $COMMAND hello ``` ? Why is the last version almost never u...
The third form is not at all like the other two -- but to understand why, we need to go into the order of operations when bash in interpreting a command, and look at which of those are followed when each method is in use. # Bash Parsing Stages 1. Quote Processing 2. Splitting Into Commands 3. Special Operator Parsing...
34188411
how to debug fish script?
9
2015-12-09 20:31:32
<p>You can <a href="https://stackoverflow.com/a/951352/802365">debug a bash script</a> like this:</p> <pre><code>bash -x script [arg1 ...]` </code></pre> <h3>Question</h3> <p>What is the <strong><code>fish</code> equivalent?</strong></p>
4,600
802,365
2021-05-27 11:53:36
34,188,509
12
2015-12-09 20:37:40
802,365
2015-12-09 22:47:58
https://stackoverflow.com/q/34188411
https://stackoverflow.com/a/34188509
<p>Fish use a similar flag system:</p> <pre><code>fish -d 3 script.fish </code></pre> <p>Where <a href="http://fishshell.com/docs/2.2/commands.html#fish-description" rel="noreferrer"><code>d</code> is the debug flag followed by the verbosity level</a>:</p> <blockquote> <p>-d or --debug-level=DEBUG_LEVEL specify the ver...
<p>Fish use a similar flag system:</p> <pre><code>fish -d 3 script.fish </code></pre> <p>Where <a href="http://fishshell.com/docs/2.2/commands.html#fish-description" rel="noreferrer"><code>d</code> is the debug flag followed by the verbosity level</a>:</p> <blockquote> <p>-d or --debug-level=DEBUG_LEVEL specify the ver...
277, 390, 531, 55824
debugging, fish, scripting, shell
<h1>how to debug fish script?</h1> <p>You can <a href="https://stackoverflow.com/a/951352/802365">debug a bash script</a> like this:</p> <pre><code>bash -x script [arg1 ...]` </code></pre> <h3>Question</h3> <p>What is the <strong><code>fish</code> equivalent?</strong></p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,846
bash
# how to debug fish script? You can [debug a bash script](https://stackoverflow.com/a/951352/802365) like this: ``` bash -x script [arg1 ...]` ``` ### Question What is the **`fish` equivalent?**
Fish use a similar flag system: ``` fish -d 3 script.fish ``` Where [`d` is the debug flag followed by the verbosity level](http://fishshell.com/docs/2.2/commands.html#fish-description): > -d or --debug-level=DEBUG_LEVEL specify the verbosity level of fish. A higher number means higher verbosity. The default level i...
33526823
Powershell curl double quotes
9
2015-11-04 16:18:36
<p>I am trying to invoke a curl command in powershell and pass some JSON information. </p> <p>Here is my command:</p> <pre><code>curl -X POST -u username:password -H "Content-Type: application/json" -d "{ "fields": { "project": { "key": "key" }, "summary": "summary", "description": "description - here", "type": { "na...
5,493
5,100,278
2023-10-13 07:11:07
33,527,459
12
2015-11-04 16:49:48
18,771
2015-11-04 16:49:48
https://stackoverflow.com/q/33526823
https://stackoverflow.com/a/33527459
<p>Pipe the data into curl.exe, instead of trying to escape it.</p> <pre><code>$data = @{ fields = @{ project = @{ key = "key" } summary = "summary" description = "description - here" type = @{ name = "Task" } } } $data | ConvertTo-Json -...
<p>Pipe the data into curl.exe, instead of trying to escape it.</p> <pre><code>$data = @{ fields = @{ project = @{ key = "key" } summary = "summary" description = "description - here" type = @{ name = "Task" } } } $data | ConvertTo-Json -...
526, 1508, 1554, 4804, 12658
character-encoding, curl, escaping, json, powershell
<h1>Powershell curl double quotes</h1> <p>I am trying to invoke a curl command in powershell and pass some JSON information. </p> <p>Here is my command:</p> <pre><code>curl -X POST -u username:password -H "Content-Type: application/json" -d "{ "fields": { "project": { "key": "key" }, "summary": "summary", "descriptio...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,847
bash
# Powershell curl double quotes I am trying to invoke a curl command in powershell and pass some JSON information. Here is my command: ``` curl -X POST -u username:password -H "Content-Type: application/json" -d "{ "fields": { "project": { "key": "key" }, "summary": "summary", "description": "description - here", "t...
Pipe the data into curl.exe, instead of trying to escape it. ``` $data = @{ fields = @{ project = @{ key = "key" } summary = "summary" description = "description - here" type = @{ name = "Task" } } } $data | ConvertTo-Json -Compress | cur...
33291631
Is there a simple way to get rid of junk values that come when you SSH using Python's Paramiko library and fetch output from CLI of a remote machine?
9
2015-10-22 22:09:58
<p>I am using Python's Paramiko library to SSH a remote machine and fetch some output from command-line. I see a lot of junk printing along with the actual output. How to get rid of this?</p> <pre><code>chan1.send(&quot;ls\n&quot;) output = chan1.recv(1024).decode(&quot;utf-8&quot;) print(output) [u'Last login: Wed Oct...
6,070
5,066,525
2023-08-03 05:41:49
33,296,127
12
2015-10-23 06:31:07
850,848
2023-08-03 05:41:49
https://stackoverflow.com/q/33291631
https://stackoverflow.com/a/33296127
<p>It's not a junk. These are <a href="https://en.wikipedia.org/wiki/ANSI_escape_code" rel="nofollow noreferrer">ANSI escape codes</a> that are normally interpreted by a terminal client to pretty print the output.</p> <p>If the server is correctly configured, you get these only, when you use an interactive terminal, in...
<p>It's not a junk. These are <a href="https://en.wikipedia.org/wiki/ANSI_escape_code" rel="nofollow noreferrer">ANSI escape codes</a> that are normally interpreted by a terminal client to pretty print the output.</p> <p>If the server is correctly configured, you get these only, when you use an interactive terminal, in...
16, 386, 390, 14323, 18589
ansi-escape, paramiko, python, shell, ssh
<h1>Is there a simple way to get rid of junk values that come when you SSH using Python's Paramiko library and fetch output from CLI of a remote machine?</h1> <p>I am using Python's Paramiko library to SSH a remote machine and fetch some output from command-line. I see a lot of junk printing along with the actual outpu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,848
bash
# Is there a simple way to get rid of junk values that come when you SSH using Python's Paramiko library and fetch output from CLI of a remote machine? I am using Python's Paramiko library to SSH a remote machine and fetch some output from command-line. I see a lot of junk printing along with the actual output. How to...
It's not a junk. These are [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) that are normally interpreted by a terminal client to pretty print the output. If the server is correctly configured, you get these only, when you use an interactive terminal, in other words, if you requested a [pseudo termi...
32922557
Find files modified over 1 hour ago but less than 3 days
9
2015-10-03 12:28:30
<p>In linux, using bash, what's the easiest way to find files that were modified more than an hour ago but less than 3 days ago?</p> <p>Surely, there's got to be an easy way to do this. I keep searching and can't find an easy solution.</p>
13,902
2,229,277
2024-06-04 12:51:29
32,922,585
12
2015-10-03 12:31:12
3,009,892
2024-06-04 12:51:29
https://stackoverflow.com/q/32922557
https://stackoverflow.com/a/32922585
<p>Find has -mtime and -mmin:</p> <pre><code>find . -mtime -3 -mmin +60 </code></pre> <p>From the find manual:</p> <blockquote> <p>Numeric arguments can be specified as:</p> <p>+n for greater than n</p> <p>-n for less than n</p> <p>n for exactly n</p> </blockquote>
<p>Find has -mtime and -mmin:</p> <pre><code>find . -mtime -3 -mmin +60 </code></pre> <p>From the find manual:</p> <blockquote> <p>Numeric arguments can be specified as:</p> <p>+n for greater than n</p> <p>-n for less than n</p> <p>n for exactly n</p> </blockquote>
58, 387
bash, linux
<h1>Find files modified over 1 hour ago but less than 3 days</h1> <p>In linux, using bash, what's the easiest way to find files that were modified more than an hour ago but less than 3 days ago?</p> <p>Surely, there's got to be an easy way to do this. I keep searching and can't find an easy solution.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,849
bash
# Find files modified over 1 hour ago but less than 3 days In linux, using bash, what's the easiest way to find files that were modified more than an hour ago but less than 3 days ago? Surely, there's got to be an easy way to do this. I keep searching and can't find an easy solution.
Find has -mtime and -mmin: ``` find . -mtime -3 -mmin +60 ``` From the find manual: > Numeric arguments can be specified as: > > +n for greater than n > > -n for less than n > > n for exactly n
31791324
Bash: Looping over multiple input sources (nesting "while read" loops?)
9
2015-08-03 15:35:16
<p>I have a <code>query.sh</code> script which runs <code>dig</code> commands, performing a set of lookups from different DNS servers, which are currently given in a column in the single input file used (<code>sites.txt</code>).</p> <p>My goal is to modify this script to use a different input file, <code>dns_servers.t...
8,807
2,382,290
2015-08-04 16:36:37
31,791,521
12
2015-08-03 15:45:47
14,122
2015-08-03 21:24:02
https://stackoverflow.com/q/31791324
https://stackoverflow.com/a/31791521
<p>Ignoring any additional column(s) in the <code>sites.txt</code> file, and iterating through the lines of <code>dns_servers.txt</code>, might look like the following:</p> <pre><code>#!/bin/sh while read -r site _ &lt;&amp;3; do while read -r dns_server &lt;&amp;4; do dig +short -4 "@$dns_server" "$site"; exit=...
<p>Ignoring any additional column(s) in the <code>sites.txt</code> file, and iterating through the lines of <code>dns_servers.txt</code>, might look like the following:</p> <pre><code>#!/bin/sh while read -r site _ &lt;&amp;3; do while read -r dns_server &lt;&amp;4; do dig +short -4 "@$dns_server" "$site"; exit=...
387
bash
<h1>Bash: Looping over multiple input sources (nesting "while read" loops?)</h1> <p>I have a <code>query.sh</code> script which runs <code>dig</code> commands, performing a set of lookups from different DNS servers, which are currently given in a column in the single input file used (<code>sites.txt</code>).</p> <p>My...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,850
bash
# Bash: Looping over multiple input sources (nesting "while read" loops?) I have a `query.sh` script which runs `dig` commands, performing a set of lookups from different DNS servers, which are currently given in a column in the single input file used (`sites.txt`). My goal is to modify this script to use a different...
Ignoring any additional column(s) in the `sites.txt` file, and iterating through the lines of `dns_servers.txt`, might look like the following: ``` #!/bin/sh while read -r site _ <&3; do while read -r dns_server <&4; do dig +short -4 "@$dns_server" "$site"; exit=$? sleep 5 echo "Exit status: $exit" don...
31546680
How to pipe grep output to paste input?
9
2015-07-21 18:16:36
<p>I basically want to take the line that is under the word "LOAD" in filename1, and make it the second column in a new file, where the first column comes from filename2. (This is being done inside a loop, but I think that's irrelevant.)</p> <p>So if I have</p> <pre><code>grep -A 1 LOAD filename1 &gt;&gt; temp paste ...
15,867
4,302,219
2021-05-15 02:19:59
31,546,711
12
2015-07-21 18:18:25
548,225
2015-07-21 18:18:25
https://stackoverflow.com/q/31546680
https://stackoverflow.com/a/31546711
<p>You can use <strong>process substitution</strong> instead of using a temporary file:</p> <pre><code>paste filename2 &lt;(grep -A 1 LOAD filename1) &gt;&gt; filename3 </code></pre>
<p>You can use <strong>process substitution</strong> instead of using a temporary file:</p> <pre><code>paste filename2 &lt;(grep -A 1 LOAD filename1) &gt;&gt; filename3 </code></pre>
387
bash
<h1>How to pipe grep output to paste input?</h1> <p>I basically want to take the line that is under the word "LOAD" in filename1, and make it the second column in a new file, where the first column comes from filename2. (This is being done inside a loop, but I think that's irrelevant.)</p> <p>So if I have</p> <pre><c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,851
bash
# How to pipe grep output to paste input? I basically want to take the line that is under the word "LOAD" in filename1, and make it the second column in a new file, where the first column comes from filename2. (This is being done inside a loop, but I think that's irrelevant.) So if I have ``` grep -A 1 LOAD filename...
You can use **process substitution** instead of using a temporary file: ``` paste filename2 <(grep -A 1 LOAD filename1) >> filename3 ```
29881948
Start-AzureStorageBlobCopy vs AzCopy: which one takes lesser time
9
2015-04-26 18:48:13
<p>I need to move vhds from one subscription to other. I would like to know which one is better option for the same: <code>Start-AzureStorageBlobCopy</code> or <code>AzCopy</code>?</p> <p>Which one takes lesser time ?</p>
13,627
4,657,053
2018-06-02 00:01:03
29,888,363
12
2015-04-27 06:09:11
188,096
2015-04-27 06:09:11
https://stackoverflow.com/q/29881948
https://stackoverflow.com/a/29888363
<p>Both of them would take the same time as all they do is initiate <code>Async Server-Side Blob Copy</code>. They just tell the service to start copying blob from source to destination. The actual copy operation is performed by Azure Blob Storage Service. The time it would take to copy the blob would depend on a numbe...
<p>Both of them would take the same time as all they do is initiate <code>Async Server-Side Blob Copy</code>. They just tell the service to start copying blob from source to destination. The actual copy operation is performed by Azure Blob Storage Service. The time it would take to copy the blob would depend on a numbe...
14158, 35808, 81879
azure, azure-powershell, azure-storage
<h1>Start-AzureStorageBlobCopy vs AzCopy: which one takes lesser time</h1> <p>I need to move vhds from one subscription to other. I would like to know which one is better option for the same: <code>Start-AzureStorageBlobCopy</code> or <code>AzCopy</code>?</p> <p>Which one takes lesser time ?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,852
bash
# Start-AzureStorageBlobCopy vs AzCopy: which one takes lesser time I need to move vhds from one subscription to other. I would like to know which one is better option for the same: `Start-AzureStorageBlobCopy` or `AzCopy`? Which one takes lesser time ?
Both of them would take the same time as all they do is initiate `Async Server-Side Blob Copy`. They just tell the service to start copying blob from source to destination. The actual copy operation is performed by Azure Blob Storage Service. The time it would take to copy the blob would depend on a number of factors i...
28755179
Select node by its text value in xmlstarlet
9
2015-02-27 00:01:24
<p>I am trying to extract the value of the 'Value' node, where the 'Key' node is 'state' within a bash shell:</p> <pre><code>&lt;FrontendStatus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" serializerVersion="1.1"&gt; &lt;script/&gt; &lt;State&gt; &lt;String&gt; ... ... &lt;/String&gt;...
12,811
4,612,473
2015-02-27 16:42:31
28,756,693
12
2015-02-27 02:49:06
290,085
2015-02-27 16:42:31
https://stackoverflow.com/q/28755179
https://stackoverflow.com/a/28756693
<p>This XPath will select <code>Value</code> of a <code>State</code> based on its <code>Key</code> equalling <code>state</code>:</p> <pre><code>/FrontendStatus/State/String[Key='state']/Value </code></pre> <p>Or, in xmlstarlet:</p> <pre><code>$ xmlstarlet sel -t -m "/FrontendStatus/State/String[Key='state']" -v Valu...
<p>This XPath will select <code>Value</code> of a <code>State</code> based on its <code>Key</code> equalling <code>state</code>:</p> <pre><code>/FrontendStatus/State/String[Key='state']/Value </code></pre> <p>Or, in xmlstarlet:</p> <pre><code>$ xmlstarlet sel -t -m "/FrontendStatus/State/String[Key='state']" -v Valu...
19, 387, 41818
bash, xml, xmlstarlet
<h1>Select node by its text value in xmlstarlet</h1> <p>I am trying to extract the value of the 'Value' node, where the 'Key' node is 'state' within a bash shell:</p> <pre><code>&lt;FrontendStatus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" serializerVersion="1.1"&gt; &lt;script/&gt; &lt;State...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,853
bash
# Select node by its text value in xmlstarlet I am trying to extract the value of the 'Value' node, where the 'Key' node is 'state' within a bash shell: ``` <FrontendStatus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" serializerVersion="1.1"> <script/> <State> <String> ... ... </Stri...
This XPath will select `Value` of a `State` based on its `Key` equalling `state`: ``` /FrontendStatus/State/String[Key='state']/Value ``` Or, in xmlstarlet: ``` $ xmlstarlet sel -t -m "/FrontendStatus/State/String[Key='state']" -v Value <status.xml ``` Will return `WatchingLiveTV` as requested.
28585171
How to alter role from command line in postgresql?
9
2015-02-18 13:44:55
<p>I'm trying to build a setup script to automate the development environments creation, but I'm having trouble both trying to pipe or using the -c modifier for psql.</p> <p>I've tried:</p> <pre><code>sudo su postgres psql -c "ALTER ROLE postgres WITH password 'pass'" </code></pre> <p>and </p> <pre><code>sudo su po...
18,366
1,730,172
2020-01-24 22:34:02
28,585,705
12
2015-02-18 14:11:53
238,814
2015-02-18 14:11:53
https://stackoverflow.com/q/28585171
https://stackoverflow.com/a/28585705
<p>What's wrong is the lack of <code>-c</code> or <code>--command</code> for <code>su</code> to indicate that the rest of the line is a command.</p> <p>But <code>su</code> is not needed anyway, because there's already <code>sudo</code>. Do this instead:</p> <pre><code>sudo -u postgres psql -c "ALTER ROLE postgres WIT...
<p>What's wrong is the lack of <code>-c</code> or <code>--command</code> for <code>su</code> to indicate that the rest of the line is a command.</p> <p>But <code>su</code> is not needed anyway, because there's already <code>sudo</code>. Do this instead:</p> <pre><code>sudo -u postgres psql -c "ALTER ROLE postgres WIT...
256, 549, 10327
postgresql, sh, ubuntu
<h1>How to alter role from command line in postgresql?</h1> <p>I'm trying to build a setup script to automate the development environments creation, but I'm having trouble both trying to pipe or using the -c modifier for psql.</p> <p>I've tried:</p> <pre><code>sudo su postgres psql -c "ALTER ROLE postgres WITH passwo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,854
bash
# How to alter role from command line in postgresql? I'm trying to build a setup script to automate the development environments creation, but I'm having trouble both trying to pipe or using the -c modifier for psql. I've tried: ``` sudo su postgres psql -c "ALTER ROLE postgres WITH password 'pass'" ``` and ``` su...
What's wrong is the lack of `-c` or `--command` for `su` to indicate that the rest of the line is a command. But `su` is not needed anyway, because there's already `sudo`. Do this instead: ``` sudo -u postgres psql -c "ALTER ROLE postgres WITH password 'pass'" ```
27650740
'PowerShell' is not recognized as an internal or external command
9
2014-12-25 21:09:17
<p>I have just installed Chocolatey via PowerShell, I tried running PowerShell both as myself and as administrator, and if I try running choco or cinst I get the following error:</p> <pre><code>PS C:\&gt; choco /? 'PowerShell' is not recognized as an internal or external command, operable program or batch file. </code...
32,721
486,512
2018-06-21 19:24:45
27,650,809
12
2014-12-25 21:20:35
null
2014-12-25 21:20:35
https://stackoverflow.com/q/27650740
https://stackoverflow.com/a/27650809
<p>This can happen if a program is not on your PATH. Open a PowerShell prompt and enter</p> <pre class="lang-sh prettyprint-override"><code>[environment]::setEnvironmentVariable('PATH', "$env:path;C:\Windows\System32\WindowsPowerShell\v1.0", 'm') </code></pre> <p>then restart PowerShell.</p>
<p>This can happen if a program is not on your PATH. Open a PowerShell prompt and enter</p> <pre class="lang-sh prettyprint-override"><code>[environment]::setEnvironmentVariable('PATH', "$env:path;C:\Windows\System32\WindowsPowerShell\v1.0", 'm') </code></pre> <p>then restart PowerShell.</p>
526, 80758
chocolatey, powershell
<h1>'PowerShell' is not recognized as an internal or external command</h1> <p>I have just installed Chocolatey via PowerShell, I tried running PowerShell both as myself and as administrator, and if I try running choco or cinst I get the following error:</p> <pre><code>PS C:\&gt; choco /? 'PowerShell' is not recognized...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,855
bash
# 'PowerShell' is not recognized as an internal or external command I have just installed Chocolatey via PowerShell, I tried running PowerShell both as myself and as administrator, and if I try running choco or cinst I get the following error: ``` PS C:\> choco /? 'PowerShell' is not recognized as an internal or exte...
This can happen if a program is not on your PATH. Open a PowerShell prompt and enter ``` [environment]::setEnvironmentVariable('PATH', "$env:path;C:\Windows\System32\WindowsPowerShell\v1.0", 'm') ``` then restart PowerShell.
27028486
How to execute system command in Erlang and get results using os:cmd/1?
9
2014-11-19 22:45:43
<p>When I try to execute following command that returns error or doesn't exit on Windows - I always get empty list instead of error returned as string so for example: </p> <p>I get: </p> <pre><code>[] = os:cmd("blah"). </code></pre> <p>instead of something like </p> <pre><code>"command not found" = os:cmd("blah"). ...
8,541
3,169,252
2020-04-28 16:28:11
27,047,529
12
2014-11-20 19:06:24
1,691,583
2014-11-20 19:06:24
https://stackoverflow.com/q/27028486
https://stackoverflow.com/a/27047529
<p>I am not familiar with windows at all, but I'm sure, you should look <a href="https://github.com/erlang/otp/blob/maint/lib/kernel/src/os.erl#L188">this</a>. This is implementation <code>os:cmd/1</code> function.</p> <p>There is problem with <code>os:cmd/1</code>. This function doesn't let you know, was command exe...
<p>I am not familiar with windows at all, but I'm sure, you should look <a href="https://github.com/erlang/otp/blob/maint/lib/kernel/src/os.erl#L188">this</a>. This is implementation <code>os:cmd/1</code> function.</p> <p>There is problem with <code>os:cmd/1</code>. This function doesn't let you know, was command exe...
538, 51067
erlang, erlang-shell
<h1>How to execute system command in Erlang and get results using os:cmd/1?</h1> <p>When I try to execute following command that returns error or doesn't exit on Windows - I always get empty list instead of error returned as string so for example: </p> <p>I get: </p> <pre><code>[] = os:cmd("blah"). </code></pre> <p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,856
bash
# How to execute system command in Erlang and get results using os:cmd/1? When I try to execute following command that returns error or doesn't exit on Windows - I always get empty list instead of error returned as string so for example: I get: ``` [] = os:cmd("blah"). ``` instead of something like ``` "command no...
I am not familiar with windows at all, but I'm sure, you should look [this](https://github.com/erlang/otp/blob/maint/lib/kernel/src/os.erl#L188). This is implementation `os:cmd/1` function. There is problem with `os:cmd/1`. This function doesn't let you know, was command execution successful or not, so you only have t...
25854447
Powershell New-ScheduledTaskTrigger recurring task with -RepetitionInterval
9
2014-09-15 18:26:13
<p>I'm finding the errors related to ScheduledTask cmdles give extremely cryptic errors. I want to schedule a test task to run every 1 minute and repeat forever. Here's what I'm trying, but no success: </p> <pre><code>cls #$Action = New-ScheduledTaskAction -Execute "e:\Scripts\TestClusteredTask.cmd" $DurationTimeSpan...
30,571
160,245
2017-03-20 10:20:01
25,857,004
12
2014-09-15 21:14:19
3,829,407
2014-09-17 14:07:49
https://stackoverflow.com/q/25854447
https://stackoverflow.com/a/25857004
<p>According to <a href="http://technet.microsoft.com/en-us/library/jj649821.aspx" rel="noreferrer">tech net</a> this is the dataset you are using</p> <pre><code>Parameter Set: Daily New-ScheduledTaskTrigger [-Daily] -At &lt;DateTime&gt; [-DaysInterval &lt;Int32&gt; ] [-RandomDelay &lt;TimeSpan&gt; ] [ &lt;CommonParam...
<p>According to <a href="http://technet.microsoft.com/en-us/library/jj649821.aspx" rel="noreferrer">tech net</a> this is the dataset you are using</p> <pre><code>Parameter Set: Daily New-ScheduledTaskTrigger [-Daily] -At &lt;DateTime&gt; [-DaysInterval &lt;Int32&gt; ] [-RandomDelay &lt;TimeSpan&gt; ] [ &lt;CommonParam...
526, 9299, 10997
eventtrigger, powershell, scheduled-tasks
<h1>Powershell New-ScheduledTaskTrigger recurring task with -RepetitionInterval</h1> <p>I'm finding the errors related to ScheduledTask cmdles give extremely cryptic errors. I want to schedule a test task to run every 1 minute and repeat forever. Here's what I'm trying, but no success: </p> <pre><code>cls #$Action = ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,857
bash
# Powershell New-ScheduledTaskTrigger recurring task with -RepetitionInterval I'm finding the errors related to ScheduledTask cmdles give extremely cryptic errors. I want to schedule a test task to run every 1 minute and repeat forever. Here's what I'm trying, but no success: ``` cls #$Action = New-ScheduledTaskActio...
According to [tech net](http://technet.microsoft.com/en-us/library/jj649821.aspx) this is the dataset you are using ``` Parameter Set: Daily New-ScheduledTaskTrigger [-Daily] -At <DateTime> [-DaysInterval <Int32> ] [-RandomDelay <TimeSpan> ] [ <CommonParameters>] ``` In your examples you are specifying `-RepetitionIn...
23418904
Why does `ls | cat` != `ls`?
9
2014-05-02 00:28:28
<p>Why is there a difference in output between these two commands:</p> <pre><code>ls | cat </code></pre> <hr> <pre><code>ls </code></pre> <p>The first one seems to separate filenames with a newline.</p> <p>This also applies to commands suc has <code>ls &gt; outfile</code>, and similar things.</p> <p>I'm on Mac OS...
736
1,127,635
2014-05-02 05:02:44
23,419,004
12
2014-05-02 00:39:29
77,567
2014-05-02 05:02:44
https://stackoverflow.com/q/23418904
https://stackoverflow.com/a/23419004
<p>The <code>ls</code> command checks the file type of its standard output. If it detects a “tty”, it emits multicolumn output. If it detects any other file type (like a disk file or a pipe), it emits single column output.</p> <p>Tty is short for teletype. In the old days, you would use an actual teletype to intera...
<p>The <code>ls</code> command checks the file type of its standard output. If it detects a “tty”, it emits multicolumn output. If it detects any other file type (like a disk file or a pipe), it emits single column output.</p> <p>Tty is short for teletype. In the old days, you would use an actual teletype to intera...
34, 387, 390
bash, shell, unix
<h1>Why does `ls | cat` != `ls`?</h1> <p>Why is there a difference in output between these two commands:</p> <pre><code>ls | cat </code></pre> <hr> <pre><code>ls </code></pre> <p>The first one seems to separate filenames with a newline.</p> <p>This also applies to commands suc has <code>ls &gt; outfile</code>, and...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,858
bash
# Why does `ls | cat` != `ls`? Why is there a difference in output between these two commands: ``` ls | cat ``` --- ``` ls ``` The first one seems to separate filenames with a newline. This also applies to commands suc has `ls > outfile`, and similar things. I'm on Mac OSX, if that makes any difference.
The `ls` command checks the file type of its standard output. If it detects a “tty”, it emits multicolumn output. If it detects any other file type (like a disk file or a pipe), it emits single column output. Tty is short for teletype. In the old days, you would use an actual teletype to interact with a Unix system. S...
23119506
Use Powershell to run Psexec command
9
2014-04-16 20:28:28
<p>First post so please don't hurt me. I've searched around but can't seem to find a way to do what I want. I've made a script that copies a folder I have to numerous computers at \$computer\c$. In these folders is a batch file that runs an .exe. What I want to do is have Powershell pull from the same computers.txt tha...
90,873
3,542,845
2022-10-12 16:55:05
23,120,034
12
2014-04-16 21:00:52
3,245,749
2014-04-16 21:33:53
https://stackoverflow.com/q/23119506
https://stackoverflow.com/a/23120034
<p>Ok, let's take it from the top then.</p> <pre><code>$computers = gc "C:\scripts\computers.txt" </code></pre> <p>That loads the contents of the "computers.txt" file into the variable <code>$computers</code>. Simple enough, no issues there.</p> <p>Next we have a ForEach loop. It splits up the contents of <code>$com...
<p>Ok, let's take it from the top then.</p> <pre><code>$computers = gc "C:\scripts\computers.txt" </code></pre> <p>That loads the contents of the "computers.txt" file into the variable <code>$computers</code>. Simple enough, no issues there.</p> <p>Next we have a ForEach loop. It splits up the contents of <code>$com...
526, 7002, 16067
batch-file, powershell, psexec
<h1>Use Powershell to run Psexec command</h1> <p>First post so please don't hurt me. I've searched around but can't seem to find a way to do what I want. I've made a script that copies a folder I have to numerous computers at \$computer\c$. In these folders is a batch file that runs an .exe. What I want to do is have P...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,859
bash
# Use Powershell to run Psexec command First post so please don't hurt me. I've searched around but can't seem to find a way to do what I want. I've made a script that copies a folder I have to numerous computers at \$computer\c$. In these folders is a batch file that runs an .exe. What I want to do is have Powershell...
Ok, let's take it from the top then. ``` $computers = gc "C:\scripts\computers.txt" ``` That loads the contents of the "computers.txt" file into the variable `$computers`. Simple enough, no issues there. Next we have a ForEach loop. It splits up the contents of `$computers` and processes each line (presumably the na...
21002919
Running a remote PowerShell script with a Git command in it results in NativeCommandError
9
2014-01-08 17:50:04
<p>I am getting an error while executing a remote PowerShell script. From my local machine I am running a PowerShell script that uses <code>Invoke-Command</code> to <code>cd</code> into a directory on a remote Amazon Windows Server instance, and a subsequent <code>Invoke-Command</code> to execute script that lives on t...
11,229
3,174,479
2014-01-08 19:11:41
21,003,410
12
2014-01-08 18:13:49
null
2014-01-08 18:58:14
https://stackoverflow.com/q/21002919
https://stackoverflow.com/a/21003410
<p>Anytime you're calling an external executable from PowerShell, I highly recommend using <code>Start-Process</code>. The <code>Start-Process</code> cmdlet handles command line arguments much better, as compared to calling the executables directly.</p> <p><strong>Important</strong>: You must also be aware that if you...
<p>Anytime you're calling an external executable from PowerShell, I highly recommend using <code>Start-Process</code>. The <code>Start-Process</code> cmdlet handles command line arguments much better, as compared to calling the executables directly.</p> <p><strong>Important</strong>: You must also be aware that if you...
64, 119, 526
git, powershell, windows
<h1>Running a remote PowerShell script with a Git command in it results in NativeCommandError</h1> <p>I am getting an error while executing a remote PowerShell script. From my local machine I am running a PowerShell script that uses <code>Invoke-Command</code> to <code>cd</code> into a directory on a remote Amazon Wind...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,860
bash
# Running a remote PowerShell script with a Git command in it results in NativeCommandError I am getting an error while executing a remote PowerShell script. From my local machine I am running a PowerShell script that uses `Invoke-Command` to `cd` into a directory on a remote Amazon Windows Server instance, and a subs...
Anytime you're calling an external executable from PowerShell, I highly recommend using `Start-Process`. The `Start-Process` cmdlet handles command line arguments much better, as compared to calling the executables directly. **Important**: You must also be aware that if you run two separate `Invoke-Command` commands (...
17076342
bash: run a script with set -e (errexit)
9
2013-06-12 22:17:37
<p>Is there a way to run a bash script with <code>set -e</code>, i.e., as if <code>set -e</code> were in the first line of the script? I know there is for example <code>bash -x</code> to emulate <code>set -x</code>, but I didn't see anything to emulate <code>set -e</code>.</p>
10,272
161,801
2013-06-12 22:22:03
17,076,387
12
2013-06-12 22:22:03
1,126,841
2013-06-12 22:22:03
https://stackoverflow.com/q/17076342
https://stackoverflow.com/a/17076387
<p><code>bash</code> can use any of the options that are valid with <code>set</code> as a command line option, so you can simply use</p> <pre><code>bash -e myScript </code></pre> <p>Here's the first sentence from the Options section of the man page (emphasis mine; I know I glossed over this sentence for a long time a...
<p><code>bash</code> can use any of the options that are valid with <code>set</code> as a command line option, so you can simply use</p> <pre><code>bash -e myScript </code></pre> <p>Here's the first sentence from the Options section of the man page (emphasis mine; I know I glossed over this sentence for a long time a...
387
bash
<h1>bash: run a script with set -e (errexit)</h1> <p>Is there a way to run a bash script with <code>set -e</code>, i.e., as if <code>set -e</code> were in the first line of the script? I know there is for example <code>bash -x</code> to emulate <code>set -x</code>, but I didn't see anything to emulate <code>set -e</cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,861
bash
# bash: run a script with set -e (errexit) Is there a way to run a bash script with `set -e`, i.e., as if `set -e` were in the first line of the script? I know there is for example `bash -x` to emulate `set -x`, but I didn't see anything to emulate `set -e`.
`bash` can use any of the options that are valid with `set` as a command line option, so you can simply use ``` bash -e myScript ``` Here's the first sentence from the Options section of the man page (emphasis mine; I know I glossed over this sentence for a long time as well): > In addition to the single-character s...
16120155
Bad array subscript
9
2013-04-20 12:06:49
<p>I'm relatively new to Shell and I've been trying to use arrays in Shell and it's not working well. I'm trying to write a script to suspend OpenVZ containers should they hit a certain bandwidth threshold over a period of time.</p> <p>My script:</p> <pre><code>#!/bin/bash #Thresholds are in bytes per second and coun...
60,782
1,429,555
2013-04-20 12:28:58
16,120,366
12
2013-04-20 12:28:58
418,413
2013-04-20 12:28:58
https://stackoverflow.com/q/16120155
https://stackoverflow.com/a/16120366
<p>So on line 38,</p> <pre><code>if (( times[$i] &gt; times[$i - 1] + $SECS + 10 )) </code></pre> <p>would refer to <code>times[-1]</code> once during the iteration. Negative indices are <a href="https://stackoverflow.com/a/16110069/418413">only very recently part of bash arrays</a>, so that is most likely why you ar...
<p>So on line 38,</p> <pre><code>if (( times[$i] &gt; times[$i - 1] + $SECS + 10 )) </code></pre> <p>would refer to <code>times[-1]</code> once during the iteration. Negative indices are <a href="https://stackoverflow.com/a/16110069/418413">only very recently part of bash arrays</a>, so that is most likely why you ar...
114, 387, 390
arrays, bash, shell
<h1>Bad array subscript</h1> <p>I'm relatively new to Shell and I've been trying to use arrays in Shell and it's not working well. I'm trying to write a script to suspend OpenVZ containers should they hit a certain bandwidth threshold over a period of time.</p> <p>My script:</p> <pre><code>#!/bin/bash #Thresholds are...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,862
bash
# Bad array subscript I'm relatively new to Shell and I've been trying to use arrays in Shell and it's not working well. I'm trying to write a script to suspend OpenVZ containers should they hit a certain bandwidth threshold over a period of time. My script: ``` #!/bin/bash #Thresholds are in bytes per second and co...
So on line 38, ``` if (( times[$i] > times[$i - 1] + $SECS + 10 )) ``` would refer to `times[-1]` once during the iteration. Negative indices are [only very recently part of bash arrays](https://stackoverflow.com/a/16110069/418413), so that is most likely why you are getting the error. Likewise with lines 54 and 67 ...
15815840
Is it possible to display the progress of a sort in linux?
9
2013-04-04 15:46:28
<p>My job involves a lot of sorting fields from very large files. I usually do this with the <code>sort</code> command in bash. Unfortunately, when I start a sort I am never really sure how long it is going to take. Should I wait a second for the results to appear, or should I start working on something else while it r...
3,507
446,554
2014-08-20 11:10:56
15,816,070
12
2013-04-04 15:59:05
166,749
2014-08-20 11:10:56
https://stackoverflow.com/q/15815840
https://stackoverflow.com/a/15816070
<p>No, GNU <code>sort</code> does not do progress reporting.</p> <p>However, if are you using <code>sort</code> just to remove duplicates, and you don't actually care about the ordering, then there's a <a href="http://www.catonmat.net/blog/wp-content/uploads/2008/09/awk1line.txt" rel="noreferrer">more scalable way</a>...
<p>No, GNU <code>sort</code> does not do progress reporting.</p> <p>However, if are you using <code>sort</code> just to remove duplicates, and you don't actually care about the ordering, then there's a <a href="http://www.catonmat.net/blog/wp-content/uploads/2008/09/awk1line.txt" rel="noreferrer">more scalable way</a>...
58, 134, 387
bash, linux, sorting
<h1>Is it possible to display the progress of a sort in linux?</h1> <p>My job involves a lot of sorting fields from very large files. I usually do this with the <code>sort</code> command in bash. Unfortunately, when I start a sort I am never really sure how long it is going to take. Should I wait a second for the resul...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,863
bash
# Is it possible to display the progress of a sort in linux? My job involves a lot of sorting fields from very large files. I usually do this with the `sort` command in bash. Unfortunately, when I start a sort I am never really sure how long it is going to take. Should I wait a second for the results to appear, or sho...
No, GNU `sort` does not do progress reporting. However, if are you using `sort` just to remove duplicates, and you don't actually care about the ordering, then there's a [more scalable way](http://www.catonmat.net/blog/wp-content/uploads/2008/09/awk1line.txt) of doing that: ``` awk '! a[$0]++' ``` This writes out th...
15182577
Run parallel Invoke-WebRequest jobs in PowerShell v3
9
2013-03-03 04:54:56
<p>Running simultaneous background jobs in PowerShell in pretty straightforward, but I cannot seem to get it working with the new (in v3) cmdlet Invoke-WebRequest.</p> <p>I have several thousand files I am downloading scriptomagically via PowerShell. Works great, but doing them in series is taking days:</p> <pre><co...
17,793
2,009,405
2013-12-22 19:15:10
15,182,694
12
2013-03-03 05:16:14
153,982
2013-03-03 05:16:14
https://stackoverflow.com/q/15182577
https://stackoverflow.com/a/15182694
<p>You need to pass in the parameters in such as way that they actually make it into the job. In V3, you can use the $using: syntax to do this:</p> <pre><code>for($f=0;$f -lt $urlList.Count;$f++) { $remote = $urlList[$f] + $fileList[$f] $local = 'C:\folder\' + $fileList[$f] Start-Job {Invoke-WebRequest $us...
<p>You need to pass in the parameters in such as way that they actually make it into the job. In V3, you can use the $using: syntax to do this:</p> <pre><code>for($f=0;$f -lt $urlList.Count;$f++) { $remote = $urlList[$f] + $fileList[$f] $local = 'C:\folder\' + $fileList[$f] Start-Job {Invoke-WebRequest $us...
526, 8109, 15292, 73157, 153947
background-process, download, powershell, powershell-3.0, powershell-cmdlet
<h1>Run parallel Invoke-WebRequest jobs in PowerShell v3</h1> <p>Running simultaneous background jobs in PowerShell in pretty straightforward, but I cannot seem to get it working with the new (in v3) cmdlet Invoke-WebRequest.</p> <p>I have several thousand files I am downloading scriptomagically via PowerShell. Works...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,864
bash
# Run parallel Invoke-WebRequest jobs in PowerShell v3 Running simultaneous background jobs in PowerShell in pretty straightforward, but I cannot seem to get it working with the new (in v3) cmdlet Invoke-WebRequest. I have several thousand files I am downloading scriptomagically via PowerShell. Works great, but doing...
You need to pass in the parameters in such as way that they actually make it into the job. In V3, you can use the $using: syntax to do this: ``` for($f=0;$f -lt $urlList.Count;$f++) { $remote = $urlList[$f] + $fileList[$f] $local = 'C:\folder\' + $fileList[$f] Start-Job {Invoke-WebRequest $using:remote -Me...
14598583
find file names that return success on -exec command
9
2013-01-30 07:18:15
<p>I am using find to find names of databases that return some rows for a query.</p> <pre><code>$ find . -name 'sqlite.db' -exec sqlite3 "{}" 'SELECT * FROM table WHERE column1="value"' \; value|a|b|c|d </code></pre> <p>But I want the name of the database, so I tried -print which showed all the names</p> <pre><cod...
5,164
786,691
2014-05-02 00:49:26
14,611,634
12
2013-01-30 18:57:38
140,750
2013-01-30 18:57:38
https://stackoverflow.com/q/14598583
https://stackoverflow.com/a/14611634
<p>You just need to <code>-print</code> after the <code>-exec</code>. It is a short circuiting boolean <code>and</code>, and by putting <code>-print</code> before <code>-exec</code>, the print happens before the exec does. </p> <pre><code>find . -name sqlite.db -exec ... \; -print </code></pre>
<p>You just need to <code>-print</code> after the <code>-exec</code>. It is a short circuiting boolean <code>and</code>, and by putting <code>-print</code> before <code>-exec</code>, the print happens before the exec does. </p> <pre><code>find . -name sqlite.db -exec ... \; -print </code></pre>
34, 58, 387, 10193
bash, find, linux, unix
<h1>find file names that return success on -exec command</h1> <p>I am using find to find names of databases that return some rows for a query.</p> <pre><code>$ find . -name 'sqlite.db' -exec sqlite3 "{}" 'SELECT * FROM table WHERE column1="value"' \; value|a|b|c|d </code></pre> <p>But I want the name of the databas...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,865
bash
# find file names that return success on -exec command I am using find to find names of databases that return some rows for a query. ``` $ find . -name 'sqlite.db' -exec sqlite3 "{}" 'SELECT * FROM table WHERE column1="value"' \; value|a|b|c|d ``` But I want the name of the database, so I tried -print which showed...
You just need to `-print` after the `-exec`. It is a short circuiting boolean `and`, and by putting `-print` before `-exec`, the print happens before the exec does. ``` find . -name sqlite.db -exec ... \; -print ```
14560796
bash aliases and awk escaping of quotes
9
2013-01-28 11:14:20
<p>I'm trying to create an alias for a command to see the memory use,</p> <pre><code>ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}' </code></pre> <p>but, the naive,</p> <pre><code>#.bash_aliases alias totalmem='ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {prin...
7,548
218,558
2022-09-01 15:13:11
14,560,889
12
2013-01-28 11:20:14
1,331,399
2016-06-06 15:04:15
https://stackoverflow.com/q/14560796
https://stackoverflow.com/a/14560889
<p>You almost have it, the <code>$</code> will be expanded in double-quotes, so that needs extra escaping:</p> <pre><code>alias totalmem='ps -u user -o rss,command | grep -v peruser | awk "{sum+=\$1} END {print sum/1024}"' </code></pre> <p>Or with the pattern inside <code>awk</code> as suggested by <em>iiSeymour</em>...
<p>You almost have it, the <code>$</code> will be expanded in double-quotes, so that needs extra escaping:</p> <pre><code>alias totalmem='ps -u user -o rss,command | grep -v peruser | awk "{sum+=\$1} END {print sum/1024}"' </code></pre> <p>Or with the pattern inside <code>awk</code> as suggested by <em>iiSeymour</em>...
387, 990, 1448, 58076
alias, awk, bash, quote
<h1>bash aliases and awk escaping of quotes</h1> <p>I'm trying to create an alias for a command to see the memory use,</p> <pre><code>ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}' </code></pre> <p>but, the naive,</p> <pre><code>#.bash_aliases alias totalmem='ps -u user -o rss,com...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,866
bash
# bash aliases and awk escaping of quotes I'm trying to create an alias for a command to see the memory use, ``` ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}' ``` but, the naive, ``` #.bash_aliases alias totalmem='ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END ...
You almost have it, the `$` will be expanded in double-quotes, so that needs extra escaping: ``` alias totalmem='ps -u user -o rss,command | grep -v peruser | awk "{sum+=\$1} END {print sum/1024}"' ``` Or with the pattern inside `awk` as suggested by *iiSeymour*: ``` alias totalmem='ps -u user -o rss,command | awk "...
13760795
How to Pass PSCredential object from C# code to Powershell Function
9
2012-12-07 10:00:07
<p>I have a PSCredential Object in C# and want to pass it as parameter for this PowerShell Script</p> <p>This is the PSCredential Object</p> <pre><code> PSCredential Credential = new PSCredential ( "bla" , blasecurestring) </code></pre> <p>This is the Script I want to run in C#</p> <pre><code>powershell.AddScrip...
16,431
1,740,630
2012-12-14 09:50:50
13,876,081
12
2012-12-14 09:43:15
1,740,630
2012-12-14 09:50:50
https://stackoverflow.com/q/13760795
https://stackoverflow.com/a/13876081
<p>I found the solution now. It's so easy when you know what you do...</p> <pre><code>powershell.AddCommand("Set-Variable"); powershell.AddParameter("Name", "cred"); powershell.AddParameter("Value", Credential); powershell.AddScript(@"$s = New-PSSession -ComputerName '" + serverName + "' -Credential $cred"); powershe...
<p>I found the solution now. It's so easy when you know what you do...</p> <pre><code>powershell.AddCommand("Set-Variable"); powershell.AddParameter("Name", "cred"); powershell.AddParameter("Value", Credential); powershell.AddScript(@"$s = New-PSSession -ComputerName '" + serverName + "' -Credential $cred"); powershe...
9, 526
c#, powershell
<h1>How to Pass PSCredential object from C# code to Powershell Function</h1> <p>I have a PSCredential Object in C# and want to pass it as parameter for this PowerShell Script</p> <p>This is the PSCredential Object</p> <pre><code> PSCredential Credential = new PSCredential ( "bla" , blasecurestring) </code></pre> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,867
bash
# How to Pass PSCredential object from C# code to Powershell Function I have a PSCredential Object in C# and want to pass it as parameter for this PowerShell Script This is the PSCredential Object ``` PSCredential Credential = new PSCredential ( "bla" , blasecurestring) ``` This is the Script I want to run in C...
I found the solution now. It's so easy when you know what you do... ``` powershell.AddCommand("Set-Variable"); powershell.AddParameter("Name", "cred"); powershell.AddParameter("Value", Credential); powershell.AddScript(@"$s = New-PSSession -ComputerName '" + serverName + "' -Credential $cred"); powershell.AddScript(@...
12535766
Store PostgreSQL query result to Shell or PostgreSQL variable
9
2012-09-21 18:01:40
<p>For instance, I have a table stores value:</p> <pre><code>select * from myvalue; val ------- 12345 (1 row) </code></pre> <p>How can I save this <code>12345</code> into a variable in postgresql or shell script?</p> <p>Here's what I tried in my shell script:</p> <pre><code>var=$(psql -h host -U user -d db &lt;...
18,559
1,021,602
2018-08-02 20:18:46
12,535,875
12
2012-09-21 18:08:13
1,673,397
2015-08-26 13:47:03
https://stackoverflow.com/q/12535766
https://stackoverflow.com/a/12535875
<p>No, no, no! Use "raw data" switch from psql, like "-t" or "\t" and pipe the query to psql instead of parsing ascii-table, come on :-)</p> <pre><code>echo 'select * from myvalue;' | psql -t -h host -U user -d db </code></pre> <p>If you really need parse psql output, you could also use -H switch ( turns on HTML outp...
<p>No, no, no! Use "raw data" switch from psql, like "-t" or "\t" and pipe the query to psql instead of parsing ascii-table, come on :-)</p> <pre><code>echo 'select * from myvalue;' | psql -t -h host -U user -d db </code></pre> <p>If you really need parse psql output, you could also use -H switch ( turns on HTML outp...
256, 390
postgresql, shell
<h1>Store PostgreSQL query result to Shell or PostgreSQL variable</h1> <p>For instance, I have a table stores value:</p> <pre><code>select * from myvalue; val ------- 12345 (1 row) </code></pre> <p>How can I save this <code>12345</code> into a variable in postgresql or shell script?</p> <p>Here's what I tried in...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,868
bash
# Store PostgreSQL query result to Shell or PostgreSQL variable For instance, I have a table stores value: ``` select * from myvalue; val ------- 12345 (1 row) ``` How can I save this `12345` into a variable in postgresql or shell script? Here's what I tried in my shell script: ``` var=$(psql -h host -U user -...
No, no, no! Use "raw data" switch from psql, like "-t" or "\t" and pipe the query to psql instead of parsing ascii-table, come on :-) ``` echo 'select * from myvalue;' | psql -t -h host -U user -d db ``` If you really need parse psql output, you could also use -H switch ( turns on HTML output ), and parse it with som...
10542694
Bash or vim alias/command to use a certain template when creating Python files?
9
2012-05-10 21:53:26
<p>I was wondering if it is possible to insert something in <code>.bashrc</code> or <code>.vimrc</code> so that whenever I create a new Python file via <code>vim</code> it automatically creates a file with this already inserted before I edit it:</p> <pre><code>#!/usr/bin/env python import sys if __name__ == '__main_...
692
613,973
2012-05-11 13:46:37
10,542,757
12
2012-05-10 21:59:02
1,282,240
2012-05-11 13:46:37
https://stackoverflow.com/q/10542694
https://stackoverflow.com/a/10542757
<p>Or if you want to avoid plugins:</p> <pre><code>autocmd bufnewfile *.py 0r /path/to/python_default.py </code></pre>
<p>Or if you want to avoid plugins:</p> <pre><code>autocmd bufnewfile *.py 0r /path/to/python_default.py </code></pre>
16, 370, 387
bash, python, vim
<h1>Bash or vim alias/command to use a certain template when creating Python files?</h1> <p>I was wondering if it is possible to insert something in <code>.bashrc</code> or <code>.vimrc</code> so that whenever I create a new Python file via <code>vim</code> it automatically creates a file with this already inserted bef...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,869
bash
# Bash or vim alias/command to use a certain template when creating Python files? I was wondering if it is possible to insert something in `.bashrc` or `.vimrc` so that whenever I create a new Python file via `vim` it automatically creates a file with this already inserted before I edit it: ``` #!/usr/bin/env python ...
Or if you want to avoid plugins: ``` autocmd bufnewfile *.py 0r /path/to/python_default.py ```
10342018
basic shell programming
9
2012-04-26 21:58:39
<p>Probably this is a very basic question for shell programmers. But suppose I have a text file A and B and B is a subset of A.</p> <p>I want to create a text file C which contains (A-B) data.</p> <p>So omit all the common lines .</p> <p>The line in files are numeric data: like</p> <pre><code>id , some aspect, othe...
271
902,885
2012-11-16 05:14:32
10,342,044
12
2012-04-26 22:00:26
836,738
2012-04-29 14:40:45
https://stackoverflow.com/q/10342018
https://stackoverflow.com/a/10342044
<p>Use <a href="http://linux.die.net/man/1/sort" rel="nofollow noreferrer"><code>sort</code></a> and <a href="http://ss64.com/bash/uniq.html" rel="nofollow noreferrer"><code>uniq</code></a></p> <pre><code>sort a b | uniq -u </code></pre> <p>If you want the lines that are the same between A and B, you can use <code>un...
<p>Use <a href="http://linux.die.net/man/1/sort" rel="nofollow noreferrer"><code>sort</code></a> and <a href="http://ss64.com/bash/uniq.html" rel="nofollow noreferrer"><code>uniq</code></a></p> <pre><code>sort a b | uniq -u </code></pre> <p>If you want the lines that are the same between A and B, you can use <code>un...
387, 390, 990
awk, bash, shell
<h1>basic shell programming</h1> <p>Probably this is a very basic question for shell programmers. But suppose I have a text file A and B and B is a subset of A.</p> <p>I want to create a text file C which contains (A-B) data.</p> <p>So omit all the common lines .</p> <p>The line in files are numeric data: like</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,870
bash
# basic shell programming Probably this is a very basic question for shell programmers. But suppose I have a text file A and B and B is a subset of A. I want to create a text file C which contains (A-B) data. So omit all the common lines . The line in files are numeric data: like ``` id , some aspect, other aspec....
Use [`sort`](http://linux.die.net/man/1/sort) and [`uniq`](http://ss64.com/bash/uniq.html) ``` sort a b | uniq -u ``` If you want the lines that are the same between A and B, you can use `uniq -d` ``` sort a b | uniq -d ``` This assumes of course that the data in A and B are *exactly* the same. There cannot be any ...
10230288
How can I fork two programs to the background using one line of bash and possibly an ampersand?
9
2012-04-19 14:28:17
<p>I have two programs that run indefinitely. I know I can fork one to the background then run the other by typing this at the command line:</p> <pre><code>&gt; program1 &amp; &gt; program2 &amp; </code></pre> <p>However, I'm lazy and don't want to hit enter, I just want to run them both immediately. But bash compl...
2,707
446,554
2012-04-19 19:39:13
10,230,452
12
2012-04-19 14:36:54
620,097
2012-04-19 14:36:54
https://stackoverflow.com/q/10230288
https://stackoverflow.com/a/10230452
<p>You leave out the ';' char, i.e.</p> <pre><code> program1 &amp; program2 &amp; </code></pre> <p>I hope this helps.</p>
<p>You leave out the ';' char, i.e.</p> <pre><code> program1 &amp; program2 &amp; </code></pre> <p>I hope this helps.</p>
387, 15292
background-process, bash
<h1>How can I fork two programs to the background using one line of bash and possibly an ampersand?</h1> <p>I have two programs that run indefinitely. I know I can fork one to the background then run the other by typing this at the command line:</p> <pre><code>&gt; program1 &amp; &gt; program2 &amp; </code></pre> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,871
bash
# How can I fork two programs to the background using one line of bash and possibly an ampersand? I have two programs that run indefinitely. I know I can fork one to the background then run the other by typing this at the command line: ``` > program1 & > program2 & ``` However, I'm lazy and don't want to hit enter, ...
You leave out the ';' char, i.e. ``` program1 & program2 & ``` I hope this helps.
10070415
Convert first letter of given file to lower case
9
2012-04-09 07:49:46
<p>I want to convert the 1st letter of each line to lower case up to the end of the file. How can I do this using shell scripting?</p> <p>I tried this:</p> <pre><code>plat=`echo $plat |cut -c1 |tr [:upper:] [:lower:]``echo $plat |cut -c2-` </code></pre> <p>but this converts only the first character to lower case.</p...
9,486
278,521
2017-09-20 13:44:01
10,070,504
12
2012-04-09 08:01:23
635,608
2012-04-09 08:01:23
https://stackoverflow.com/q/10070415
https://stackoverflow.com/a/10070504
<p>You can do that with <code>sed</code>:</p> <pre><code>sed -e 's/./\L&amp;/' Shell.txt </code></pre> <p>(Probably safer to do</p> <pre><code>sed -e 's/^./\L&amp;\E/' Shell.txt </code></pre> <p>if you ever want to extend this.)</p>
<p>You can do that with <code>sed</code>:</p> <pre><code>sed -e 's/./\L&amp;/' Shell.txt </code></pre> <p>(Probably safer to do</p> <pre><code>sed -e 's/^./\L&amp;\E/' Shell.txt </code></pre> <p>if you ever want to extend this.)</p>
58, 387, 390
bash, linux, shell
<h1>Convert first letter of given file to lower case</h1> <p>I want to convert the 1st letter of each line to lower case up to the end of the file. How can I do this using shell scripting?</p> <p>I tried this:</p> <pre><code>plat=`echo $plat |cut -c1 |tr [:upper:] [:lower:]``echo $plat |cut -c2-` </code></pre> <p>bu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,872
bash
# Convert first letter of given file to lower case I want to convert the 1st letter of each line to lower case up to the end of the file. How can I do this using shell scripting? I tried this: ``` plat=`echo $plat |cut -c1 |tr [:upper:] [:lower:]``echo $plat |cut -c2-` ``` but this converts only the first character...
You can do that with `sed`: ``` sed -e 's/./\L&/' Shell.txt ``` (Probably safer to do ``` sed -e 's/^./\L&\E/' Shell.txt ``` if you ever want to extend this.)