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
36940073
Julia - run a script and keep the interpreter running
7
2016-04-29 13:47:38
<p>I am running a Julia script, but would like to have the interpreter keep itself open after the script is executed.</p> <p>E.g. when I run <code>julia example.jl</code>, I'd like the script to run and the interpreter to stay open after that, so I can experiment with the results.</p> <p>Is this possible?</p> <p>Tha...
1,369
4,829,548
2023-12-01 10:58:30
36,940,870
11
2016-04-29 14:26:22
176,071
2016-04-29 14:26:22
https://stackoverflow.com/q/36940073
https://stackoverflow.com/a/36940870
<p>Alternatively, you can just use the <code>-i</code> (interactive) flag. See <code>julia --help</code> for more details.</p> <pre><code>julia -i example.jl </code></pre> <p>Note, though, that the REPL won't start if the script errors.</p>
<p>Alternatively, you can just use the <code>-i</code> (interactive) flag. See <code>julia --help</code> for more details.</p> <pre><code>julia -i example.jl </code></pre> <p>Note, though, that the REPL won't start if the script errors.</p>
390, 1687, 77929
interpreter, julia, shell
<h1>Julia - run a script and keep the interpreter running</h1> <p>I am running a Julia script, but would like to have the interpreter keep itself open after the script is executed.</p> <p>E.g. when I run <code>julia example.jl</code>, I'd like the script to run and the interpreter to stay open after that, so I can exp...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,576
bash
# Julia - run a script and keep the interpreter running I am running a Julia script, but would like to have the interpreter keep itself open after the script is executed. E.g. when I run `julia example.jl`, I'd like the script to run and the interpreter to stay open after that, so I can experiment with the results. ...
Alternatively, you can just use the `-i` (interactive) flag. See `julia --help` for more details. ``` julia -i example.jl ``` Note, though, that the REPL won't start if the script errors.
36853564
Bash echo text into sudo file
7
2016-04-26 00:52:11
<p>I am trying to push some text into a file which requires <code>sudo</code>:</p> <pre><code>sudo echo "some text" &gt; /etc/path/to/file </code></pre> <p>But I keep getting the following error:</p> <pre><code>bash: /etc/path/to/file: Permission denied </code></pre> <p>I can do it with <code>nano</code>, but I kin...
4,435
1,157,242
2016-04-26 01:34:54
36,853,636
11
2016-04-26 01:03:05
3,789,550
2016-04-26 01:03:05
https://stackoverflow.com/q/36853564
https://stackoverflow.com/a/36853636
<p>Shell (<code>bash</code> in this case) does the redirection (<code>&gt;</code>) first before running the command. So <code>/etc/path/to/file</code> will be created before the command with <code>sudo</code> even runs and the normal user does not have sufficient permission to create the file <code>/etc/path/to/file</c...
<p>Shell (<code>bash</code> in this case) does the redirection (<code>&gt;</code>) first before running the command. So <code>/etc/path/to/file</code> will be created before the command with <code>sudo</code> even runs and the normal user does not have sufficient permission to create the file <code>/etc/path/to/file</c...
387, 1674, 5310
bash, file, sudo
<h1>Bash echo text into sudo file</h1> <p>I am trying to push some text into a file which requires <code>sudo</code>:</p> <pre><code>sudo echo "some text" &gt; /etc/path/to/file </code></pre> <p>But I keep getting the following error:</p> <pre><code>bash: /etc/path/to/file: Permission denied </code></pre> <p>I can ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,577
bash
# Bash echo text into sudo file I am trying to push some text into a file which requires `sudo`: ``` sudo echo "some text" > /etc/path/to/file ``` But I keep getting the following error: ``` bash: /etc/path/to/file: Permission denied ``` I can do it with `nano`, but I kind of need to do it programmatically. Is it ...
Shell (`bash` in this case) does the redirection (`>`) first before running the command. So `/etc/path/to/file` will be created before the command with `sudo` even runs and the normal user does not have sufficient permission to create the file `/etc/path/to/file`, hence the error message regarding permission. You can ...
36003519
How to map a long bash command in vim?
7
2016-03-15 05:46:48
<p>The shell command can kill chrome process.</p> <pre><code>ps -ef | grep chrome |awk '{print $2}'| xargs kill </code></pre> <p>Now I want to map the character <code>-</code> with above bash command.</p> <pre><code>nnoremap - :!ps -ef | grep chrome |awk '{print $2}'| xargs kill </code></pre> <p>It takes no effec...
680
1,982,032
2016-06-15 11:16:53
36,055,916
11
2016-03-17 09:07:40
1,028,589
2016-06-15 11:16:53
https://stackoverflow.com/q/36003519
https://stackoverflow.com/a/36055916
<h1>Escape the pipes</h1> <p>Every pipe has to be escaped. Then append it with <code>&lt;CR&gt;</code> so you don't have to press enter all the time.</p> <pre><code>nnoremap - :!ps -ef \| grep chrome \|awk '{print $2}'\| xargs kill&lt;CR&gt; </code></pre> <h1>Kill'Em All</h1> <p>Note also, that we have a cute littl...
<h1>Escape the pipes</h1> <p>Every pipe has to be escaped. Then append it with <code>&lt;CR&gt;</code> so you don't have to press enter all the time.</p> <pre><code>nnoremap - :!ps -ef \| grep chrome \|awk '{print $2}'\| xargs kill&lt;CR&gt; </code></pre> <h1>Kill'Em All</h1> <p>Note also, that we have a cute littl...
370, 390, 8632
call, shell, vim
<h1>How to map a long bash command in vim?</h1> <p>The shell command can kill chrome process.</p> <pre><code>ps -ef | grep chrome |awk '{print $2}'| xargs kill </code></pre> <p>Now I want to map the character <code>-</code> with above bash command.</p> <pre><code>nnoremap - :!ps -ef | grep chrome |awk '{print $2}'...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,578
bash
# How to map a long bash command in vim? The shell command can kill chrome process. ``` ps -ef | grep chrome |awk '{print $2}'| xargs kill ``` Now I want to map the character `-` with above bash command. ``` nnoremap - :!ps -ef | grep chrome |awk '{print $2}'| xargs kill ``` It takes no effect, how to map my bas...
# Escape the pipes Every pipe has to be escaped. Then append it with `<CR>` so you don't have to press enter all the time. ``` nnoremap - :!ps -ef \| grep chrome \|awk '{print $2}'\| xargs kill<CR> ``` # Kill'Em All Note also, that we have a cute little tool to kill'em all. So instead of ``` ps -ef | grep chrome |...
36036561
Syntax with pound and percent sign after shell parameter name
7
2016-03-16 13:06:09
<p>Please explain the following syntax:</p> <pre><code> i##*. i%.* </code></pre> <p>I understand what it's doing, but I want to know the general pattern (why/how is it doing so).</p> <p>Code where it appears:</p> <pre><code>#!/bin/bash recursive_name_change() { cd "$1" for i in * do #ech...
3,380
2,145,002
2016-03-16 16:05:32
36,036,707
11
2016-03-16 13:12:15
1,030,675
2016-03-16 13:17:56
https://stackoverflow.com/q/36036561
https://stackoverflow.com/a/36036707
<p>See <em>Parameter Expansion</em> in <code>man bash</code>:</p> <blockquote> <pre><code> ${parameter#word} ${parameter##word} </code></pre> <p>Remove matching prefix pattern. The word is expanded to produce a pattern just as in pathname expansion. If the pattern matches the beginning of t...
<p>See <em>Parameter Expansion</em> in <code>man bash</code>:</p> <blockquote> <pre><code> ${parameter#word} ${parameter##word} </code></pre> <p>Remove matching prefix pattern. The word is expanded to produce a pattern just as in pathname expansion. If the pattern matches the beginning of t...
58, 387, 390
bash, linux, shell
<h1>Syntax with pound and percent sign after shell parameter name</h1> <p>Please explain the following syntax:</p> <pre><code> i##*. i%.* </code></pre> <p>I understand what it's doing, but I want to know the general pattern (why/how is it doing so).</p> <p>Code where it appears:</p> <pre><code>#!/bin/bash r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,579
bash
# Syntax with pound and percent sign after shell parameter name Please explain the following syntax: ``` i##*. i%.* ``` I understand what it's doing, but I want to know the general pattern (why/how is it doing so). Code where it appears: ``` #!/bin/bash recursive_name_change() { cd "$1" for i in * ...
See *Parameter Expansion* in `man bash`: > ``` > ${parameter#word} > ${parameter##word} > ``` > > Remove matching prefix pattern. The word is expanded to produce a pattern just > as in pathname expansion. If the pattern matches the beginning of the value of > parameter, then the result of the expansion is the ex...
35464408
Windows: Elixir phoenix MIX_ENV=prod : The term is not recognized
7
2016-02-17 18:08:45
<p>Just started to learn elixir and phoenix framework. for the most part it going well. However when I want to run ecto.create on my production configs, I get an error in my cmd &amp; powershell that MIX_ENV=prod : The term is not recognized. Just in general though MIX_ENV=Xyz doesn't work for me.</p> <p>I've made a f...
2,301
5,800,159
2016-02-17 19:10:11
35,465,440
11
2016-02-17 19:03:26
69,527
2016-02-17 19:10:11
https://stackoverflow.com/q/35464408
https://stackoverflow.com/a/35465440
<p><code>MIX_ENV</code> is an environment variable and you just need to set it. Powershell does that differently than a *nix shell, so the examples that show putting <code>MIX_ENV=prod</code> in line with the mix command won't work.</p> <p>Use <code>$env:MIX_ENV="prod"</code> to set the environment variable and then c...
<p><code>MIX_ENV</code> is an environment variable and you just need to set it. Powershell does that differently than a *nix shell, so the examples that show putting <code>MIX_ENV=prod</code> in line with the mix command won't work.</p> <p>Use <code>$env:MIX_ENV="prod"</code> to set the environment variable and then c...
64, 526, 11878, 106806
elixir, phoenix-framework, powershell, windows
<h1>Windows: Elixir phoenix MIX_ENV=prod : The term is not recognized</h1> <p>Just started to learn elixir and phoenix framework. for the most part it going well. However when I want to run ecto.create on my production configs, I get an error in my cmd &amp; powershell that MIX_ENV=prod : The term is not recognized. Ju...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,580
bash
# Windows: Elixir phoenix MIX_ENV=prod : The term is not recognized Just started to learn elixir and phoenix framework. for the most part it going well. However when I want to run ecto.create on my production configs, I get an error in my cmd & powershell that MIX_ENV=prod : The term is not recognized. Just in general...
`MIX_ENV` is an environment variable and you just need to set it. Powershell does that differently than a *nix shell, so the examples that show putting `MIX_ENV=prod` in line with the mix command won't work. Use `$env:MIX_ENV="prod"` to set the environment variable and then call the rest of the mix command line.
34969408
Path substitution with sed and shell variables on OS X
7
2016-01-23 22:01:47
<p>I am on Mac OS X and using sed for an in-place replacement. </p> <p>Essentially I have this:</p> <pre><code>#!/bin/sh -e PREFIX="$1" sed -i bak -e 's|OCAMLDIR|"${PREFIX}"|g' ocamloptrev </code></pre> <p>Where <code>PREFIX</code> is a path, hence I'm using the <code>|</code>. </p> <p>Unfortunately, the variable ...
6,969
null
2016-01-23 22:29:35
34,969,456
11
2016-01-23 22:05:45
145,279
2016-01-23 22:29:35
https://stackoverflow.com/q/34969408
https://stackoverflow.com/a/34969456
<p>Try this:</p> <pre><code>#!/bin/sh -e PREFIX=&quot;$1&quot; sed -i bak -e 's|OCAMLDIR|'&quot;${PREFIX}&quot;'|g' ocamloptrev </code></pre> <p>What you're basically doing, is &quot;exiting&quot;/getting outside the single-quoted string, entering into a double-quoted string, interpreting the variable inside double-qu...
<p>Try this:</p> <pre><code>#!/bin/sh -e PREFIX=&quot;$1&quot; sed -i bak -e 's|OCAMLDIR|'&quot;${PREFIX}&quot;'|g' ocamloptrev </code></pre> <p>What you're basically doing, is &quot;exiting&quot;/getting outside the single-quoted string, entering into a double-quoted string, interpreting the variable inside double-qu...
390, 5282, 25968
sed, shell, string-interpolation
<h1>Path substitution with sed and shell variables on OS X</h1> <p>I am on Mac OS X and using sed for an in-place replacement. </p> <p>Essentially I have this:</p> <pre><code>#!/bin/sh -e PREFIX="$1" sed -i bak -e 's|OCAMLDIR|"${PREFIX}"|g' ocamloptrev </code></pre> <p>Where <code>PREFIX</code> is a path, hence I'm...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,581
bash
# Path substitution with sed and shell variables on OS X I am on Mac OS X and using sed for an in-place replacement. Essentially I have this: ``` #!/bin/sh -e PREFIX="$1" sed -i bak -e 's|OCAMLDIR|"${PREFIX}"|g' ocamloptrev ``` Where `PREFIX` is a path, hence I'm using the `|`. Unfortunately, the variable in the ...
Try this: ``` #!/bin/sh -e PREFIX="$1" sed -i bak -e 's|OCAMLDIR|'"${PREFIX}"'|g' ocamloptrev ``` What you're basically doing, is "exiting"/getting outside the single-quoted string, entering into a double-quoted string, interpreting the variable inside double-quotes, and then entering the single quotes again. With ...
34293139
How to run Odoo ORM methods in the python console?
7
2015-12-15 15:31:07
<p>I would like to use ORM methods such as <code>browse</code> or <code>search</code> in the python console. </p> <pre><code>$pwd /opt/odoo/ $python &gt;&gt;&gt; import openerp &gt;&gt;&gt; product_obj = pool.get('product.product) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; Nam...
6,462
1,163,438
2016-10-14 20:25:28
34,293,569
11
2015-12-15 15:51:22
1,362,167
2015-12-15 15:51:22
https://stackoverflow.com/q/34293139
https://stackoverflow.com/a/34293569
<p>In version 9 you can start an odoo shell with <code>odoo.py shell -d &lt;database&gt;</code>, thanks to <a href="https://github.com/odoo/odoo/commit/9ed13353c0d5f6b8a9684e612514b3b834642554" rel="noreferrer">this commit</a></p> <p>In version 8 the functionality is not builtin but you can use <a href="https://gist.g...
<p>In version 9 you can start an odoo shell with <code>odoo.py shell -d &lt;database&gt;</code>, thanks to <a href="https://github.com/odoo/odoo/commit/9ed13353c0d5f6b8a9684e612514b3b834642554" rel="noreferrer">this commit</a></p> <p>In version 8 the functionality is not builtin but you can use <a href="https://gist.g...
16, 390, 432, 105140
import, odoo, python, shell
<h1>How to run Odoo ORM methods in the python console?</h1> <p>I would like to use ORM methods such as <code>browse</code> or <code>search</code> in the python console. </p> <pre><code>$pwd /opt/odoo/ $python &gt;&gt;&gt; import openerp &gt;&gt;&gt; product_obj = pool.get('product.product) Traceback (most recent call...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,582
bash
# How to run Odoo ORM methods in the python console? I would like to use ORM methods such as `browse` or `search` in the python console. ``` $pwd /opt/odoo/ $python >>> import openerp >>> product_obj = pool.get('product.product) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name ...
In version 9 you can start an odoo shell with `odoo.py shell -d <database>`, thanks to [this commit](https://github.com/odoo/odoo/commit/9ed13353c0d5f6b8a9684e612514b3b834642554) In version 8 the functionality is not builtin but you can use [this script](https://gist.github.com/dreispt/d14e424540faedb3ea88), [this mod...
16284042
shortcut to replace all strings in previous bash command
7
2013-04-29 16:50:27
<p><code>man bash</code> describes a very useful <a href="https://www.gnu.org/software/bash/manual/bashref.html#Event-Designators" rel="noreferrer">Event Designator</a></p> <blockquote> <p>^string1^string2^</p> <p>Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to ''!!:s/string1/...
2,254
1,107,999
2015-12-10 16:23:38
34,206,850
11
2015-12-10 16:23:38
2,556,118
2015-12-10 16:23:38
https://stackoverflow.com/q/16284042
https://stackoverflow.com/a/34206850
<p><code>^string1^string2^:g&amp;</code></p> <p>See question <a href="https://superuser.com/a/940539/205301">Replace all occurrences of a word in the last command</a>.</p> <p>See <a href="https://www.gnu.org/software/bash/manual/html_node/Modifiers.html#Modifiers" rel="noreferrer">Modifiers</a> in <a href="https://ww...
<p><code>^string1^string2^:g&amp;</code></p> <p>See question <a href="https://superuser.com/a/940539/205301">Replace all occurrences of a word in the last command</a>.</p> <p>See <a href="https://www.gnu.org/software/bash/manual/html_node/Modifiers.html#Modifiers" rel="noreferrer">Modifiers</a> in <a href="https://ww...
387, 1231, 31134
bash, command-line, command-line-arguments
<h1>shortcut to replace all strings in previous bash command</h1> <p><code>man bash</code> describes a very useful <a href="https://www.gnu.org/software/bash/manual/bashref.html#Event-Designators" rel="noreferrer">Event Designator</a></p> <blockquote> <p>^string1^string2^</p> <p>Quick substitution. Repeat the last comm...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,583
bash
# shortcut to replace all strings in previous bash command `man bash` describes a very useful [Event Designator](https://www.gnu.org/software/bash/manual/bashref.html#Event-Designators) > ^string1^string2^ > > Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to ''!!:s/string1/st...
`^string1^string2^:g&` See question [Replace all occurrences of a word in the last command](https://superuser.com/a/940539/205301). See [Modifiers](https://www.gnu.org/software/bash/manual/html_node/Modifiers.html#Modifiers) in [History Expansion](https://www.gnu.org/software/bash/manual/html_node/History-Interaction...
33800565
How to store linux command output into a variable in puppet
7
2015-11-19 09:58:58
<p>Is it possible to store a linux command result in variable?</p> <p>I am trying to store an encrypted value in a variable. To encrypt I am using base64 command. To store it in variable, I am using generate method. But I am not able to store a value. </p> <pre><code>$secretvalue = generate("/bin/bash","-c","/usr/...
7,790
2,959,196
2015-11-24 11:40:07
33,842,527
11
2015-11-21 11:01:23
2,398,521
2015-11-21 11:16:29
https://stackoverflow.com/q/33800565
https://stackoverflow.com/a/33842527
<p>If you want to execute any command on Puppet Master server you can use <code>inline_template</code> function with ERB template inside and Ruby code for execute shell command:</p> <pre><code>$password = "12345" $secretvalue = inline_template("&lt;%= `/bin/echo ${password} | /usr/bin/base64` %&gt;") notify { "STDOU...
<p>If you want to execute any command on Puppet Master server you can use <code>inline_template</code> function with ERB template inside and Ruby code for execute shell command:</p> <pre><code>$password = "12345" $secretvalue = inline_template("&lt;%= `/bin/echo ${password} | /usr/bin/base64` %&gt;") notify { "STDOU...
58, 387, 10429, 108843
bash, linux, puppet, puppet-enterprise
<h1>How to store linux command output into a variable in puppet</h1> <p>Is it possible to store a linux command result in variable?</p> <p>I am trying to store an encrypted value in a variable. To encrypt I am using base64 command. To store it in variable, I am using generate method. But I am not able to store a value...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,584
bash
# How to store linux command output into a variable in puppet Is it possible to store a linux command result in variable? I am trying to store an encrypted value in a variable. To encrypt I am using base64 command. To store it in variable, I am using generate method. But I am not able to store a value. ``` $secretva...
If you want to execute any command on Puppet Master server you can use `inline_template` function with ERB template inside and Ruby code for execute shell command: ``` $password = "12345" $secretvalue = inline_template("<%= `/bin/echo ${password} | /usr/bin/base64` %>") notify { "STDOUT: ${secretvalue}": } ``` P.S....
33784892
Bash vs. Dash behavior with the command `echo -ne "hello\n"`
7
2015-11-18 16:08:59
<p>I got different behaviors with the same command <code>echo -ne "hello\n"</code> with bash and with dash. See below :</p> <pre><code>$ bash -c 'echo -ne "hello\n"' hello $ dash -c 'echo -ne "hello\n"' -ne hello </code></pre> <p>Why is that ? I don't understand at all…</p> <p>My system : </p> <pre><code>$ lsb_rele...
3,909
2,087,834
2023-11-13 04:45:03
33,785,069
11
2015-11-18 16:17:04
258,523
2015-11-18 16:17:04
https://stackoverflow.com/q/33784892
https://stackoverflow.com/a/33785069
<p>The POSIX specification for <code>echo</code> doesn't support any arguments. See it <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html" rel="noreferrer">here</a>.</p> <p>And while the spec mentions <code>-n</code> it does so to say that it is <em>not</em> an option and is either an impleme...
<p>The POSIX specification for <code>echo</code> doesn't support any arguments. See it <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html" rel="noreferrer">here</a>.</p> <p>And while the spec mentions <code>-n</code> it does so to say that it is <em>not</em> an option and is either an impleme...
387, 137448
bash, dash-shell
<h1>Bash vs. Dash behavior with the command `echo -ne "hello\n"`</h1> <p>I got different behaviors with the same command <code>echo -ne "hello\n"</code> with bash and with dash. See below :</p> <pre><code>$ bash -c 'echo -ne "hello\n"' hello $ dash -c 'echo -ne "hello\n"' -ne hello </code></pre> <p>Why is that ? I do...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,585
bash
# Bash vs. Dash behavior with the command `echo -ne "hello\n"` I got different behaviors with the same command `echo -ne "hello\n"` with bash and with dash. See below : ``` $ bash -c 'echo -ne "hello\n"' hello $ dash -c 'echo -ne "hello\n"' -ne hello ``` Why is that ? I don't understand at all… My system : ``` $ l...
The POSIX specification for `echo` doesn't support any arguments. See it [here](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html). And while the spec mentions `-n` it does so to say that it is *not* an option and is either an implementation defined case or to be treated as a string. So `dash` is do...
33320584
Bash: How to split a string and assign multiple variables
7
2015-10-24 16:35:15
<p>I have to split a URL string and assign variables to few of the splits. Here is the string</p> <pre><code>http://web.com/sub1/sub2/sub3/sub4/sub5/sub6 </code></pre> <p>I want to assign variables like below from bash</p> <pre><code>var1=sub2 var2=sub4 var3=sub5 </code></pre> <p>How to do this in bash?</p>
10,239
1,776,410
2018-09-27 04:23:35
33,320,662
11
2015-10-24 16:42:26
3,776,858
2018-09-27 04:23:35
https://stackoverflow.com/q/33320584
https://stackoverflow.com/a/33320662
<pre><code>x="http://web.com/sub1/sub2/sub3/sub4/sub5/sub6" IFS="/" read -r foo foo foo foo var1 foo var2 var3 foo &lt;&lt;&lt; "$x" echo "$var1 $var2 $var3" </code></pre> <p>Output:</p> <pre> sub2 sub4 sub5 </pre> <p>Or with an array:</p> <pre><code>x="http://web.com/sub1/sub2/sub3/sub4/sub5/sub6" IFS="/" read -r ...
<pre><code>x="http://web.com/sub1/sub2/sub3/sub4/sub5/sub6" IFS="/" read -r foo foo foo foo var1 foo var2 var3 foo &lt;&lt;&lt; "$x" echo "$var1 $var2 $var3" </code></pre> <p>Output:</p> <pre> sub2 sub4 sub5 </pre> <p>Or with an array:</p> <pre><code>x="http://web.com/sub1/sub2/sub3/sub4/sub5/sub6" IFS="/" read -r ...
387
bash
<h1>Bash: How to split a string and assign multiple variables</h1> <p>I have to split a URL string and assign variables to few of the splits. Here is the string</p> <pre><code>http://web.com/sub1/sub2/sub3/sub4/sub5/sub6 </code></pre> <p>I want to assign variables like below from bash</p> <pre><code>var1=sub2 var2=s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,586
bash
# Bash: How to split a string and assign multiple variables I have to split a URL string and assign variables to few of the splits. Here is the string ``` http://web.com/sub1/sub2/sub3/sub4/sub5/sub6 ``` I want to assign variables like below from bash ``` var1=sub2 var2=sub4 var3=sub5 ``` How to do this in bash?
``` x="http://web.com/sub1/sub2/sub3/sub4/sub5/sub6" IFS="/" read -r foo foo foo foo var1 foo var2 var3 foo <<< "$x" echo "$var1 $var2 $var3" ``` Output: ``` sub2 sub4 sub5 ``` Or with an array: ``` x="http://web.com/sub1/sub2/sub3/sub4/sub5/sub6" IFS="/" read -r -a var <<< "$x" echo "${var[4]}" declare -p var ``` ...
32388896
Creating Tables in Powershell
7
2015-09-04 01:49:38
<p>Guys I've got a script that queries services in remote computers. It runs 2 nested foreach loops, 1 for the computer list and the internal one for the services list. I want to capture the output of the process in a 2-dimensional array.</p> <pre><code>The desired output should be like this: Computer Service ...
104,378
5,298,999
2022-08-11 00:43:20
32,391,886
11
2015-09-04 06:56:39
4,568,320
2021-09-10 13:38:26
https://stackoverflow.com/q/32388896
https://stackoverflow.com/a/32391886
<p>Try This one:</p> <p>Using WMI because <code>Get-Service</code> missing the <code>StartupMode</code></p> <pre><code>$Array = @() $Computers = &quot;Computer1&quot;,&quot;Computer2&quot;,&quot;Computer3&quot; Foreach ($Computer in $Computers) { $Services = Get-WmiObject Win32_Service -ComputerName $Computer | Select...
<p>Try This one:</p> <p>Using WMI because <code>Get-Service</code> missing the <code>StartupMode</code></p> <pre><code>$Array = @() $Computers = &quot;Computer1&quot;,&quot;Computer2&quot;,&quot;Computer3&quot; Foreach ($Computer in $Computers) { $Services = Get-WmiObject Win32_Service -ComputerName $Computer | Select...
114, 526, 25430
arrays, multidimensional-array, powershell
<h1>Creating Tables in Powershell</h1> <p>Guys I've got a script that queries services in remote computers. It runs 2 nested foreach loops, 1 for the computer list and the internal one for the services list. I want to capture the output of the process in a 2-dimensional array.</p> <pre><code>The desired output shoul...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,587
bash
# Creating Tables in Powershell Guys I've got a script that queries services in remote computers. It runs 2 nested foreach loops, 1 for the computer list and the internal one for the services list. I want to capture the output of the process in a 2-dimensional array. ``` The desired output should be like this: Compu...
Try This one: Using WMI because `Get-Service` missing the `StartupMode` ``` $Array = @() $Computers = "Computer1","Computer2","Computer3" Foreach ($Computer in $Computers) { $Services = Get-WmiObject Win32_Service -ComputerName $Computer | Select name,state,startmode Foreach ($Service in $Services) { $Ro...
32125893
Running Batch Script on remote Server via PowerShell
7
2015-08-20 18:39:25
<p>I need to connect to some remote servers from a client (same domain as the servers) once connected, I need to run a batch file:</p> <p>I've done so with this code:</p> <pre><code>$Username = 'USER' $Password = 'PASSWORD' $pass = ConvertTo-SecureString -AsPlainText $Password -Force $Cred = New-Object System.Managem...
100,420
2,777,103
2022-07-20 09:39:40
32,126,136
11
2015-08-20 18:53:34
5,218,300
2015-08-20 18:53:34
https://stackoverflow.com/q/32125893
https://stackoverflow.com/a/32126136
<p>Try replacing </p> <pre><code>invoke-command -computername "SERVER1" -credential $Cred -ScriptBlock -ErrorAction stop { Start-Process "C:\Users\nithi.sundar\Desktop\Test.bat" } </code></pre> <p>with</p> <pre><code>Invoke-Command -ComputerName "Server1" -credential $cred -ErrorAction Stop -ScriptBlock {Invoke-Expr...
<p>Try replacing </p> <pre><code>invoke-command -computername "SERVER1" -credential $Cred -ScriptBlock -ErrorAction stop { Start-Process "C:\Users\nithi.sundar\Desktop\Test.bat" } </code></pre> <p>with</p> <pre><code>Invoke-Command -ComputerName "Server1" -credential $cred -ErrorAction Stop -ScriptBlock {Invoke-Expr...
526, 7002, 18556
batch-file, powershell, remote-server
<h1>Running Batch Script on remote Server via PowerShell</h1> <p>I need to connect to some remote servers from a client (same domain as the servers) once connected, I need to run a batch file:</p> <p>I've done so with this code:</p> <pre><code>$Username = 'USER' $Password = 'PASSWORD' $pass = ConvertTo-SecureString -...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,588
bash
# Running Batch Script on remote Server via PowerShell I need to connect to some remote servers from a client (same domain as the servers) once connected, I need to run a batch file: I've done so with this code: ``` $Username = 'USER' $Password = 'PASSWORD' $pass = ConvertTo-SecureString -AsPlainText $Password -Forc...
Try replacing ``` invoke-command -computername "SERVER1" -credential $Cred -ScriptBlock -ErrorAction stop { Start-Process "C:\Users\nithi.sundar\Desktop\Test.bat" } ``` with ``` Invoke-Command -ComputerName "Server1" -credential $cred -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\Users\n...
31919064
PowerShell: Get the MSI product code out of a MSI file without installing?
7
2015-08-10 12:04:12
<p>Is there a possibility to retreive the MSI product code out of a MSI file without installing it with PowerShell? I want to compare the product code of a MSI file with the MSI codes installed on a maschine to find out if the file was installed in the past.</p>
27,001
null
2024-02-22 11:53:47
31,919,297
11
2015-08-10 12:15:16
1,163,423
2022-06-06 08:46:37
https://stackoverflow.com/q/31919064
https://stackoverflow.com/a/31919297
<p>Here is a script that reads the product code based on [this article][1]:</p> <pre><code>$path = &quot;pathto.msi&quot; $comObjWI = New-Object -ComObject WindowsInstaller.Installer $MSIDatabase = $comObjWI.GetType().InvokeMember(&quot;OpenDatabase&quot;,&quot;InvokeMethod&quot;,$Null,$comObjWI,@($Path,0)) $Query = &...
<p>Here is a script that reads the product code based on [this article][1]:</p> <pre><code>$path = &quot;pathto.msi&quot; $comObjWI = New-Object -ComObject WindowsInstaller.Installer $MSIDatabase = $comObjWI.GetType().InvokeMember(&quot;OpenDatabase&quot;,&quot;InvokeMethod&quot;,$Null,$comObjWI,@($Path,0)) $Query = &...
526, 1914
powershell, windows-installer
<h1>PowerShell: Get the MSI product code out of a MSI file without installing?</h1> <p>Is there a possibility to retreive the MSI product code out of a MSI file without installing it with PowerShell? I want to compare the product code of a MSI file with the MSI codes installed on a maschine to find out if the file was ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,589
bash
# PowerShell: Get the MSI product code out of a MSI file without installing? Is there a possibility to retreive the MSI product code out of a MSI file without installing it with PowerShell? I want to compare the product code of a MSI file with the MSI codes installed on a maschine to find out if the file was installed...
Here is a script that reads the product code based on [this article][1]: ``` $path = "pathto.msi" $comObjWI = New-Object -ComObject WindowsInstaller.Installer $MSIDatabase = $comObjWI.GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$comObjWI,@($Path,0)) $Query = "SELECT Value FROM Property WHERE Property =...
31002558
How to get value from property in BeanShell (jmeter)
7
2015-06-23 12:15:55
<p>I have got several thread groups. I want to use variable from the first group. In second group this var should be used in BeanShell. So: in first thread group I created BeanShell Assertion with this code:</p> <pre><code> ${__setProperty(erroriden, ${erroriden1})}; </code></pre> <p>In second thread group I have Bea...
23,348
5,028,121
2015-06-23 13:35:54
31,004,310
11
2015-06-23 13:35:54
2,897,748
2015-06-23 13:35:54
https://stackoverflow.com/q/31002558
https://stackoverflow.com/a/31004310
<p>In the first Thread Group:</p> <pre><code>props.put("erroriden", vars.get("erroriden1")); </code></pre> <p>In the second Thread Group:</p> <pre><code>String[] erroriden = props.get("erroriden").split(","); </code></pre> <ul> <li><a href="https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.htm...
<p>In the first Thread Group:</p> <pre><code>props.put("erroriden", vars.get("erroriden1")); </code></pre> <p>In the second Thread Group:</p> <pre><code>String[] erroriden = props.get("erroriden").split(","); </code></pre> <ul> <li><a href="https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.htm...
276, 8401, 13554
beanshell, jmeter, variables
<h1>How to get value from property in BeanShell (jmeter)</h1> <p>I have got several thread groups. I want to use variable from the first group. In second group this var should be used in BeanShell. So: in first thread group I created BeanShell Assertion with this code:</p> <pre><code> ${__setProperty(erroriden, ${erro...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,590
bash
# How to get value from property in BeanShell (jmeter) I have got several thread groups. I want to use variable from the first group. In second group this var should be used in BeanShell. So: in first thread group I created BeanShell Assertion with this code: ``` ${__setProperty(erroriden, ${erroriden1})}; ``` In s...
In the first Thread Group: ``` props.put("erroriden", vars.get("erroriden1")); ``` In the second Thread Group: ``` String[] erroriden = props.get("erroriden").split(","); ``` - [JMeterVariables](https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html) scope is limited to the current thread grou...
30485004
Powershell convertfrom-json | convertto-csv
7
2015-05-27 14:09:56
<p>I have a JSON data structured as following (there may be some mistakes here, the data I'm using is fine):</p> <pre><code>[{ "id": 12345, "itemName": "some string", "sellerId": 123, "seller": "", "categoryId": , "categoryPath": [ { //more data }, { //more data } ]}, {"id": 12346, "itemName": "some oth...
13,149
3,665,534
2015-05-27 14:50:35
30,485,859
11
2015-05-27 14:45:18
3,829,407
2015-05-27 14:50:35
https://stackoverflow.com/q/30485004
https://stackoverflow.com/a/30485859
<p>In short you need to do something like this:</p> <pre><code>(Get-Content file.json -Raw | ConvertFrom-Json) | Select id,itemName,sellerId | Convertto-CSV -NoTypeInformation </code></pre> <p>The first problem was that <code>Get-Content</code> was passing individual lines to <code>ConvertFrom-Json</code> which is n...
<p>In short you need to do something like this:</p> <pre><code>(Get-Content file.json -Raw | ConvertFrom-Json) | Select id,itemName,sellerId | Convertto-CSV -NoTypeInformation </code></pre> <p>The first problem was that <code>Get-Content</code> was passing individual lines to <code>ConvertFrom-Json</code> which is n...
73, 526, 1508
csv, json, powershell
<h1>Powershell convertfrom-json | convertto-csv</h1> <p>I have a JSON data structured as following (there may be some mistakes here, the data I'm using is fine):</p> <pre><code>[{ "id": 12345, "itemName": "some string", "sellerId": 123, "seller": "", "categoryId": , "categoryPath": [ { //more data }, { //m...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,591
bash
# Powershell convertfrom-json | convertto-csv I have a JSON data structured as following (there may be some mistakes here, the data I'm using is fine): ``` [{ "id": 12345, "itemName": "some string", "sellerId": 123, "seller": "", "categoryId": , "categoryPath": [ { //more data }, { //more data } ]}, {"...
In short you need to do something like this: ``` (Get-Content file.json -Raw | ConvertFrom-Json) | Select id,itemName,sellerId | Convertto-CSV -NoTypeInformation ``` The first problem was that `Get-Content` was passing individual lines to `ConvertFrom-Json` which is not what it wants. Using the `-Raw` switch passes i...
30404863
Expression recursion level exceeded
7
2015-05-22 19:51:14
<p>Don't know why there is error in the following examples:</p> <pre><code>$ a=1; (( a &gt; 0 )) &amp;&amp; echo y || echo n </code></pre> <blockquote> <pre><code> y </code></pre> </blockquote> <pre><code>$ a=x; (( a &gt; 0 )) &amp;&amp; echo y || echo n </code></pre> <blockquote> <pre><code> n </code></pre> </blockquo...
7,782
2,847,598
2023-06-01 14:02:00
30,404,917
11
2015-05-22 19:55:07
418,413
2023-06-01 14:02:00
https://stackoverflow.com/q/30404863
https://stackoverflow.com/a/30404917
<pre><code>$ a=a ( no error ) $ declare -i a $ a=a -bash: ((: a: expression recursion level exceeded (error token is &quot;a&quot;) </code></pre> <p>This behavior is because <code>declare -i</code> puts the right-hand side of an assignment in arithmetic context. In arithmetic context, bash dereferences variable names t...
<pre><code>$ a=a ( no error ) $ declare -i a $ a=a -bash: ((: a: expression recursion level exceeded (error token is &quot;a&quot;) </code></pre> <p>This behavior is because <code>declare -i</code> puts the right-hand side of an assignment in arithmetic context. In arithmetic context, bash dereferences variable names t...
387, 5481
arithmetic-expressions, bash
<h1>Expression recursion level exceeded</h1> <p>Don't know why there is error in the following examples:</p> <pre><code>$ a=1; (( a &gt; 0 )) &amp;&amp; echo y || echo n </code></pre> <blockquote> <pre><code> y </code></pre> </blockquote> <pre><code>$ a=x; (( a &gt; 0 )) &amp;&amp; echo y || echo n </code></pre> <block...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,592
bash
# Expression recursion level exceeded Don't know why there is error in the following examples: ``` $ a=1; (( a > 0 )) && echo y || echo n ``` > ``` > y > ``` ``` $ a=x; (( a > 0 )) && echo y || echo n ``` > ``` > n > ``` ``` $ a=a; (( a > 0 )) && echo y || echo n ``` > ``` > -bash: ((: a: expression recursion...
``` $ a=a ( no error ) $ declare -i a $ a=a -bash: ((: a: expression recursion level exceeded (error token is "a") ``` This behavior is because `declare -i` puts the right-hand side of an assignment in arithmetic context. In arithmetic context, bash dereferences variable names to their values recursively. If the name ...
29810297
Command line arguments validation with GetOpts and mandatory parameters
7
2015-04-22 22:45:47
<p>I'm creating a basic script that should take 3 mandatory command line options and each one must be followed by a value. Like this:</p> <pre><code>$ myscript.sh -u &lt;username&gt; -p &lt;password&gt; -f &lt;hosts.txt&gt; </code></pre> <p>I'm trying to make sure the user is passing those exact 3 options and their v...
10,976
1,806,782
2015-04-22 23:12:06
29,810,398
11
2015-04-22 22:53:16
3,030,305
2015-04-22 23:12:06
https://stackoverflow.com/q/29810297
https://stackoverflow.com/a/29810398
<p><code>getopts</code> has no concept of "mandatory" options. The colons in <code>u:p:f:</code> mean that, if one of those options happens to be supplied, then an argument to that option is mandatory. The option-argument pairs, however, are always optional.</p> <p>You can require that the user provide all three tho...
<p><code>getopts</code> has no concept of "mandatory" options. The colons in <code>u:p:f:</code> mean that, if one of those options happens to be supplied, then an argument to that option is mandatory. The option-argument pairs, however, are always optional.</p> <p>You can require that the user provide all three tho...
58, 387, 19020, 103312
bash, getopts, linux, ubuntu-14.04
<h1>Command line arguments validation with GetOpts and mandatory parameters</h1> <p>I'm creating a basic script that should take 3 mandatory command line options and each one must be followed by a value. Like this:</p> <pre><code>$ myscript.sh -u &lt;username&gt; -p &lt;password&gt; -f &lt;hosts.txt&gt; </code></pre> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,593
bash
# Command line arguments validation with GetOpts and mandatory parameters I'm creating a basic script that should take 3 mandatory command line options and each one must be followed by a value. Like this: ``` $ myscript.sh -u <username> -p <password> -f <hosts.txt> ``` I'm trying to make sure the user is passing tho...
`getopts` has no concept of "mandatory" options. The colons in `u:p:f:` mean that, if one of those options happens to be supplied, then an argument to that option is mandatory. The option-argument pairs, however, are always optional. You can require that the user provide all three though with code such as: ``` if [ !...
29434916
Why is my Python script not writing to file when it is backgrounded it in Linux?
7
2015-04-03 15:16:18
<p>I can do:</p> <pre><code>python script.py &gt; logfile 2&gt;&amp;1 </code></pre> <p>and once I kill it using ctrl c I can see changes to the logfile. However, when I do:</p> <pre><code>python script.py &gt; logfile 2&gt;&amp;1 &amp; </code></pre> <p>I can't see any changes to the log file . How can I background ...
3,447
1,689,987
2023-09-20 09:28:03
29,434,961
11
2015-04-03 15:19:32
14,122
2015-04-03 15:19:32
https://stackoverflow.com/q/29434916
https://stackoverflow.com/a/29434961
<p>Your writes aren't going into the ether -- they're getting buffered. After a graceful shutdown (SIGTERM, not SIGKILL), you should see content in the file then as well.</p> <p>Alternately, you can explicitly flush:</p> <pre><code>sys.stdout.flush() </code></pre> <p>...or tell Python to run in unbuffered mode:</p> ...
<p>Your writes aren't going into the ether -- they're getting buffered. After a graceful shutdown (SIGTERM, not SIGKILL), you should see content in the file then as well.</p> <p>Alternately, you can explicitly flush:</p> <pre><code>sys.stdout.flush() </code></pre> <p>...or tell Python to run in unbuffered mode:</p> ...
16, 58, 387
bash, linux, python
<h1>Why is my Python script not writing to file when it is backgrounded it in Linux?</h1> <p>I can do:</p> <pre><code>python script.py &gt; logfile 2&gt;&amp;1 </code></pre> <p>and once I kill it using ctrl c I can see changes to the logfile. However, when I do:</p> <pre><code>python script.py &gt; logfile 2&gt;&amp...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,594
bash
# Why is my Python script not writing to file when it is backgrounded it in Linux? I can do: ``` python script.py > logfile 2>&1 ``` and once I kill it using ctrl c I can see changes to the logfile. However, when I do: ``` python script.py > logfile 2>&1 & ``` I can't see any changes to the log file . How can I ba...
Your writes aren't going into the ether -- they're getting buffered. After a graceful shutdown (SIGTERM, not SIGKILL), you should see content in the file then as well. Alternately, you can explicitly flush: ``` sys.stdout.flush() ``` ...or tell Python to run in unbuffered mode: ``` python -u yourscript.py ``` or s...
29211928
Change powershell Title on every command
7
2015-03-23 13:48:44
<p>I would like to display the last command that i have entered into powershell in the title of the window so that it is easier to find</p> <p>Currently I have:</p> <pre><code>C:\&gt; $host.ui.rawui.WindowTitle = $$ </code></pre> <p>but this just gets the previous command relative to when i enter it so if I have </p...
3,859
3,262,190
2025-03-24 07:44:51
29,213,095
11
2015-03-23 14:40:13
323,582
2015-03-23 14:40:13
https://stackoverflow.com/q/29211928
https://stackoverflow.com/a/29213095
<p>You can use your custom function <code>prompt</code> defined in your profile. For example:</p> <pre><code>function prompt { # get the last command from history $command = Get-History -Count 1 # set it to the window title if ($command) { $host.ui.rawui.WindowTitle = $command } # spe...
<p>You can use your custom function <code>prompt</code> defined in your profile. For example:</p> <pre><code>function prompt { # get the last command from history $command = Get-History -Count 1 # set it to the window title if ($command) { $host.ui.rawui.WindowTitle = $command } # spe...
526
powershell
<h1>Change powershell Title on every command</h1> <p>I would like to display the last command that i have entered into powershell in the title of the window so that it is easier to find</p> <p>Currently I have:</p> <pre><code>C:\&gt; $host.ui.rawui.WindowTitle = $$ </code></pre> <p>but this just gets the previous co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,595
bash
# Change powershell Title on every command I would like to display the last command that i have entered into powershell in the title of the window so that it is easier to find Currently I have: ``` C:\> $host.ui.rawui.WindowTitle = $$ ``` but this just gets the previous command relative to when i enter it so if I h...
You can use your custom function `prompt` defined in your profile. For example: ``` function prompt { # get the last command from history $command = Get-History -Count 1 # set it to the window title if ($command) { $host.ui.rawui.WindowTitle = $command } # specify your custom prompt, ...
28589098
Sed command to replace a string which has a special character "&"
7
2015-02-18 16:49:11
<p>Content of test.csv is:</p> <pre><code>XYZ,IN123 </code></pre> <p>Here is my script:</p> <pre><code>Var1=IN123 Var2=A&amp;B sed -i "s/$Var1/$Var2/g" test.csv </code></pre> <p>This is my simple code to replace the content of test.csv, when the code finds IN123, it will be replaced by A&amp;B. </p> <p>So expected...
48,499
4,456,527
2021-03-05 15:55:00
28,589,149
11
2015-02-18 16:51:40
2,088,135
2015-02-18 17:11:01
https://stackoverflow.com/q/28589098
https://stackoverflow.com/a/28589149
<p>Unfortunately you have been caught out by the fact that <code>&amp;</code> has a special meaning in a sed replacement string. It is a metacharacter that means "the entire pattern that was matched". In order to get a literal ampersand, you will have to escape it:</p> <pre><code>Var1='IN123' Var2='A\&amp;B' sed -i "s...
<p>Unfortunately you have been caught out by the fact that <code>&amp;</code> has a special meaning in a sed replacement string. It is a metacharacter that means "the entire pattern that was matched". In order to get a literal ampersand, you will have to escape it:</p> <pre><code>Var1='IN123' Var2='A\&amp;B' sed -i "s...
387, 390, 990, 5282
awk, bash, sed, shell
<h1>Sed command to replace a string which has a special character "&"</h1> <p>Content of test.csv is:</p> <pre><code>XYZ,IN123 </code></pre> <p>Here is my script:</p> <pre><code>Var1=IN123 Var2=A&amp;B sed -i "s/$Var1/$Var2/g" test.csv </code></pre> <p>This is my simple code to replace the content of test.csv, when...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,596
bash
# Sed command to replace a string which has a special character "&" Content of test.csv is: ``` XYZ,IN123 ``` Here is my script: ``` Var1=IN123 Var2=A&B sed -i "s/$Var1/$Var2/g" test.csv ``` This is my simple code to replace the content of test.csv, when the code finds IN123, it will be replaced by A&B. So expect...
Unfortunately you have been caught out by the fact that `&` has a special meaning in a sed replacement string. It is a metacharacter that means "the entire pattern that was matched". In order to get a literal ampersand, you will have to escape it: ``` Var1='IN123' Var2='A\&B' sed -i "s/$Var1/$Var2/g" test.csv ``` The...
28495913
How do you escape a hyphen as character range in a POSIX regex
7
2015-02-13 09:06:34
<p>I have a csv file full of values such as this:</p> <pre><code>0.00145423,3.03795e-05 </code></pre> <p>I wanted to check that all the lines were consistent so I tried to grep for any unexpected characters like so...</p> <pre><code>grep '[^0-9,e\-\.]' myfile </code></pre> <p>In my mind it goes like this: find a li...
7,191
1,888,983
2022-12-06 22:47:17
28,508,572
11
2015-02-13 20:55:22
1,745,001
2022-12-06 22:47:17
https://stackoverflow.com/q/28495913
https://stackoverflow.com/a/28508572
<p>The way to include a literal <code>-</code> in a character list is to put it in the first or last position of the bracket expression, exactly as shown in the answer at: <a href="https://stackoverflow.com/questions/25682967/get-final-special-character-with-a-regular-expression">Get final special character with a regu...
<p>The way to include a literal <code>-</code> in a character list is to put it in the first or last position of the bracket expression, exactly as shown in the answer at: <a href="https://stackoverflow.com/questions/25682967/get-final-special-character-with-a-regular-expression">Get final special character with a regu...
18, 387, 1271
bash, grep, regex
<h1>How do you escape a hyphen as character range in a POSIX regex</h1> <p>I have a csv file full of values such as this:</p> <pre><code>0.00145423,3.03795e-05 </code></pre> <p>I wanted to check that all the lines were consistent so I tried to grep for any unexpected characters like so...</p> <pre><code>grep '[^0-9,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,597
bash
# How do you escape a hyphen as character range in a POSIX regex I have a csv file full of values such as this: ``` 0.00145423,3.03795e-05 ``` I wanted to check that all the lines were consistent so I tried to grep for any unexpected characters like so... ``` grep '[^0-9,e\-\.]' myfile ``` In my mind it goes like ...
The way to include a literal `-` in a character list is to put it in the first or last position of the bracket expression, exactly as shown in the answer at: [Get final special character with a regular expression](https://stackoverflow.com/questions/25682967/get-final-special-character-with-a-regular-expression). From...
27490379
how to remove first two words of a strings output
7
2014-12-15 18:12:51
<p>I want to remove the first two words that come up in my output string. this string is also within another string.</p> <p>What I have: </p> <pre><code>for servers in `ls /data/field` do string=`cat /data/field/$servers/time` </code></pre> <p>This sends this text: </p> <pre><code>00:00 down server </code...
12,134
4,363,113
2017-12-06 11:17:01
27,490,451
11
2014-12-15 18:17:15
465,183
2014-12-15 18:31:43
https://stackoverflow.com/q/27490379
https://stackoverflow.com/a/27490451
<p>Please, do the things properly :</p> <pre><code>for servers in /data/field/*; do string=$(cut -d" " -f3- /data/field/$servers/time) echo "$string" done </code></pre> <ul> <li>backticks are deprecated in 2014 in favor of the form <code>$( )</code></li> <li>don't parse <code>ls</code> output, use <code>glob...
<p>Please, do the things properly :</p> <pre><code>for servers in /data/field/*; do string=$(cut -d" " -f3- /data/field/$servers/time) echo "$string" done </code></pre> <ul> <li>backticks are deprecated in 2014 in favor of the form <code>$( )</code></li> <li>don't parse <code>ls</code> output, use <code>glob...
58, 387, 990, 4257, 5282
awk, bash, cut, linux, sed
<h1>how to remove first two words of a strings output</h1> <p>I want to remove the first two words that come up in my output string. this string is also within another string.</p> <p>What I have: </p> <pre><code>for servers in `ls /data/field` do string=`cat /data/field/$servers/time` </code></pre> <p>This...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,598
bash
# how to remove first two words of a strings output I want to remove the first two words that come up in my output string. this string is also within another string. What I have: ``` for servers in `ls /data/field` do string=`cat /data/field/$servers/time` ``` This sends this text: ``` 00:00 down server ...
Please, do the things properly : ``` for servers in /data/field/*; do string=$(cut -d" " -f3- /data/field/$servers/time) echo "$string" done ``` - backticks are deprecated in 2014 in favor of the form `$( )` - don't parse `ls` output, use `glob` instead like I do with `data/field/*` Check <http://mywiki.woo...
27098578
OSX Terminal command to move all files in directory
7
2014-11-24 05:49:07
<p>i'm at the OSX terminal now and try to move a lot of files from <code>~/Desktop/dir/</code> to <code>~/Desktop/dir/dir2</code>. </p> <p>Command </p> <pre><code>mv *.* ~/Desktop/dir/dir2 </code></pre> <p>doesn't work.</p>
9,368
4,286,195
2014-11-24 06:37:29
27,098,994
11
2014-11-24 06:25:32
548,225
2014-11-24 06:37:29
https://stackoverflow.com/q/27098578
https://stackoverflow.com/a/27098994
<p>You're getting <code>"too many argument"</code> because there are probably too many files in <code>~/Desktop/dir/</code> that that are allowed by glob matching pattern on command line.</p> <p>To move all files from <code>~/Desktop/dir/</code> to <code>~/Desktop/dir/dir2</code> use this <code>find</code> instead:</p...
<p>You're getting <code>"too many argument"</code> because there are probably too many files in <code>~/Desktop/dir/</code> that that are allowed by glob matching pattern on command line.</p> <p>To move all files from <code>~/Desktop/dir/</code> to <code>~/Desktop/dir/dir2</code> use this <code>find</code> instead:</p...
369, 390, 391, 11225
command-line-interface, macos, shell, terminal
<h1>OSX Terminal command to move all files in directory</h1> <p>i'm at the OSX terminal now and try to move a lot of files from <code>~/Desktop/dir/</code> to <code>~/Desktop/dir/dir2</code>. </p> <p>Command </p> <pre><code>mv *.* ~/Desktop/dir/dir2 </code></pre> <p>doesn't work.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,599
bash
# OSX Terminal command to move all files in directory i'm at the OSX terminal now and try to move a lot of files from `~/Desktop/dir/` to `~/Desktop/dir/dir2`. Command ``` mv *.* ~/Desktop/dir/dir2 ``` doesn't work.
You're getting `"too many argument"` because there are probably too many files in `~/Desktop/dir/` that that are allowed by glob matching pattern on command line. To move all files from `~/Desktop/dir/` to `~/Desktop/dir/dir2` use this `find` instead: ``` find ~/Desktop/dir/ -type f -execdir mv '{}' ~/Desktop/dir/dir...
25780138
How to find a desktop window (by window name) in Windows 8.1 Update 2 OS, using the Win32 API FindWindow() in PowerShell environment?
7
2014-09-11 06:02:47
<p>I don't remember having any problem finding a window in older Windows OS's, but, I'm not succeeding in Windows 8.1 Update 2 OS, using <strong>PowerShell v4.0</strong>.</p> <p>This is the <strong>PowerShell v4.0</strong> code I'm using (pretty much trivial):</p> <pre><code>$sig=@' [DllImport("user32.dll")] public s...
12,352
3,904,490
2023-07-06 11:15:06
25,792,444
11
2014-09-11 16:17:22
608,772
2014-09-12 03:07:18
https://stackoverflow.com/q/25780138
https://stackoverflow.com/a/25792444
<p><strong>First</strong> : not an answer but to help other people working on it, if you use the good class, for example here I code <code>CalcFrame</code> wich is the real class of the main window of <code>calc.exe</code> it works.</p> <pre><code>$fw::FindWindow("CalcFrame", $wname) # returns the right value for me ...
<p><strong>First</strong> : not an answer but to help other people working on it, if you use the good class, for example here I code <code>CalcFrame</code> wich is the real class of the main window of <code>calc.exe</code> it works.</p> <pre><code>$fw::FindWindow("CalcFrame", $wname) # returns the right value for me ...
64, 526
powershell, windows
<h1>How to find a desktop window (by window name) in Windows 8.1 Update 2 OS, using the Win32 API FindWindow() in PowerShell environment?</h1> <p>I don't remember having any problem finding a window in older Windows OS's, but, I'm not succeeding in Windows 8.1 Update 2 OS, using <strong>PowerShell v4.0</strong>.</p> <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,600
bash
# How to find a desktop window (by window name) in Windows 8.1 Update 2 OS, using the Win32 API FindWindow() in PowerShell environment? I don't remember having any problem finding a window in older Windows OS's, but, I'm not succeeding in Windows 8.1 Update 2 OS, using **PowerShell v4.0**. This is the **PowerShell v4...
**First** : not an answer but to help other people working on it, if you use the good class, for example here I code `CalcFrame` wich is the real class of the main window of `calc.exe` it works. ``` $fw::FindWindow("CalcFrame", $wname) # returns the right value for me if calc.exe is started. ``` **Second** : The foll...
25730425
Get tag name of XML element that has a "name" property
7
2014-09-08 18:04:53
<pre><code>$x = ([xml]"&lt;sample name='notsample'/&gt;").sample </code></pre> <p>Given the above line of code, as is, I want to find the name of the tag described by the <code>XmlElement</code> in <code>$x</code>. Typically, you would just use <code>$x.Name</code>, but the <code>name</code> attribute masks it. Instea...
5,540
172,029
2014-09-08 19:23:42
25,730,645
11
2014-09-08 18:19:28
517,852
2014-09-08 19:23:42
https://stackoverflow.com/q/25730425
https://stackoverflow.com/a/25730645
<p>You can get it by invoking the property getter method directly:</p> <pre><code>$x.get_Name() </code></pre> <p>This works in many other similar cases. For example, if a type implements <code>IDictonary</code> and has other properties, you may need to use this to access those properties. By default, PowerShell does ...
<p>You can get it by invoking the property getter method directly:</p> <pre><code>$x.get_Name() </code></pre> <p>This works in many other similar cases. For example, if a type implements <code>IDictonary</code> and has other properties, you may need to use this to access those properties. By default, PowerShell does ...
19, 526
powershell, xml
<h1>Get tag name of XML element that has a "name" property</h1> <pre><code>$x = ([xml]"&lt;sample name='notsample'/&gt;").sample </code></pre> <p>Given the above line of code, as is, I want to find the name of the tag described by the <code>XmlElement</code> in <code>$x</code>. Typically, you would just use <code>$x.N...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,601
bash
# Get tag name of XML element that has a "name" property ``` $x = ([xml]"<sample name='notsample'/>").sample ``` Given the above line of code, as is, I want to find the name of the tag described by the `XmlElement` in `$x`. Typically, you would just use `$x.Name`, but the `name` attribute masks it. Instead of returni...
You can get it by invoking the property getter method directly: ``` $x.get_Name() ``` This works in many other similar cases. For example, if a type implements `IDictonary` and has other properties, you may need to use this to access those properties. By default, PowerShell does a lookup into the dictionary rather th...
25351213
My shell prompt looks like this: ➜ ~ git:(master) ✗. How can I get my normal prompt back?
7
2014-08-17 16:30:57
<p>My normal terminal command line has suddenly disappeared and has been replaced by this git command line <code>➜ ~ git:(master) ✗</code>.</p> <p>How do I get rid of this and go back to my normal command line in Terminal? I on Mac OS X.</p> <p>I have tried typing <code>exit</code>, <kbd>Ctrl</kbd>+<kbd>c</kbd>, <kb...
33,664
3,543,449
2023-09-04 10:11:09
25,357,808
11
2014-08-18 06:58:28
1,784,595
2015-06-28 02:07:16
https://stackoverflow.com/q/25351213
https://stackoverflow.com/a/25357808
<p>I know your problem , You are using <code>zsh</code>, right? </p> <p>If so, you should add <code>export PS1=xxxxx</code> to <code>~/.zshrc</code>, not <code>~/.bashrc</code>.</p> <p>Or you just don't use <code>zsh</code> , input <code>bash</code> and switch to <code>bash.input</code> <code>chsh -s /bin/bash</code>...
<p>I know your problem , You are using <code>zsh</code>, right? </p> <p>If so, you should add <code>export PS1=xxxxx</code> to <code>~/.zshrc</code>, not <code>~/.bashrc</code>.</p> <p>Or you just don't use <code>zsh</code> , input <code>bash</code> and switch to <code>bash.input</code> <code>chsh -s /bin/bash</code>...
119, 387, 391, 6452
bash, git, git-svn, terminal
<h1>My shell prompt looks like this: ➜ ~ git:(master) ✗. How can I get my normal prompt back?</h1> <p>My normal terminal command line has suddenly disappeared and has been replaced by this git command line <code>➜ ~ git:(master) ✗</code>.</p> <p>How do I get rid of this and go back to my normal command line in Termin...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,602
bash
# My shell prompt looks like this: ➜ ~ git:(master) ✗. How can I get my normal prompt back? My normal terminal command line has suddenly disappeared and has been replaced by this git command line `➜ ~ git:(master) ✗`. How do I get rid of this and go back to my normal command line in Terminal? I on Mac OS X. I have t...
I know your problem , You are using `zsh`, right? If so, you should add `export PS1=xxxxx` to `~/.zshrc`, not `~/.bashrc`. Or you just don't use `zsh` , input `bash` and switch to `bash.input` `chsh -s /bin/bash` to change the default shell to `bash`.
25311853
Can I change my own password in Active Directory using Powershell
7
2014-08-14 15:26:21
<p>I am trying to <strong>change password for my own account in AD using powershell</strong>. My account is just a regular account (no domain admin rights)</p> <p>I tried net user, dsquery and powershell cmdlets, but all of them errors out "Access is denied". I think all of those requires admin rights.</p> <p>Is ther...
31,980
3,817,513
2014-08-14 16:02:45
25,312,566
11
2014-08-14 16:02:45
3,885,583
2014-08-14 16:02:45
https://stackoverflow.com/q/25311853
https://stackoverflow.com/a/25312566
<p>If you have the Active Directory PowerShell Module installed, this is a pretty easy task using Set-ADAccountPassword.</p> <p>You can use the -Server parameter to supply a different Domain Controller name from each Domain to set the password on that Domain.</p> <pre><code>$DomainControllers = "Domain1DC","Domain2DC...
<p>If you have the Active Directory PowerShell Module installed, this is a pretty easy task using Set-ADAccountPassword.</p> <p>You can use the -Server parameter to supply a different Domain Controller name from each Domain to set the password on that Domain.</p> <pre><code>$DomainControllers = "Domain1DC","Domain2DC...
220, 526, 9847, 10401
active-directory, change-password, passwords, powershell
<h1>Can I change my own password in Active Directory using Powershell</h1> <p>I am trying to <strong>change password for my own account in AD using powershell</strong>. My account is just a regular account (no domain admin rights)</p> <p>I tried net user, dsquery and powershell cmdlets, but all of them errors out "Acc...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,603
bash
# Can I change my own password in Active Directory using Powershell I am trying to **change password for my own account in AD using powershell**. My account is just a regular account (no domain admin rights) I tried net user, dsquery and powershell cmdlets, but all of them errors out "Access is denied". I think all o...
If you have the Active Directory PowerShell Module installed, this is a pretty easy task using Set-ADAccountPassword. You can use the -Server parameter to supply a different Domain Controller name from each Domain to set the password on that Domain. ``` $DomainControllers = "Domain1DC","Domain2DC","Domain3DC" $MyName...
25279112
Returning a List[String] using a comma vs not using a comma
7
2014-08-13 06:05:40
<p>how does putting a comma before a list affect its type?</p> <p>Have a look at the following code:</p> <pre><code>function StartProgram { $firstList = getListMethodOne Write-Host "firstList is of type $($firstList.gettype())" $secondList = getListMethodTwo Write-Host "secondList is of type $($secon...
3,448
2,063,755
2014-08-13 06:56:26
25,279,899
11
2014-08-13 06:55:42
674,943
2014-08-13 06:55:42
https://stackoverflow.com/q/25279112
https://stackoverflow.com/a/25279899
<p>When you return collection, than PowerShell is kind enough to unravel it for you. Unary comma creates collection with single element, so "external" collection gets unraveled and collection you want to return is kept.</p> <p>I <a href="http://becomelotr.wordpress.com/2010/10/05/unary-comma/" rel="noreferrer">blogged...
<p>When you return collection, than PowerShell is kind enough to unravel it for you. Unary comma creates collection with single element, so "external" collection gets unraveled and collection you want to return is kept.</p> <p>I <a href="http://becomelotr.wordpress.com/2010/10/05/unary-comma/" rel="noreferrer">blogged...
526
powershell
<h1>Returning a List[String] using a comma vs not using a comma</h1> <p>how does putting a comma before a list affect its type?</p> <p>Have a look at the following code:</p> <pre><code>function StartProgram { $firstList = getListMethodOne Write-Host "firstList is of type $($firstList.gettype())" $secondL...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,604
bash
# Returning a List[String] using a comma vs not using a comma how does putting a comma before a list affect its type? Have a look at the following code: ``` function StartProgram { $firstList = getListMethodOne Write-Host "firstList is of type $($firstList.gettype())" $secondList = getListMethodTwo ...
When you return collection, than PowerShell is kind enough to unravel it for you. Unary comma creates collection with single element, so "external" collection gets unraveled and collection you want to return is kept. I [blogged](http://becomelotr.wordpress.com/2010/10/05/unary-comma/) about it a while ago. Two more t...
24606966
"sh: ./<file> not found" error when trying to execute a file
7
2014-07-07 09:13:01
<p>I've come across a weirdest problem I ever met. I'm cross-compiling an app for ARM CPU with Linux on-board. I'm using <em>buildroot</em>, and all goes well until I'm trying to run the application on the target: I'm getting <code>-sh: ./hw: not found</code>. E.g.:</p> <pre><code>$ cat /tmp/test.cpp #include &lt;cst...
9,703
2,388,257
2017-03-08 19:41:37
24,607,099
11
2014-07-07 09:19:32
865,874
2014-07-07 09:19:32
https://stackoverflow.com/q/24606966
https://stackoverflow.com/a/24607099
<p><code>sh</code> prints this weird error because it is trying to run your program as a <em>shell script</em>!</p> <p>Your error <code>./hw: not found</code> is probably caused by the dynamic linker (AKA ELF interpreter) not being found. Try compiling it as a static program with <code>-static</code> or running it wit...
<p><code>sh</code> prints this weird error because it is trying to run your program as a <em>shell script</em>!</p> <p>Your error <code>./hw: not found</code> is probably caused by the dynamic linker (AKA ELF interpreter) not being found. Try compiling it as a static program with <code>-static</code> or running it wit...
10, 58, 2280, 10327, 36913
arm, buildroot, c++, linux, sh
<h1>"sh: ./<file> not found" error when trying to execute a file</h1> <p>I've come across a weirdest problem I ever met. I'm cross-compiling an app for ARM CPU with Linux on-board. I'm using <em>buildroot</em>, and all goes well until I'm trying to run the application on the target: I'm getting <code>-sh: ./hw: not fou...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,605
bash
# "sh: ./ not found" error when trying to execute a file I've come across a weirdest problem I ever met. I'm cross-compiling an app for ARM CPU with Linux on-board. I'm using *buildroot*, and all goes well until I'm trying to run the application on the target: I'm getting `-sh: ./hw: not found`. E.g.: ``` $ cat /tmp/...
`sh` prints this weird error because it is trying to run your program as a *shell script*! Your error `./hw: not found` is probably caused by the dynamic linker (AKA ELF interpreter) not being found. Try compiling it as a static program with `-static` or running it with your dynamic loader: `# /lib/ld-linux.so.2 ./hw`...
23651620
Append or create a file, in one command?
7
2014-05-14 10:09:03
<p>Very simple task: grab an output and redirect it to a file, using shell.</p> <p>Now, I need to create the file if it does not exist, or if it exist, I need to append data</p> <p>If I use <code>output &gt; file.txt</code> I get data overwritten at each access. Not what I want. If I use <code>output &gt;&gt; file.tx...
9,156
null
2014-05-14 10:34:04
23,652,173
11
2014-05-14 10:34:04
1,049,096
2014-05-14 10:34:04
https://stackoverflow.com/q/23651620
https://stackoverflow.com/a/23652173
<p>to create or append to a file in <code>bash</code>, you can use <code>&gt;&gt;</code>. </p> <pre><code>echo "sample text" &gt;&gt; sample_file echo "append text" &gt;&gt; sample_file </code></pre>
<p>to create or append to a file in <code>bash</code>, you can use <code>&gt;&gt;</code>. </p> <pre><code>echo "sample text" &gt;&gt; sample_file echo "append text" &gt;&gt; sample_file </code></pre>
387
bash
<h1>Append or create a file, in one command?</h1> <p>Very simple task: grab an output and redirect it to a file, using shell.</p> <p>Now, I need to create the file if it does not exist, or if it exist, I need to append data</p> <p>If I use <code>output &gt; file.txt</code> I get data overwritten at each access. Not w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,606
bash
# Append or create a file, in one command? Very simple task: grab an output and redirect it to a file, using shell. Now, I need to create the file if it does not exist, or if it exist, I need to append data If I use `output > file.txt` I get data overwritten at each access. Not what I want. If I use `output >> file....
to create or append to a file in `bash`, you can use `>>`. ``` echo "sample text" >> sample_file echo "append text" >> sample_file ```
22962591
How to prevent direct bash script execution and allow only usage from other script?
7
2014-04-09 12:29:53
<p>I have one script with common functions that is included in other my scripts with:</p> <pre><code>. ~/bin/fns </code></pre> <p>Since my <code>~/bin</code> path is on the PATH, is there a way to prevent users to execute <code>fns</code> from command line (by returning from the script with a message), but to allow o...
3,679
511,837
2024-11-19 22:17:57
22,962,683
11
2014-04-09 12:33:28
341,291
2014-04-09 12:33:28
https://stackoverflow.com/q/22962591
https://stackoverflow.com/a/22962683
<p>Just remove the executable bit with <code>chmod -x . ~/bin/fns</code>. It will still work when sourced, but you can't call it (accidentally) by its name anymore.</p>
<p>Just remove the executable bit with <code>chmod -x . ~/bin/fns</code>. It will still work when sourced, but you can't call it (accidentally) by its name anymore.</p>
387
bash
<h1>How to prevent direct bash script execution and allow only usage from other script?</h1> <p>I have one script with common functions that is included in other my scripts with:</p> <pre><code>. ~/bin/fns </code></pre> <p>Since my <code>~/bin</code> path is on the PATH, is there a way to prevent users to execute <co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,607
bash
# How to prevent direct bash script execution and allow only usage from other script? I have one script with common functions that is included in other my scripts with: ``` . ~/bin/fns ``` Since my `~/bin` path is on the PATH, is there a way to prevent users to execute `fns` from command line (by returning from the ...
Just remove the executable bit with `chmod -x . ~/bin/fns`. It will still work when sourced, but you can't call it (accidentally) by its name anymore.
22794949
Join/merge arrays' properties
7
2014-04-01 19:17:54
<p>I have 2 objects that I will like to merge, but it seems I cannot find the solution</p> <pre><code>Messages Name Error -------- ---- ...
31,610
3,029,422
2019-11-11 12:32:52
22,795,736
11
2014-04-01 19:59:34
null
2014-04-01 19:59:34
https://stackoverflow.com/q/22794949
https://stackoverflow.com/a/22795736
<h2>Option 1</h2> <p>One option would be to put both object into a <code>HashTable</code>, and then cast it as a <code>PSCustomObject</code>.</p> <pre><code> $Obj1 = (Get-Process)[0]; # Get a process $Obj2 = (Get-Service)[0]; # Get a service ($Result = [PSCustomObject]@{ Obj1 = $Obj1; Obj2 = $Obj2; }); $Result.Ob...
<h2>Option 1</h2> <p>One option would be to put both object into a <code>HashTable</code>, and then cast it as a <code>PSCustomObject</code>.</p> <pre><code> $Obj1 = (Get-Process)[0]; # Get a process $Obj2 = (Get-Service)[0]; # Get a service ($Result = [PSCustomObject]@{ Obj1 = $Obj1; Obj2 = $Obj2; }); $Result.Ob...
526
powershell
<h1>Join/merge arrays' properties</h1> <p>I have 2 objects that I will like to merge, but it seems I cannot find the solution</p> <pre><code>Messages Name Error -------- ---- ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,608
bash
# Join/merge arrays' properties I have 2 objects that I will like to merge, but it seems I cannot find the solution ``` Messages Name Error -------- ---- ...
## Option 1 One option would be to put both object into a `HashTable`, and then cast it as a `PSCustomObject`. ``` $Obj1 = (Get-Process)[0]; # Get a process $Obj2 = (Get-Service)[0]; # Get a service ($Result = [PSCustomObject]@{ Obj1 = $Obj1; Obj2 = $Obj2; }); $Result.Obj1.Name; $Result.Obj2.Name; ``` **NOTE**...
22239469
Grep: invalid repetition count
7
2014-03-07 01:06:31
<p>I'm very experienced with regex, but cannot figure out why this isn't working.</p> <p>My sample text:</p> <pre><code>{ "coord": { "lon":-74.01, "lat":40.71 }, "sys": { "message":0.2452, "country":"United States of America", "sunrise":1394191161, "...
10,479
1,351,335
2014-03-07 01:20:26
22,239,615
11
2014-03-07 01:19:49
3,030,305
2014-03-07 01:19:49
https://stackoverflow.com/q/22239469
https://stackoverflow.com/a/22239615
<p><code>grep -e</code> does not recognize <code>\d</code> as digits. It does not recognize non-greedy forms like <code>.*?</code>. For the <code>grep</code> portion of your command, try:</p> <pre><code>grep -e '"weather":[^[]*\[[^{]*{[^}]*"id": *[0-9]\{1,3\}' </code></pre> <p>Alternatively, it your <code>grep</cod...
<p><code>grep -e</code> does not recognize <code>\d</code> as digits. It does not recognize non-greedy forms like <code>.*?</code>. For the <code>grep</code> portion of your command, try:</p> <pre><code>grep -e '"weather":[^[]*\[[^{]*{[^}]*"id": *[0-9]\{1,3\}' </code></pre> <p>Alternatively, it your <code>grep</cod...
18, 387, 390, 1271, 1554
bash, curl, grep, regex, shell
<h1>Grep: invalid repetition count</h1> <p>I'm very experienced with regex, but cannot figure out why this isn't working.</p> <p>My sample text:</p> <pre><code>{ "coord": { "lon":-74.01, "lat":40.71 }, "sys": { "message":0.2452, "country":"United States of America",...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,609
bash
# Grep: invalid repetition count I'm very experienced with regex, but cannot figure out why this isn't working. My sample text: ``` { "coord": { "lon":-74.01, "lat":40.71 }, "sys": { "message":0.2452, "country":"United States of America", "sunrise":13941911...
`grep -e` does not recognize `\d` as digits. It does not recognize non-greedy forms like `.*?`. For the `grep` portion of your command, try: ``` grep -e '"weather":[^[]*\[[^{]*{[^}]*"id": *[0-9]\{1,3\}' ``` Alternatively, it your `grep` supports it (GNU), use the `-P` option for perl-like regex and your original rege...
21865940
How do I change the group ownership of a file in Ubuntu?
7
2014-02-18 21:37:04
<p>I have a little question on how to change the group owner of a file. At the moment the group of the file is the same as my user name but I want to change it so another user can access that same file and read/write to it.</p>
21,972
2,489,694
2017-05-06 02:59:27
21,866,002
11
2014-02-18 21:40:09
648,658
2014-02-18 22:09:33
https://stackoverflow.com/q/21865940
https://stackoverflow.com/a/21866002
<p>The syntax would be</p> <pre><code>chown user:group file ... </code></pre> <p>This usually (=when you're not <code>root</code>) only works as long as you are a member of the same group (since otherwise by chown'ing files you could exceed the other user's disk quota).</p> <p>If you both are in the same group you c...
<p>The syntax would be</p> <pre><code>chown user:group file ... </code></pre> <p>This usually (=when you're not <code>root</code>) only works as long as you are a member of the same group (since otherwise by chown'ing files you could exceed the other user's disk quota).</p> <p>If you both are in the same group you c...
58, 387, 549, 66181
access-rights, bash, linux, ubuntu
<h1>How do I change the group ownership of a file in Ubuntu?</h1> <p>I have a little question on how to change the group owner of a file. At the moment the group of the file is the same as my user name but I want to change it so another user can access that same file and read/write to it.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,610
bash
# How do I change the group ownership of a file in Ubuntu? I have a little question on how to change the group owner of a file. At the moment the group of the file is the same as my user name but I want to change it so another user can access that same file and read/write to it.
The syntax would be ``` chown user:group file ... ``` This usually (=when you're not `root`) only works as long as you are a member of the same group (since otherwise by chown'ing files you could exceed the other user's disk quota). If you both are in the same group you could also allow write access with ``` chmod ...
21118311
Ordering files inside tar created from bash
7
2014-01-14 16:14:21
<p>Any idea how to tar files in a specific order. I know it sounds weird at first, but hear me out. An OVA file is essentially a tar file but with a specific order. Tar is commonly used to create the file, but in order for the OVA to be recognised by HyperVisors like VMware, the files inside the OVA must be ordered in ...
4,720
2,272,450
2019-08-20 15:05:49
21,118,428
11
2014-01-14 16:19:34
418,413
2019-08-20 15:05:49
https://stackoverflow.com/q/21118311
https://stackoverflow.com/a/21118428
<p>The issue is that you're just using a glob, <code>*</code>, to list the files. The glob expands immediately, before <code>tar</code> ever sees it, so what tar really sees is:</p> <pre><code>tar -cvf VM.ova VM.iso VM.mf VM.ovf VM.vmdk </code></pre> <p>Because under normal* circumstances globs expand lexically in th...
<p>The issue is that you're just using a glob, <code>*</code>, to list the files. The glob expands immediately, before <code>tar</code> ever sees it, so what tar really sees is:</p> <pre><code>tar -cvf VM.ova VM.iso VM.mf VM.ovf VM.vmdk </code></pre> <p>Because under normal* circumstances globs expand lexically in th...
58, 387, 8773, 97941
bash, linux, ova, tar
<h1>Ordering files inside tar created from bash</h1> <p>Any idea how to tar files in a specific order. I know it sounds weird at first, but hear me out. An OVA file is essentially a tar file but with a specific order. Tar is commonly used to create the file, but in order for the OVA to be recognised by HyperVisors like...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,611
bash
# Ordering files inside tar created from bash Any idea how to tar files in a specific order. I know it sounds weird at first, but hear me out. An OVA file is essentially a tar file but with a specific order. Tar is commonly used to create the file, but in order for the OVA to be recognised by HyperVisors like VMware, ...
The issue is that you're just using a glob, `*`, to list the files. The glob expands immediately, before `tar` ever sees it, so what tar really sees is: ``` tar -cvf VM.ova VM.iso VM.mf VM.ovf VM.vmdk ``` Because under normal* circumstances globs expand lexically in the `C` collation locale. If the order is important...
20830478
Powershell display message both on console and in a file
7
2013-12-29 21:53:11
<p>Not sure if this is a simple question or some code is required in order to achieve this, so here it goes.</p> <p>I have a script which basically displays some text 1st on the PS console <em>and also</em> in a log file.</p> <p>The code I have uses both the write-host and write-output, so my question is that if the ...
6,942
3,144,292
2013-12-31 05:04:01
20,831,124
11
2013-12-29 23:09:41
3,093,031
2013-12-29 23:09:41
https://stackoverflow.com/q/20830478
https://stackoverflow.com/a/20831124
<p>Simple answer is to use a Tee-Object. In version 3 you should have access to the -Append parameter as well (but not in v2)</p> <pre><code>Write-Output "Error: whatever message" | Tee-Object -Append $Log_file </code></pre>
<p>Simple answer is to use a Tee-Object. In version 3 you should have access to the -Append parameter as well (but not in v2)</p> <pre><code>Write-Output "Error: whatever message" | Tee-Object -Append $Log_file </code></pre>
526, 73157, 95686
powershell, powershell-3.0, powershell-4.0
<h1>Powershell display message both on console and in a file</h1> <p>Not sure if this is a simple question or some code is required in order to achieve this, so here it goes.</p> <p>I have a script which basically displays some text 1st on the PS console <em>and also</em> in a log file.</p> <p>The code I have uses bo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,612
bash
# Powershell display message both on console and in a file Not sure if this is a simple question or some code is required in order to achieve this, so here it goes. I have a script which basically displays some text 1st on the PS console *and also* in a log file. The code I have uses both the write-host and write-ou...
Simple answer is to use a Tee-Object. In version 3 you should have access to the -Append parameter as well (but not in v2) ``` Write-Output "Error: whatever message" | Tee-Object -Append $Log_file ```
19999562
Bash script to convert windows path to linux path
7
2013-11-15 11:02:21
<p>I'm new to shell scripting and trying to accomplish following, converting a windows path to a linux path and navigating to that location:</p> <p>Input: <code>cdwin "J:\abc\def"</code> Action: <code>cd /usr/abc/def/</code></p> <p>So, I'm changing the following:</p> <pre><code>"J:" -&gt; "/usr" </code></pre> <p>an...
18,639
2,987,193
2018-12-29 08:42:22
19,999,693
11
2013-11-15 11:09:20
1,983,854
2013-11-15 11:59:07
https://stackoverflow.com/q/19999562
https://stackoverflow.com/a/19999693
<p>You need to catch the variable and then process it.</p> <p>For example this would make it:</p> <pre><code>function cdwin(){ echo "I receive the variable --&gt; $1" line=$(sed -e 's#^J:##' -e 's#\\#/#g' &lt;&lt;&lt; "$1") cd "$line" } </code></pre> <p>And then you call it with</p> <pre><code>cdwin "J:...
<p>You need to catch the variable and then process it.</p> <p>For example this would make it:</p> <pre><code>function cdwin(){ echo "I receive the variable --&gt; $1" line=$(sed -e 's#^J:##' -e 's#\\#/#g' &lt;&lt;&lt; "$1") cd "$line" } </code></pre> <p>And then you call it with</p> <pre><code>cdwin "J:...
58, 64, 387, 5282, 6268
bash, linux, path, sed, windows
<h1>Bash script to convert windows path to linux path</h1> <p>I'm new to shell scripting and trying to accomplish following, converting a windows path to a linux path and navigating to that location:</p> <p>Input: <code>cdwin "J:\abc\def"</code> Action: <code>cd /usr/abc/def/</code></p> <p>So, I'm changing the follow...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,613
bash
# Bash script to convert windows path to linux path I'm new to shell scripting and trying to accomplish following, converting a windows path to a linux path and navigating to that location: Input: `cdwin "J:\abc\def"` Action: `cd /usr/abc/def/` So, I'm changing the following: ``` "J:" -> "/usr" ``` and ``` "\" ->...
You need to catch the variable and then process it. For example this would make it: ``` function cdwin(){ echo "I receive the variable --> $1" line=$(sed -e 's#^J:##' -e 's#\\#/#g' <<< "$1") cd "$line" } ``` And then you call it with ``` cdwin "J:\abc\def" ``` ### Explanation The command ``` line=$(s...
19737398
Sed: How to replace a string found after a specific pattern is located in a file
7
2013-11-02 00:05:46
<p>If I have the following list in a file:</p> <pre><code>integer, parameter :: ni = 1024 integer, parameter :: nj = 256 integer, parameter :: nk = 16 </code></pre> <p>and want to search based on the string 'ni =', and then replace the string that follows (in this case '1024') with a new string like '512' for example...
26,613
1,974,964
2013-11-02 00:47:40
19,737,485
11
2013-11-02 00:15:59
2,206,004
2013-11-02 00:47:40
https://stackoverflow.com/q/19737398
https://stackoverflow.com/a/19737485
<p>GNU sed supports extended regular expressions if you give it the <code>-r</code> flag.</p> <pre><code>sed -re 's/(:: ni =)[^=]*$/\1 512/' file </code></pre> <p>Better yet, match for multiple whitespace.</p> <pre><code>sed -re 's/(::\s+ni\s+=)[^=]*$/\1 512/' file </code></pre> <p>The <code>\1</code> is a referen...
<p>GNU sed supports extended regular expressions if you give it the <code>-r</code> flag.</p> <pre><code>sed -re 's/(:: ni =)[^=]*$/\1 512/' file </code></pre> <p>Better yet, match for multiple whitespace.</p> <pre><code>sed -re 's/(::\s+ni\s+=)[^=]*$/\1 512/' file </code></pre> <p>The <code>\1</code> is a referen...
18, 34, 58, 387, 5282
bash, linux, regex, sed, unix
<h1>Sed: How to replace a string found after a specific pattern is located in a file</h1> <p>If I have the following list in a file:</p> <pre><code>integer, parameter :: ni = 1024 integer, parameter :: nj = 256 integer, parameter :: nk = 16 </code></pre> <p>and want to search based on the string 'ni =', and then repl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,614
bash
# Sed: How to replace a string found after a specific pattern is located in a file If I have the following list in a file: ``` integer, parameter :: ni = 1024 integer, parameter :: nj = 256 integer, parameter :: nk = 16 ``` and want to search based on the string 'ni =', and then replace the string that follows (in t...
GNU sed supports extended regular expressions if you give it the `-r` flag. ``` sed -re 's/(:: ni =)[^=]*$/\1 512/' file ``` Better yet, match for multiple whitespace. ``` sed -re 's/(::\s+ni\s+=)[^=]*$/\1 512/' file ``` The `\1` is a reference to what's matched in parentheses `( )`, so we replace with `\1` and a n...
18626209
-bash: syntax error near unexpected token `)'
7
2013-09-05 01:05:57
<p>I'm probably missing something very basic. I have a web script that tells a shell script to update some database records. These records are for statistics, and this way the web script does not have to wait while the database records are updated. However, I can't actually make the shell script work running it from co...
39,011
2,744,953
2022-07-13 13:17:28
18,626,228
11
2013-09-05 01:08:17
2,698,019
2014-07-06 01:23:49
https://stackoverflow.com/q/18626209
https://stackoverflow.com/a/18626228
<p>It is not possible to escape single quote in single quotes. Use <code>" "</code> instead</p> <pre><code>perl async_sql.pl "UPDATE some_table set i = i + 1 WHERE (n in ('328430','334969','330179','335290','335285','335284','335264','335145','335146','335147','335148','335149','335230','335201','335198','335196','335...
<p>It is not possible to escape single quote in single quotes. Use <code>" "</code> instead</p> <pre><code>perl async_sql.pl "UPDATE some_table set i = i + 1 WHERE (n in ('328430','334969','330179','335290','335285','335284','335264','335145','335146','335147','335148','335149','335230','335201','335198','335196','335...
387, 390
bash, shell
<h1>-bash: syntax error near unexpected token `)'</h1> <p>I'm probably missing something very basic. I have a web script that tells a shell script to update some database records. These records are for statistics, and this way the web script does not have to wait while the database records are updated. However, I can't...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,615
bash
# -bash: syntax error near unexpected token `)' I'm probably missing something very basic. I have a web script that tells a shell script to update some database records. These records are for statistics, and this way the web script does not have to wait while the database records are updated. However, I can't actually...
It is not possible to escape single quote in single quotes. Use `" "` instead ``` perl async_sql.pl "UPDATE some_table set i = i + 1 WHERE (n in ('328430','334969','330179','335290','335285','335284','335264','335145','335146','335147','335148','335149','335230','335201','335198','335196','335167','335151','335152','3...
18513631
Why pipe resets current working directory?
7
2013-08-29 14:25:08
<p>First script:</p> <pre><code>$ { mkdir dir; cd dir; pwd; } | cat; pwd; ./dir . </code></pre> <p>Second script:</p> <pre><code>$ { mkdir dir; cd dir; pwd; }; pwd; ./dir ./dir </code></pre> <p>Why this <code>| cat</code> has an effect on current directory? And how to solve it? I need the first script to work exact...
573
187,141
2013-09-23 09:23:40
18,513,756
11
2013-08-29 14:30:04
2,235,132
2013-08-29 14:30:04
https://stackoverflow.com/q/18513631
https://stackoverflow.com/a/18513756
<p>Quoting from the <a href="http://www.gnu.org/software/bash/manual/bashref.html#Pipelines" rel="noreferrer">manual</a>:</p> <blockquote> <p>Each command in a pipeline is executed in its own subshell (see <a href="http://www.gnu.org/software/bash/manual/bashref.html#Command-Execution-Environment" rel="noreferrer"...
<p>Quoting from the <a href="http://www.gnu.org/software/bash/manual/bashref.html#Pipelines" rel="noreferrer">manual</a>:</p> <blockquote> <p>Each command in a pipeline is executed in its own subshell (see <a href="http://www.gnu.org/software/bash/manual/bashref.html#Command-Execution-Environment" rel="noreferrer"...
387, 390
bash, shell
<h1>Why pipe resets current working directory?</h1> <p>First script:</p> <pre><code>$ { mkdir dir; cd dir; pwd; } | cat; pwd; ./dir . </code></pre> <p>Second script:</p> <pre><code>$ { mkdir dir; cd dir; pwd; }; pwd; ./dir ./dir </code></pre> <p>Why this <code>| cat</code> has an effect on current directory? And ho...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,616
bash
# Why pipe resets current working directory? First script: ``` $ { mkdir dir; cd dir; pwd; } | cat; pwd; ./dir . ``` Second script: ``` $ { mkdir dir; cd dir; pwd; }; pwd; ./dir ./dir ``` Why this `| cat` has an effect on current directory? And how to solve it? I need the first script to work exactly as the second...
Quoting from the [manual](http://www.gnu.org/software/bash/manual/bashref.html#Pipelines): > Each command in a pipeline is executed in its own subshell (see > [Command Execution Environment](http://www.gnu.org/software/bash/manual/bashref.html#Command-Execution-Environment)). Also see [Grouping Commands](http://www.g...
18463735
How to calculate and used memory of multiple instance of a single process using powershell?
7
2013-08-27 11:08:45
<p>I have following result while running below powershell command,</p> <pre><code>PS C:\&gt; Get-Process svchost Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 546 34 18528 14884 136 49.76 260 svchost...
4,946
2,181,079
2016-03-08 17:31:11
18,464,463
11
2013-08-27 11:44:31
867,377
2013-08-27 11:44:31
https://stackoverflow.com/q/18463735
https://stackoverflow.com/a/18464463
<p>You can use the Measure-Object cmdlet</p> <pre><code>$measure = Get-Process svchost | Measure-Object PM -Sum $mem = ("{0:N2}MB " -f ($measure.sum / 1mb)) </code></pre>
<p>You can use the Measure-Object cmdlet</p> <pre><code>$measure = Get-Process svchost | Measure-Object PM -Sum $mem = ("{0:N2}MB " -f ($measure.sum / 1mb)) </code></pre>
64, 526, 24067, 36466
powershell, powershell-2.0, windows, windows-server-2008-r2
<h1>How to calculate and used memory of multiple instance of a single process using powershell?</h1> <p>I have following result while running below powershell command,</p> <pre><code>PS C:\&gt; Get-Process svchost Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,617
bash
# How to calculate and used memory of multiple instance of a single process using powershell? I have following result while running below powershell command, ``` PS C:\> Get-Process svchost Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ --...
You can use the Measure-Object cmdlet ``` $measure = Get-Process svchost | Measure-Object PM -Sum $mem = ("{0:N2}MB " -f ($measure.sum / 1mb)) ```
18268203
Powershell Test if array in one line
7
2013-08-16 07:38:14
<p>I do a get-content on a file. Sometimes there are a lot of lines, but it can happen there is only one line (or even 0)</p> <p>I was doing something like</p> <pre><code>$csv = (gc $FileIn) $lastID = $csv[0].Split(' ')[1] #First Line,2nd column </code></pre> <p>But with only one line, gc return a string and $csv[0]...
12,019
1,545,476
2013-08-16 08:05:00
18,268,656
11
2013-08-16 08:05:00
526,535
2013-08-16 08:05:00
https://stackoverflow.com/q/18268203
https://stackoverflow.com/a/18268656
<p>Instead of doing:</p> <pre><code>$csv = (gc $FileIn) </code></pre> <p>you had to </p> <pre><code>$csv = @(gc $FileIn) </code></pre> <p>Now the output will always be an array of strings irrespective of the file having one line or not. The rest of the code will just have to treat <code>$csv</code> as an array of s...
<p>Instead of doing:</p> <pre><code>$csv = (gc $FileIn) </code></pre> <p>you had to </p> <pre><code>$csv = @(gc $FileIn) </code></pre> <p>Now the output will always be an array of strings irrespective of the file having one line or not. The rest of the code will just have to treat <code>$csv</code> as an array of s...
114, 526, 2193
arrays, powershell, split
<h1>Powershell Test if array in one line</h1> <p>I do a get-content on a file. Sometimes there are a lot of lines, but it can happen there is only one line (or even 0)</p> <p>I was doing something like</p> <pre><code>$csv = (gc $FileIn) $lastID = $csv[0].Split(' ')[1] #First Line,2nd column </code></pre> <p>But with...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,618
bash
# Powershell Test if array in one line I do a get-content on a file. Sometimes there are a lot of lines, but it can happen there is only one line (or even 0) I was doing something like ``` $csv = (gc $FileIn) $lastID = $csv[0].Split(' ')[1] #First Line,2nd column ``` But with only one line, gc return a string and $...
Instead of doing: ``` $csv = (gc $FileIn) ``` you had to ``` $csv = @(gc $FileIn) ``` Now the output will always be an array of strings irrespective of the file having one line or not. The rest of the code will just have to treat `$csv` as an array of strings. This way is better than having to check if the output i...
17729235
Concatenate string literals
7
2013-07-18 16:35:53
<p>I've seen a couple posts for this, like <a href="https://stackoverflow.com/questions/4181703/how-can-i-concatenate-string-variables-in-bash">this one</a>, but none are helping me in my particular situation.</p> <pre><code>scriptsPath="/var/db/gbi/scripts/" echo "$scriptsPathawesome.csv"; </code></pre> <p>I would e...
8,683
550,309
2013-07-18 16:58:25
17,729,269
11
2013-07-18 16:37:49
982,510
2013-07-18 16:37:49
https://stackoverflow.com/q/17729235
https://stackoverflow.com/a/17729269
<p>You need to surround your variable with curly braces like so:</p> <pre><code>scriptsPath="/var/db/gbi/scripts/" echo "${scriptsPath}awesome.csv"; </code></pre>
<p>You need to surround your variable with curly braces like so:</p> <pre><code>scriptsPath="/var/db/gbi/scripts/" echo "${scriptsPath}awesome.csv"; </code></pre>
58, 387, 7792, 19847
bash, linux, string-concatenation, string-literals
<h1>Concatenate string literals</h1> <p>I've seen a couple posts for this, like <a href="https://stackoverflow.com/questions/4181703/how-can-i-concatenate-string-variables-in-bash">this one</a>, but none are helping me in my particular situation.</p> <pre><code>scriptsPath="/var/db/gbi/scripts/" echo "$scriptsPathawes...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,619
bash
# Concatenate string literals I've seen a couple posts for this, like [this one](https://stackoverflow.com/questions/4181703/how-can-i-concatenate-string-variables-in-bash), but none are helping me in my particular situation. ``` scriptsPath="/var/db/gbi/scripts/" echo "$scriptsPathawesome.csv"; ``` I would expect t...
You need to surround your variable with curly braces like so: ``` scriptsPath="/var/db/gbi/scripts/" echo "${scriptsPath}awesome.csv"; ```
17699518
order of files unix find on two directories with or command
7
2013-07-17 12:14:43
<p>What is the expected order of the files if one executes the following <code>find</code> command on Linux:</p> <pre><code>mkdir /tmp/dir1 /tmp/dir2 touch /tmp/dir1/1 /tmp/dir1/2 /tmp/dir2/1 /tmp/dir2/2 /tmp/dir2/3 /tmp/dir2/0 find /tmp/dir1 /tmp/dir2 -name 1 -or -name 0 -not -name 2 /tmp/dir1/1 /tmp/dir2/1 /tmp/dir...
1,406
719,016
2013-07-17 12:18:16
17,699,582
11
2013-07-17 12:18:16
86,604
2013-07-17 12:18:16
https://stackoverflow.com/q/17699518
https://stackoverflow.com/a/17699582
<p>The find command will search the directories in the order given. Since you said</p> <pre><code>find /tmp/dir1 /tmp/dir2 ..... </code></pre> <p>it will always first find evrything that matches below /tmp/dir1, then /tmp/dir2.</p> <p>Yet, subdirectories and files can, of course, appear in any order.</p>
<p>The find command will search the directories in the order given. Since you said</p> <pre><code>find /tmp/dir1 /tmp/dir2 ..... </code></pre> <p>it will always first find evrything that matches below /tmp/dir1, then /tmp/dir2.</p> <p>Yet, subdirectories and files can, of course, appear in any order.</p>
34, 58, 387
bash, linux, unix
<h1>order of files unix find on two directories with or command</h1> <p>What is the expected order of the files if one executes the following <code>find</code> command on Linux:</p> <pre><code>mkdir /tmp/dir1 /tmp/dir2 touch /tmp/dir1/1 /tmp/dir1/2 /tmp/dir2/1 /tmp/dir2/2 /tmp/dir2/3 /tmp/dir2/0 find /tmp/dir1 /tmp/di...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,620
bash
# order of files unix find on two directories with or command What is the expected order of the files if one executes the following `find` command on Linux: ``` mkdir /tmp/dir1 /tmp/dir2 touch /tmp/dir1/1 /tmp/dir1/2 /tmp/dir2/1 /tmp/dir2/2 /tmp/dir2/3 /tmp/dir2/0 find /tmp/dir1 /tmp/dir2 -name 1 -or -name 0 -not -na...
The find command will search the directories in the order given. Since you said ``` find /tmp/dir1 /tmp/dir2 ..... ``` it will always first find evrything that matches below /tmp/dir1, then /tmp/dir2. Yet, subdirectories and files can, of course, appear in any order.
17353326
Extracting matches using regex and then passing them into an array
7
2013-06-27 21:14:41
<pre><code> $htmltitle1 = "{Quit|Discontinue|Stop|Cease|Give Up} Tottenham Manager {HEY}" $reg = "\{.*?\}" $found = $htmltitle1 -match $reg $spuntext = @() If ($found) { ([regex]$reg).matches($htmltitle1) } </code></pre> <p>I can see the $matches (below) but how would I extract each mat...
16,539
2,529,778
2017-09-01 01:35:50
17,353,511
11
2013-06-27 21:27:27
1,630,171
2017-09-01 01:35:50
https://stackoverflow.com/q/17353326
https://stackoverflow.com/a/17353511
<p>Like this:</p> <pre><code>$htmltitle1 = "{Quit|Discontinue|Stop|Cease|Give Up} Tottenham Manager {HEY}" $reg = '{.*?}' $spuntext = $htmltitle1 | Select-String $reg -AllMatches | ForEach-Object { $_.Matches.Value } </code></pre> <p>Result:</p> <pre> PS C:\&gt; <b>$spuntext</b> {Quit|Discontinue|Stop|Ce...
<p>Like this:</p> <pre><code>$htmltitle1 = "{Quit|Discontinue|Stop|Cease|Give Up} Tottenham Manager {HEY}" $reg = '{.*?}' $spuntext = $htmltitle1 | Select-String $reg -AllMatches | ForEach-Object { $_.Matches.Value } </code></pre> <p>Result:</p> <pre> PS C:\&gt; <b>$spuntext</b> {Quit|Discontinue|Stop|Ce...
526
powershell
<h1>Extracting matches using regex and then passing them into an array</h1> <pre><code> $htmltitle1 = "{Quit|Discontinue|Stop|Cease|Give Up} Tottenham Manager {HEY}" $reg = "\{.*?\}" $found = $htmltitle1 -match $reg $spuntext = @() If ($found) { ([regex]$reg).matches($htmltitle1) } </cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,621
bash
# Extracting matches using regex and then passing them into an array ``` $htmltitle1 = "{Quit|Discontinue|Stop|Cease|Give Up} Tottenham Manager {HEY}" $reg = "\{.*?\}" $found = $htmltitle1 -match $reg $spuntext = @() If ($found) { ([regex]$reg).matches($htmltitle1) } ``` I can see the...
Like this: ``` $htmltitle1 = "{Quit|Discontinue|Stop|Cease|Give Up} Tottenham Manager {HEY}" $reg = '{.*?}' $spuntext = $htmltitle1 | Select-String $reg -AllMatches | ForEach-Object { $_.Matches.Value } ``` Result: ``` PS C:\> $spuntext {Quit|Discontinue|Stop|Cease|Give Up} {HEY} ``` **Edit:** Microsoft...
16875453
Check if string contains non digit characters
7
2013-06-01 17:44:08
<p>How can I check if a given string contains non numeric characters, examples : </p> <pre><code>x11z returns &gt; 0 x$1 also returns &gt; 0 1111~ also returns &gt; 0 </code></pre> <p>By character I mean everything not between <code>0-9</code>. I saw similar threads but non of them talks about "non 0-9" except they...
15,729
1,013,875
2013-11-15 17:44:48
16,875,489
11
2013-06-01 17:47:09
1,114,966
2013-06-01 17:47:09
https://stackoverflow.com/q/16875453
https://stackoverflow.com/a/16875489
<p>Just use a negated character class:</p> <pre><code>grep [^0-9] </code></pre> <p>This will match any non-numeric character, and not strings composed of only digits.</p>
<p>Just use a negated character class:</p> <pre><code>grep [^0-9] </code></pre> <p>This will match any non-numeric character, and not strings composed of only digits.</p>
387, 1271
bash, grep
<h1>Check if string contains non digit characters</h1> <p>How can I check if a given string contains non numeric characters, examples : </p> <pre><code>x11z returns &gt; 0 x$1 also returns &gt; 0 1111~ also returns &gt; 0 </code></pre> <p>By character I mean everything not between <code>0-9</code>. I saw similar thr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,622
bash
# Check if string contains non digit characters How can I check if a given string contains non numeric characters, examples : ``` x11z returns > 0 x$1 also returns > 0 1111~ also returns > 0 ``` By character I mean everything not between `0-9`. I saw similar threads but non of them talks about "non 0-9" except they ...
Just use a negated character class: ``` grep [^0-9] ``` This will match any non-numeric character, and not strings composed of only digits.
14717469
copying (cp) a thing that a symlink points to rather than the symlink itself
7
2013-02-05 21:41:01
<p>I know that the dirs ~/foo and ~/bar already exist.</p> <p>I know that "cp -R ~/foo ~/bar" will recursively copy the ~/foo directory into the ~/bar directory, potentially causing ~/bar/foo to be created.</p> <p>But what if foo is a symlink to a directory? Can I make the cp command copy the directory that the symli...
8,093
2,015,453
2013-02-05 21:46:03
14,717,540
11
2013-02-05 21:45:55
1,899,640
2013-02-05 21:45:55
https://stackoverflow.com/q/14717469
https://stackoverflow.com/a/14717540
<p>From <code>man cp</code>:</p> <pre><code> -L, --dereference always follow symbolic links in SOURCE </code></pre>
<p>From <code>man cp</code>:</p> <pre><code> -L, --dereference always follow symbolic links in SOURCE </code></pre>
34, 387
bash, unix
<h1>copying (cp) a thing that a symlink points to rather than the symlink itself</h1> <p>I know that the dirs ~/foo and ~/bar already exist.</p> <p>I know that "cp -R ~/foo ~/bar" will recursively copy the ~/foo directory into the ~/bar directory, potentially causing ~/bar/foo to be created.</p> <p>But what if foo is...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,623
bash
# copying (cp) a thing that a symlink points to rather than the symlink itself I know that the dirs ~/foo and ~/bar already exist. I know that "cp -R ~/foo ~/bar" will recursively copy the ~/foo directory into the ~/bar directory, potentially causing ~/bar/foo to be created. But what if foo is a symlink to a directo...
From `man cp`: ``` -L, --dereference always follow symbolic links in SOURCE ```
13891662
How to find files bigger then some size, and sort them by last modification date?
7
2012-12-15 11:13:00
<p>I need to write script which write down each files in selected catalog, which are bigger then some size. Also I need to sort them by size, name and last modification date.</p> <p>So I have made the first two cases:</p> <p><strong>Sort by size</strong></p> <pre><code>RESULTS=`find $CATALOG -size +$SIZE | sort -n -...
10,446
1,338,201
2012-12-15 11:48:54
13,891,771
11
2012-12-15 11:28:53
1,815,797
2012-12-15 11:28:53
https://stackoverflow.com/q/13891662
https://stackoverflow.com/a/13891771
<p>One of the best approaches, provided you don't have too many files, is to use <code>ls</code> to do the sorting itself.</p> <p>Sort by name and print one file per line:</p> <pre><code>find $CATALOG -size +$SIZE -exec ls -1 {} + </code></pre> <p>Sort by size and print one file per line:</p> <pre><code>find $CATAL...
<p>One of the best approaches, provided you don't have too many files, is to use <code>ls</code> to do the sorting itself.</p> <p>Sort by name and print one file per line:</p> <pre><code>find $CATALOG -size +$SIZE -exec ls -1 {} + </code></pre> <p>Sort by size and print one file per line:</p> <pre><code>find $CATAL...
387, 10193
bash, find
<h1>How to find files bigger then some size, and sort them by last modification date?</h1> <p>I need to write script which write down each files in selected catalog, which are bigger then some size. Also I need to sort them by size, name and last modification date.</p> <p>So I have made the first two cases:</p> <p><s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,624
bash
# How to find files bigger then some size, and sort them by last modification date? I need to write script which write down each files in selected catalog, which are bigger then some size. Also I need to sort them by size, name and last modification date. So I have made the first two cases: **Sort by size** ``` RES...
One of the best approaches, provided you don't have too many files, is to use `ls` to do the sorting itself. Sort by name and print one file per line: ``` find $CATALOG -size +$SIZE -exec ls -1 {} + ``` Sort by size and print one file per line: ``` find $CATALOG -size +$SIZE -exec ls -S1 {} + ``` Sort by modificat...
13149637
Csh adding strings to an array, whitespace troubles
7
2012-10-31 00:39:16
<p>I’m having trouble doing something basic with csh. I have a string:</p> <pre><code>set newCmd = "$expansionCmd –option1 –option2 …" </code></pre> <p>And I’m creating an array of these strings, which I later want to execute:</p> <pre><code>set expansionCmdList = ($expansionCmdList[*] "$newCmd") #I also tried wi...
13,481
624,869
2019-07-15 17:55:07
13,149,888
11
2012-10-31 01:10:51
797,049
2019-07-15 17:55:07
https://stackoverflow.com/q/13149637
https://stackoverflow.com/a/13149888
<p>Any time you are expanding an entire array and want to keep its individual elements' identities intact, you need the <code>:q</code> (for "quoted") modifier on the expansion. Otherwise, as soon as you do something like <code>set expansionCmdList=($expansionCmdList[*] "$newCmd")</code>, all previous commands in the ...
<p>Any time you are expanding an entire array and want to keep its individual elements' identities intact, you need the <code>:q</code> (for "quoted") modifier on the expansion. Otherwise, as soon as you do something like <code>set expansionCmdList=($expansionCmdList[*] "$newCmd")</code>, all previous commands in the ...
114, 139, 390, 531, 2829
arrays, csh, scripting, shell, string
<h1>Csh adding strings to an array, whitespace troubles</h1> <p>I’m having trouble doing something basic with csh. I have a string:</p> <pre><code>set newCmd = "$expansionCmd –option1 –option2 …" </code></pre> <p>And I’m creating an array of these strings, which I later want to execute:</p> <pre><code>set expansionC...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,625
bash
# Csh adding strings to an array, whitespace troubles I’m having trouble doing something basic with csh. I have a string: ``` set newCmd = "$expansionCmd –option1 –option2 …" ``` And I’m creating an array of these strings, which I later want to execute: ``` set expansionCmdList = ($expansionCmdList[*] "$newCmd") ...
Any time you are expanding an entire array and want to keep its individual elements' identities intact, you need the `:q` (for "quoted") modifier on the expansion. Otherwise, as soon as you do something like `set expansionCmdList=($expansionCmdList[*] "$newCmd")`, all previous commands in the list are split out into th...
12760587
search multiple pattern in file and delete line if pattern matches
7
2012-10-06 14:17:48
<p>For ex, a file contain contents:</p> <pre><code>10.45.56.84 raj 10.49.31.81 mum 10.49.31.86 mum 10.81.51.92 guj 10.45.56.116 raj 10.45.56.84 raj </code></pre> <p>I want to search <code>10.45.56.84</code> and <code>10.81.51.92</code> in the above file and delete line if pattern matches.</p> <p>Also i want to do th...
29,480
1,464,248
2018-02-01 13:56:15
12,760,805
11
2012-10-06 14:46:15
1,274,047
2012-10-06 14:46:15
https://stackoverflow.com/q/12760587
https://stackoverflow.com/a/12760805
<p>Another solution:</p> <pre><code> awk '!/10.45.56.84|10.81.51.92/' file </code></pre>
<p>Another solution:</p> <pre><code> awk '!/10.45.56.84|10.81.51.92/' file </code></pre>
34, 390, 531, 990, 5282
awk, scripting, sed, shell, unix
<h1>search multiple pattern in file and delete line if pattern matches</h1> <p>For ex, a file contain contents:</p> <pre><code>10.45.56.84 raj 10.49.31.81 mum 10.49.31.86 mum 10.81.51.92 guj 10.45.56.116 raj 10.45.56.84 raj </code></pre> <p>I want to search <code>10.45.56.84</code> and <code>10.81.51.92</code> in the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,626
bash
# search multiple pattern in file and delete line if pattern matches For ex, a file contain contents: ``` 10.45.56.84 raj 10.49.31.81 mum 10.49.31.86 mum 10.81.51.92 guj 10.45.56.116 raj 10.45.56.84 raj ``` I want to search `10.45.56.84` and `10.81.51.92` in the above file and delete line if pattern matches. Also i...
Another solution: ``` awk '!/10.45.56.84|10.81.51.92/' file ```
12314349
PowerShell date/time conversion
7
2012-09-07 08:21:42
<p>I have a variable, $date, containing <code>24 June 2012 00:00:00</code>.</p> <p>How do I convert this to <code>24/06/2012</code>?</p>
36,539
1,061,719
2017-05-01 07:38:05
12,314,542
11
2012-09-07 08:35:51
9,833
2012-09-07 08:35:51
https://stackoverflow.com/q/12314349
https://stackoverflow.com/a/12314542
<p>Use the <code>Get-Date</code> cmdlet together with the Format parameter:</p> <pre><code>PS&gt; $date = '24 June 2012 00:00:00' PS&gt; Get-Date $date -Format 'dd/MM/yyyy' 24/06/2012 </code></pre>
<p>Use the <code>Get-Date</code> cmdlet together with the Format parameter:</p> <pre><code>PS&gt; $date = '24 June 2012 00:00:00' PS&gt; Get-Date $date -Format 'dd/MM/yyyy' 24/06/2012 </code></pre>
526
powershell
<h1>PowerShell date/time conversion</h1> <p>I have a variable, $date, containing <code>24 June 2012 00:00:00</code>.</p> <p>How do I convert this to <code>24/06/2012</code>?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,627
bash
# PowerShell date/time conversion I have a variable, $date, containing `24 June 2012 00:00:00`. How do I convert this to `24/06/2012`?
Use the `Get-Date` cmdlet together with the Format parameter: ``` PS> $date = '24 June 2012 00:00:00' PS> Get-Date $date -Format 'dd/MM/yyyy' 24/06/2012 ```
12255722
How to find/grep all paths where directory name matches "x" but not "y" on *nix?
7
2012-09-04 01:28:01
<p>I have a folder structure like this (which is a small snippet):</p> <pre><code>└── test    └── cases       └── model          ├── client          │ ├── socketsTest.coffee          ├── server          │   └── socketsTest.coffee          └── shared          └── findersTest.coffee </code></p...
14,267
169,992
2012-09-04 03:08:06
12,255,734
11
2012-09-04 01:30:47
68,587
2012-09-04 03:08:06
https://stackoverflow.com/q/12255722
https://stackoverflow.com/a/12255734
<p>You can use the <code>-prune</code> action to ignore directories. <code>-o</code> means "or", so read this as, "if it's named client prune it, otherwise print files named <code>*.coffee</code>".</p> <pre><code>find test -name client -prune -o -name '*.coffee' -print </code></pre> <p>Or you can use a double test, w...
<p>You can use the <code>-prune</code> action to ignore directories. <code>-o</code> means "or", so read this as, "if it's named client prune it, otherwise print files named <code>*.coffee</code>".</p> <pre><code>find test -name client -prune -o -name '*.coffee' -print </code></pre> <p>Or you can use a double test, w...
34, 58, 390, 1271, 10193
find, grep, linux, shell, unix
<h1>How to find/grep all paths where directory name matches "x" but not "y" on *nix?</h1> <p>I have a folder structure like this (which is a small snippet):</p> <pre><code>└── test    └── cases       └── model          ├── client          │ ├── socketsTest.coffee          ├── server          │   └── s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,628
bash
# How to find/grep all paths where directory name matches "x" but not "y" on *nix? I have a folder structure like this (which is a small snippet): ``` └── test    └── cases       └── model          ├── client          │ ├── socketsTest.coffee          ├── server          │   └── socketsTest.coffee  ...
You can use the `-prune` action to ignore directories. `-o` means "or", so read this as, "if it's named client prune it, otherwise print files named `*.coffee`". ``` find test -name client -prune -o -name '*.coffee' -print ``` Or you can use a double test, which is easier to read but slightly less efficient, since it...
11951655
how to continue run script after tail -f command
7
2012-08-14 11:50:16
<p>I have the following script:</p> <pre><code>tail -f nohup.out echo 5 </code></pre> <p>When I press <kbd>Ctrl</kbd>+<kbd>C</kbd> on <code>tail -f</code>, the script stops running: the <code>5</code> is not printed. How can I run the command <code>echo 5</code> after I stop the <code>tail</code> command?</p>
3,886
486,720
2020-08-21 00:17:22
11,952,947
11
2012-08-14 13:07:48
387,076
2012-08-14 13:07:48
https://stackoverflow.com/q/11951655
https://stackoverflow.com/a/11952947
<p><kbd>Ctrl</kbd>+<kbd>C</kbd> sends the <a href="http://en.wikipedia.org/wiki/SIGINT_%28POSIX%29" rel="noreferrer">SIGINT</a> signal to all the processes in the foreground <a href="http://en.wikipedia.org/wiki/Process_group" rel="noreferrer">process group</a>. While <code>tail</code> is running, the process group con...
<p><kbd>Ctrl</kbd>+<kbd>C</kbd> sends the <a href="http://en.wikipedia.org/wiki/SIGINT_%28POSIX%29" rel="noreferrer">SIGINT</a> signal to all the processes in the foreground <a href="http://en.wikipedia.org/wiki/Process_group" rel="noreferrer">process group</a>. While <code>tail</code> is running, the process group con...
387, 2481, 7896
bash, signals, tail
<h1>how to continue run script after tail -f command</h1> <p>I have the following script:</p> <pre><code>tail -f nohup.out echo 5 </code></pre> <p>When I press <kbd>Ctrl</kbd>+<kbd>C</kbd> on <code>tail -f</code>, the script stops running: the <code>5</code> is not printed. How can I run the command <code>echo 5</cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,629
bash
# how to continue run script after tail -f command I have the following script: ``` tail -f nohup.out echo 5 ``` When I press `Ctrl`+`C` on `tail -f`, the script stops running: the `5` is not printed. How can I run the command `echo 5` after I stop the `tail` command?
`Ctrl`+`C` sends the [SIGINT](http://en.wikipedia.org/wiki/SIGINT_%28POSIX%29) signal to all the processes in the foreground [process group](http://en.wikipedia.org/wiki/Process_group). While `tail` is running, the process group consists of the `tail` process and the shell running the script. Use the [`trap`](http://p...
11527469
Output arguments in sorted order
7
2012-07-17 17:12:04
<p>I need to write a bash script that prints out its command line arguments in sorted order, one per line.</p> <p>I wrote this script and it works fine, but is there any other way? Especially without outputting it to a file and sorting.</p> <pre><code>#!/bin/bash for var in $* do echo $var &gt;&gt; file done so...
7,838
1,175,946
2012-09-30 10:01:45
11,527,518
11
2012-07-17 17:15:10
1,126,841
2012-07-17 18:05:45
https://stackoverflow.com/q/11527469
https://stackoverflow.com/a/11527518
<pre><code>#!/bin/bash for var in "$@"; do echo "$var" done | sort </code></pre> <p>You want to use <code>$@</code> in quotes (instead of <code>$*</code>) to accommodate arguments with spaces, such as </p> <pre><code>script hello "goodbye, cruel world" </code></pre> <p>The pipe gets rid of the need for a tempor...
<pre><code>#!/bin/bash for var in "$@"; do echo "$var" done | sort </code></pre> <p>You want to use <code>$@</code> in quotes (instead of <code>$*</code>) to accommodate arguments with spaces, such as </p> <pre><code>script hello "goodbye, cruel world" </code></pre> <p>The pipe gets rid of the need for a tempor...
134, 387
bash, sorting
<h1>Output arguments in sorted order</h1> <p>I need to write a bash script that prints out its command line arguments in sorted order, one per line.</p> <p>I wrote this script and it works fine, but is there any other way? Especially without outputting it to a file and sorting.</p> <pre><code>#!/bin/bash for var in ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,630
bash
# Output arguments in sorted order I need to write a bash script that prints out its command line arguments in sorted order, one per line. I wrote this script and it works fine, but is there any other way? Especially without outputting it to a file and sorting. ``` #!/bin/bash for var in $* do echo $var >> file...
``` #!/bin/bash for var in "$@"; do echo "$var" done | sort ``` You want to use `$@` in quotes (instead of `$*`) to accommodate arguments with spaces, such as ``` script hello "goodbye, cruel world" ``` The pipe gets rid of the need for a temporary file.
11456200
How can I exclude directories matching certain patterns from the output of the Linux 'find' command?
7
2012-07-12 16:18:26
<p>I want to use regex's with Linux's <code>find</code> command to dive recursively into a gargantuan directory tree, showing me all of the .c, .cpp, and .h files, but omitting matches containing certain substrings. Ultimately I want to send the output to an <code>xargs</code> command to do certain processing on all o...
14,319
1,245,420
2018-03-26 17:29:13
11,456,468
11
2012-07-12 16:34:48
180,736
2012-07-12 17:03:38
https://stackoverflow.com/q/11456200
https://stackoverflow.com/a/11456468
<p>This works for me:</p> <pre><code>find . -regextype posix-egrep -regex '.+\.(c|cpp|h)$' -not -path '*/generated/*' \ -not -path '*/deploy/*' -print0 | xargs -0 ls -L1d </code></pre> <p>Changes from your version are minimal: I added exclusions of certain path patterns separately, because that's easier, and I...
<p>This works for me:</p> <pre><code>find . -regextype posix-egrep -regex '.+\.(c|cpp|h)$' -not -path '*/generated/*' \ -not -path '*/deploy/*' -print0 | xargs -0 ls -L1d </code></pre> <p>Changes from your version are minimal: I added exclusions of certain path patterns separately, because that's easier, and I...
18, 58, 387, 1271
bash, grep, linux, regex
<h1>How can I exclude directories matching certain patterns from the output of the Linux 'find' command?</h1> <p>I want to use regex's with Linux's <code>find</code> command to dive recursively into a gargantuan directory tree, showing me all of the .c, .cpp, and .h files, but omitting matches containing certain substr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,631
bash
# How can I exclude directories matching certain patterns from the output of the Linux 'find' command? I want to use regex's with Linux's `find` command to dive recursively into a gargantuan directory tree, showing me all of the .c, .cpp, and .h files, but omitting matches containing certain substrings. Ultimately I w...
This works for me: ``` find . -regextype posix-egrep -regex '.+\.(c|cpp|h)$' -not -path '*/generated/*' \ -not -path '*/deploy/*' -print0 | xargs -0 ls -L1d ``` Changes from your version are minimal: I added exclusions of certain path patterns separately, because that's easier, and I single-quote things to hid...
10899308
How can I test if a variable is *not* a positive integer?
7
2012-06-05 14:34:20
<p>To test whether a variable is e.g. a number greater than 0, you would write:</p> <pre><code>((i &gt; 0)) </code></pre> <p>But how would I test if the variable is <code>not</code> a number greater than 0?</p> <p><strong>EDIT</strong></p> <p>Sorry for the typo, meant <code>not a number greater than 0</code>.</p> ...
34,957
1,178,669
2017-08-12 07:30:59
10,899,665
11
2012-06-05 14:56:41
742,469
2017-08-12 07:30:59
https://stackoverflow.com/q/10899308
https://stackoverflow.com/a/10899665
<p>For checking on not being number, you have to test with regex. I have used <code>-5</code> instead <code>0</code> just to demonstrate more general case (My assumption is that you use integers):</p> <pre><code>#!/bin/bash A=$1 if [[ $A =~ ^[\-0-9]+$ ]] &amp;&amp; (( A &gt; -5)); then echo "A is number and is gre...
<p>For checking on not being number, you have to test with regex. I have used <code>-5</code> instead <code>0</code> just to demonstrate more general case (My assumption is that you use integers):</p> <pre><code>#!/bin/bash A=$1 if [[ $A =~ ^[\-0-9]+$ ]] &amp;&amp; (( A &gt; -5)); then echo "A is number and is gre...
387
bash
<h1>How can I test if a variable is *not* a positive integer?</h1> <p>To test whether a variable is e.g. a number greater than 0, you would write:</p> <pre><code>((i &gt; 0)) </code></pre> <p>But how would I test if the variable is <code>not</code> a number greater than 0?</p> <p><strong>EDIT</strong></p> <p>Sorry ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,632
bash
# How can I test if a variable is *not* a positive integer? To test whether a variable is e.g. a number greater than 0, you would write: ``` ((i > 0)) ``` But how would I test if the variable is `not` a number greater than 0? **EDIT** Sorry for the typo, meant `not a number greater than 0`. **EDIT 2** Sry for th...
For checking on not being number, you have to test with regex. I have used `-5` instead `0` just to demonstrate more general case (My assumption is that you use integers): ``` #!/bin/bash A=$1 if [[ $A =~ ^[\-0-9]+$ ]] && (( A > -5)); then echo "A is number and is greater then -5" else echo "A is not a number or...
10847573
Changing powershell pipeline type to hashtable (or any other enumerable type)
7
2012-06-01 09:15:49
<p>I like to write a cmdlet "Convert-ToHashTable" which performs following task:</p> <pre><code>$HashTable = Import-Csv Table.csv | Convert-ToHashTable </code></pre> <p>Import-csv places an array on the pipeline, how can i change it to a hashtable in my Convert-ToHashTable cmdlet? In the Process part of the cmdlet i...
6,975
165,958
2012-09-10 18:58:42
10,847,711
11
2012-06-01 09:26:41
674,943
2012-06-01 09:26:41
https://stackoverflow.com/q/10847573
https://stackoverflow.com/a/10847711
<p>What do you plan to use as keys for hashtable? other than that, it should be pretty easy to do even with simple foreach-object:</p> <pre><code>Import-Csv Table.csv | Foreach-Object -begin { $Out = @{} } -process { $Out.Add('Thing you want to use as key',$_) } -end { $Out } </code></pre> <p>Don't see ne...
<p>What do you plan to use as keys for hashtable? other than that, it should be pretty easy to do even with simple foreach-object:</p> <pre><code>Import-Csv Table.csv | Foreach-Object -begin { $Out = @{} } -process { $Out.Add('Thing you want to use as key',$_) } -end { $Out } </code></pre> <p>Don't see ne...
526, 2844, 5189, 153947
hashtable, pipeline, powershell, powershell-cmdlet
<h1>Changing powershell pipeline type to hashtable (or any other enumerable type)</h1> <p>I like to write a cmdlet "Convert-ToHashTable" which performs following task:</p> <pre><code>$HashTable = Import-Csv Table.csv | Convert-ToHashTable </code></pre> <p>Import-csv places an array on the pipeline, how can i change i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,633
bash
# Changing powershell pipeline type to hashtable (or any other enumerable type) I like to write a cmdlet "Convert-ToHashTable" which performs following task: ``` $HashTable = Import-Csv Table.csv | Convert-ToHashTable ``` Import-csv places an array on the pipeline, how can i change it to a hashtable in my Convert-To...
What do you plan to use as keys for hashtable? other than that, it should be pretty easy to do even with simple foreach-object: ``` Import-Csv Table.csv | Foreach-Object -begin { $Out = @{} } -process { $Out.Add('Thing you want to use as key',$_) } -end { $Out } ``` Don't see need for any "change pipeline...
10239056
How does one properly "forward" function arguments in bash?
7
2012-04-20 01:28:20
<p>I am wondering how arguments given to a function in <code>bash</code> can be properly "forwarded" to another function or program.</p> <p>For example, in Mac OS X there is a command line program <code>open</code> (<a href="https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/open.1.h...
1,348
1,304,626
2012-04-20 01:31:36
10,239,071
11
2012-04-20 01:31:36
643,977
2012-04-20 01:31:36
https://stackoverflow.com/q/10239056
https://stackoverflow.com/a/10239071
<p>You indeed missed <code>"$@"</code>, which is designed for this case.</p>
<p>You indeed missed <code>"$@"</code>, which is designed for this case.</p>
387, 390, 2313, 5569
arguments, bash, function, shell
<h1>How does one properly "forward" function arguments in bash?</h1> <p>I am wondering how arguments given to a function in <code>bash</code> can be properly "forwarded" to another function or program.</p> <p>For example, in Mac OS X there is a command line program <code>open</code> (<a href="https://developer.apple.c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,634
bash
# How does one properly "forward" function arguments in bash? I am wondering how arguments given to a function in `bash` can be properly "forwarded" to another function or program. For example, in Mac OS X there is a command line program `open` ([man page](https://developer.apple.com/library/mac/#documentation/Darwin...
You indeed missed `"$@"`, which is designed for this case.
10197938
Last modified date of a directory in OSX
7
2012-04-17 19:36:15
<p>How do I get the last modified date of a directory in terminal?</p>
9,011
754,905
2012-04-18 12:28:13
10,198,387
11
2012-04-17 20:11:15
1,030,301
2012-04-17 23:50:33
https://stackoverflow.com/q/10197938
https://stackoverflow.com/a/10198387
<p>If you just want to get the modification date (mtime) and nothing else</p> <pre><code>stat --printf='%y\n' directory_name </code></pre> <p>or, for the date in seconds since the epoch:</p> <pre><code>stat --printf='%Y\n' directory_name </code></pre> <p>this is more straightforward, efficient and robust than solut...
<p>If you just want to get the modification date (mtime) and nothing else</p> <pre><code>stat --printf='%y\n' directory_name </code></pre> <p>or, for the date in seconds since the epoch:</p> <pre><code>stat --printf='%Y\n' directory_name </code></pre> <p>this is more straightforward, efficient and robust than solut...
369, 390
macos, shell
<h1>Last modified date of a directory in OSX</h1> <p>How do I get the last modified date of a directory in terminal?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,635
bash
# Last modified date of a directory in OSX How do I get the last modified date of a directory in terminal?
If you just want to get the modification date (mtime) and nothing else ``` stat --printf='%y\n' directory_name ``` or, for the date in seconds since the epoch: ``` stat --printf='%Y\n' directory_name ``` this is more straightforward, efficient and robust than solutions involving `ls`/`cut`/`grep`/`awk`/`find` etc ...
9722010
How to verify snapin before add?
7
2012-03-15 14:38:09
<p>I am getting following compilation issue in Powershell.</p> <blockquote> <p>Add-PSSnapin : Cannot add Windows PowerShell snap-in VMware.VimAutomation.Core because it is already added. Verify the name of the snap-in and try again.</p> </blockquote> <p>The error clearly mentions that I need to verify the name ...
8,611
399,145
2013-06-05 22:35:32
9,722,526
11
2012-03-15 15:06:35
9,833
2012-03-15 15:06:35
https://stackoverflow.com/q/9722010
https://stackoverflow.com/a/9722526
<p>You can load it if it's not loaded already:</p> <pre><code>if(-not (Get-PSSnapin VMware.VimAutomation.Core)) { Add-PSSnapin VMware.VimAutomation.Core } </code></pre> <p>You could also load it anyway and ignore the error:</p> <pre><code>Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue </code...
<p>You can load it if it's not loaded already:</p> <pre><code>if(-not (Get-PSSnapin VMware.VimAutomation.Core)) { Add-PSSnapin VMware.VimAutomation.Core } </code></pre> <p>You could also load it anyway and ignore the error:</p> <pre><code>Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue </code...
526, 24067
powershell, powershell-2.0
<h1>How to verify snapin before add?</h1> <p>I am getting following compilation issue in Powershell.</p> <blockquote> <p>Add-PSSnapin : Cannot add Windows PowerShell snap-in VMware.VimAutomation.Core because it is already added. Verify the name of the snap-in and try again.</p> </blockquote> <p>The error clearl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,636
bash
# How to verify snapin before add? I am getting following compilation issue in Powershell. > Add-PSSnapin : Cannot add Windows PowerShell snap-in > VMware.VimAutomation.Core because it is already added. Verify the name > of the snap-in and try again. The error clearly mentions that I need to verify the name of the s...
You can load it if it's not loaded already: ``` if(-not (Get-PSSnapin VMware.VimAutomation.Core)) { Add-PSSnapin VMware.VimAutomation.Core } ``` You could also load it anyway and ignore the error: ``` Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue ```
9540329
Formatting a Powershell string containing hashtable values
7
2012-03-02 21:02:28
<p>The answer to this is likely to be trivial, but I have spent half an hour and still can't work it out.</p> <p>Assume I have a the following hashtable:</p> <pre><code>$hash = @{face='Off';} </code></pre> <p>What I have tried to do, is output the value of "face" along side some other string elements.</p> <p>This w...
7,468
427,495
2012-03-03 02:52:18
9,540,428
11
2012-03-02 21:11:19
73,070
2012-03-02 21:11:19
https://stackoverflow.com/q/9540329
https://stackoverflow.com/a/9540428
<p>Sure, use a subexpression:</p> <pre><code>Write-Host Face/$($hash['face']) </code></pre> <p>Generally, I'd just use a string, if I need precise control over whitespace with Write-Host:</p> <pre><code>Write-Host "Face/$($hash['face'])" </code></pre> <p>Yes, in this case you need a subexpression again, but more be...
<p>Sure, use a subexpression:</p> <pre><code>Write-Host Face/$($hash['face']) </code></pre> <p>Generally, I'd just use a string, if I need precise control over whitespace with Write-Host:</p> <pre><code>Write-Host "Face/$($hash['face'])" </code></pre> <p>Yes, in this case you need a subexpression again, but more be...
245, 526, 5189
format, hashtable, powershell
<h1>Formatting a Powershell string containing hashtable values</h1> <p>The answer to this is likely to be trivial, but I have spent half an hour and still can't work it out.</p> <p>Assume I have a the following hashtable:</p> <pre><code>$hash = @{face='Off';} </code></pre> <p>What I have tried to do, is output the v...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,637
bash
# Formatting a Powershell string containing hashtable values The answer to this is likely to be trivial, but I have spent half an hour and still can't work it out. Assume I have a the following hashtable: ``` $hash = @{face='Off';} ``` What I have tried to do, is output the value of "face" along side some other str...
Sure, use a subexpression: ``` Write-Host Face/$($hash['face']) ``` Generally, I'd just use a string, if I need precise control over whitespace with Write-Host: ``` Write-Host "Face/$($hash['face'])" ``` Yes, in this case you need a subexpression again, but more because you simply can't include an expression like `...
9504390
Running jQuery on a static HTML file from Bash
7
2012-02-29 18:09:42
<p>I'm trying to write a simple script to simply check a webpage for a specific value:</p> <pre><code>$("a#infgHeader").text() == "Delivered"; </code></pre> <p>I'd like to automate this from a Bash script to be run at an interval. I'm also fine with using Python. I need to essentially make an HTTP request, get the re...
2,126
128,967
2012-02-29 18:53:48
9,504,474
11
2012-02-29 18:15:16
404,536
2012-02-29 18:53:48
https://stackoverflow.com/q/9504390
https://stackoverflow.com/a/9504474
<p>Xpath is great for querying html.</p> <p>Something like this:</p> <pre><code>//a[@id='infgHeader']/@text </code></pre> <p>In chrome developer tool you can use the search box in the Elements tab to test the expression.</p> <p>Quick run in terminal:</p> <pre><code>$echo '&lt;div id="test" text="foo"&gt;Hello&lt;/...
<p>Xpath is great for querying html.</p> <p>Something like this:</p> <pre><code>//a[@id='infgHeader']/@text </code></pre> <p>In chrome developer tool you can use the search box in the Elements tab to test the expression.</p> <p>Quick run in terminal:</p> <pre><code>$echo '&lt;div id="test" text="foo"&gt;Hello&lt;/...
16, 387, 820
bash, jquery, python
<h1>Running jQuery on a static HTML file from Bash</h1> <p>I'm trying to write a simple script to simply check a webpage for a specific value:</p> <pre><code>$("a#infgHeader").text() == "Delivered"; </code></pre> <p>I'd like to automate this from a Bash script to be run at an interval. I'm also fine with using Python...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,638
bash
# Running jQuery on a static HTML file from Bash I'm trying to write a simple script to simply check a webpage for a specific value: ``` $("a#infgHeader").text() == "Delivered"; ``` I'd like to automate this from a Bash script to be run at an interval. I'm also fine with using Python. I need to essentially make an H...
Xpath is great for querying html. Something like this: ``` //a[@id='infgHeader']/@text ``` In chrome developer tool you can use the search box in the Elements tab to test the expression. Quick run in terminal: ``` $echo '<div id="test" text="foo">Hello</div>' | xpath '//div[@id="test"]/@text' Found 1 nodes: -- NO...
9298699
Select all words from string except last (PowerShell)
7
2012-02-15 18:00:24
<p>So what I am trying to achieve is selecting all words from a given string, except the last one. So I have a few strings;</p> <pre><code>On The Rocks The Rocks Major Bananas </code></pre> <p>I want to select all words, except the last one from every string. I figured out I could use split() to take every word as se...
26,221
594,023
2023-08-22 08:51:16
9,298,829
11
2012-02-15 18:08:42
1,211,886
2012-02-15 18:08:42
https://stackoverflow.com/q/9298699
https://stackoverflow.com/a/9298829
<p>Here's how I might do something like this.</p> <pre><code>$Sample = "String sample we can use" $Split = $Sample.Split(" ") [string]$split[0..($Split.count-2)] </code></pre>
<p>Here's how I might do something like this.</p> <pre><code>$Sample = "String sample we can use" $Split = $Sample.Split(" ") [string]$split[0..($Split.count-2)] </code></pre>
114, 526, 2193
arrays, powershell, split
<h1>Select all words from string except last (PowerShell)</h1> <p>So what I am trying to achieve is selecting all words from a given string, except the last one. So I have a few strings;</p> <pre><code>On The Rocks The Rocks Major Bananas </code></pre> <p>I want to select all words, except the last one from every str...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,639
bash
# Select all words from string except last (PowerShell) So what I am trying to achieve is selecting all words from a given string, except the last one. So I have a few strings; ``` On The Rocks The Rocks Major Bananas ``` I want to select all words, except the last one from every string. I figured out I could use sp...
Here's how I might do something like this. ``` $Sample = "String sample we can use" $Split = $Sample.Split(" ") [string]$split[0..($Split.count-2)] ```
8682996
bash string to array with spaces and extra delimiters
7
2011-12-30 19:04:22
<p>I'm trying to create arrays from strings that have pipe ("|") as delimiters and include spaces. I've been looking around for a while and I've gotten close thanks to sources like <a href="https://stackoverflow.com/questions/918886/split-string-based-on-delimiter-in-bash">How do I split a string on a delimiter in Bash...
35,663
1,118,281
2022-07-10 22:51:49
8,683,268
11
2011-12-30 19:33:19
978,917
2011-12-30 19:33:19
https://stackoverflow.com/q/8682996
https://stackoverflow.com/a/8683268
<p>Your first attempt is pretty close. The main problems are these:</p> <ul> <li><code>for line in &#x60;cat $userList&#x60;</code> splits the file by <code>$IFS</code>, not by line-breaks. So you should set <code>IFS=$'\n'</code> before the loop, and <code>IFS='|'</code> inside the loop. (By the way, it's worth notin...
<p>Your first attempt is pretty close. The main problems are these:</p> <ul> <li><code>for line in &#x60;cat $userList&#x60;</code> splits the file by <code>$IFS</code>, not by line-breaks. So you should set <code>IFS=$'\n'</code> before the loop, and <code>IFS='|'</code> inside the loop. (By the way, it's worth notin...
114, 139, 387, 16168
arrays, bash, delimiter, string
<h1>bash string to array with spaces and extra delimiters</h1> <p>I'm trying to create arrays from strings that have pipe ("|") as delimiters and include spaces. I've been looking around for a while and I've gotten close thanks to sources like <a href="https://stackoverflow.com/questions/918886/split-string-based-on-de...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,640
bash
# bash string to array with spaces and extra delimiters I'm trying to create arrays from strings that have pipe ("|") as delimiters and include spaces. I've been looking around for a while and I've gotten close thanks to sources like [How do I split a string on a delimiter in Bash?](https://stackoverflow.com/questions...
Your first attempt is pretty close. The main problems are these: - `` for line in `cat $userList` `` splits the file by `$IFS`, not by line-breaks. So you should set `IFS=$'\n'` before the loop, and `IFS='|'` inside the loop. (By the way, it's worth noting that the `` for ... in `cat ...` `` approach reads out the ent...
7620478
iterate over argument list in linux shell
7
2011-10-01 13:21:26
<p>I want to iterate over the argument list in shell, I know how to do this with</p> <pre><code>for var in $@ </code></pre> <p>But I want to do this with</p> <pre><code>for ((i=3; i&lt;=$#; i++)) </code></pre> <p>I need this because the first two arguments won't enter into the loop. Anyone knows how to do this? Loo...
11,352
572,138
2015-10-05 17:03:15
7,620,536
11
2011-10-01 13:30:37
932,278
2011-10-02 08:30:51
https://stackoverflow.com/q/7620478
https://stackoverflow.com/a/7620536
<p>This might help:</p> <pre><code>for var in "${@:3}" </code></pre> <p>for more information you can look at:</p> <p><a href="http://www.ibm.com/developerworks/library/l-bash-parameters/index.html" rel="noreferrer">http://www.ibm.com/developerworks/library/l-bash-parameters/index.html</a></p>
<p>This might help:</p> <pre><code>for var in "${@:3}" </code></pre> <p>for more information you can look at:</p> <p><a href="http://www.ibm.com/developerworks/library/l-bash-parameters/index.html" rel="noreferrer">http://www.ibm.com/developerworks/library/l-bash-parameters/index.html</a></p>
58, 390
linux, shell
<h1>iterate over argument list in linux shell</h1> <p>I want to iterate over the argument list in shell, I know how to do this with</p> <pre><code>for var in $@ </code></pre> <p>But I want to do this with</p> <pre><code>for ((i=3; i&lt;=$#; i++)) </code></pre> <p>I need this because the first two arguments won't en...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,641
bash
# iterate over argument list in linux shell I want to iterate over the argument list in shell, I know how to do this with ``` for var in $@ ``` But I want to do this with ``` for ((i=3; i<=$#; i++)) ``` I need this because the first two arguments won't enter into the loop. Anyone knows how to do this? Looking forw...
This might help: ``` for var in "${@:3}" ``` for more information you can look at: <http://www.ibm.com/developerworks/library/l-bash-parameters/index.html>
6942097
Finding next open port
7
2011-08-04 13:15:43
<p>Is there any way, using basic Unix commands, to find the next unused port number, starting at port 4444 and going upwards? I'm ssh'ed (via openssh) into a Windows XP machine, running Cygwin tools and using a bash shell.</p> <p>Thanks, - Dave</p>
6,613
623,658
2016-12-16 04:56:37
6,943,581
11
2011-08-04 14:50:10
478,681
2011-08-04 20:48:27
https://stackoverflow.com/q/6942097
https://stackoverflow.com/a/6943581
<p>Try this:</p> <pre><code>for port in $(seq 4444 65000); do echo -ne "\035" | telnet 127.0.0.1 $port &gt; /dev/null 2&gt;&amp;1; [ $? -eq 1 ] &amp;&amp; echo "unused $port" &amp;&amp; break; done </code></pre> <p>where</p> <pre><code>seq 4444 65000 - port range for check echo -ne "\035" - escape character to force...
<p>Try this:</p> <pre><code>for port in $(seq 4444 65000); do echo -ne "\035" | telnet 127.0.0.1 $port &gt; /dev/null 2&gt;&amp;1; [ $? -eq 1 ] &amp;&amp; echo "unused $port" &amp;&amp; break; done </code></pre> <p>where</p> <pre><code>seq 4444 65000 - port range for check echo -ne "\035" - escape character to force...
34, 387, 390, 1731
bash, cygwin, shell, unix
<h1>Finding next open port</h1> <p>Is there any way, using basic Unix commands, to find the next unused port number, starting at port 4444 and going upwards? I'm ssh'ed (via openssh) into a Windows XP machine, running Cygwin tools and using a bash shell.</p> <p>Thanks, - Dave</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,642
bash
# Finding next open port Is there any way, using basic Unix commands, to find the next unused port number, starting at port 4444 and going upwards? I'm ssh'ed (via openssh) into a Windows XP machine, running Cygwin tools and using a bash shell. Thanks, - Dave
Try this: ``` for port in $(seq 4444 65000); do echo -ne "\035" | telnet 127.0.0.1 $port > /dev/null 2>&1; [ $? -eq 1 ] && echo "unused $port" && break; done ``` where ``` seq 4444 65000 - port range for check echo -ne "\035" - escape character to force close telnet session (^]) ``` if telnet finishes with exit cod...
5578907
PowerShell BizTalk scripts WITHOUT using BizTalk provider for PowerShell
7
2011-04-07 09:30:42
<p>I have been using the excellent BizTalk Provider for PowerShell from Codeplex for a while now. However in my new company the build team are not comfortable using it so I need to rewrite all my handy configuration scripts to not use it. </p> <p>I have re-done most of them but am having some problems finding examples...
7,470
569,662
2017-01-16 13:30:01
5,582,880
11
2011-04-07 14:40:37
569,662
2012-04-19 10:24:36
https://stackoverflow.com/q/5578907
https://stackoverflow.com/a/5582880
<p>OK here are my finished hacky powershell functions if anyone else needs them:</p> <pre><code>function write-WarnMessage([string]$message) { Write-Host $(Get-Date) $message -ForegroundColor Yellow } function write-SucessMessage([string]$message) { Write-Host $(Get-Date) $message -ForegroundColor Green } fu...
<p>OK here are my finished hacky powershell functions if anyone else needs them:</p> <pre><code>function write-WarnMessage([string]$message) { Write-Host $(Get-Date) $message -ForegroundColor Yellow } function write-SucessMessage([string]$message) { Write-Host $(Get-Date) $message -ForegroundColor Green } fu...
526, 2450
biztalk, powershell
<h1>PowerShell BizTalk scripts WITHOUT using BizTalk provider for PowerShell</h1> <p>I have been using the excellent BizTalk Provider for PowerShell from Codeplex for a while now. However in my new company the build team are not comfortable using it so I need to rewrite all my handy configuration scripts to not use it....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,643
bash
# PowerShell BizTalk scripts WITHOUT using BizTalk provider for PowerShell I have been using the excellent BizTalk Provider for PowerShell from Codeplex for a while now. However in my new company the build team are not comfortable using it so I need to rewrite all my handy configuration scripts to not use it. I have ...
OK here are my finished hacky powershell functions if anyone else needs them: ``` function write-WarnMessage([string]$message) { Write-Host $(Get-Date) $message -ForegroundColor Yellow } function write-SucessMessage([string]$message) { Write-Host $(Get-Date) $message -ForegroundColor Green } function write-I...
5287874
Buffer overflow attack format
7
2011-03-13 06:28:18
<p>Usually we all see the basic buffer overflow format which has :- <code>NOPs + shellcode + return_address</code></p> <p>Why dont we use, <code>NOPs + return_address + shellcode?</code> where we make the return address point to the start of the shellcode?</p> <p>Im guessing that this is because we might be trying to...
1,573
null
2012-03-20 19:38:44
5,288,580
11
2011-03-13 09:42:05
183,528
2011-03-13 21:24:43
https://stackoverflow.com/q/5287874
https://stackoverflow.com/a/5288580
<p>The return address can come before the <code>shellcode+nop sled</code> or after. For instance if you are writing to a variable close the top of the stack you might have to write your <code>nop sled+shell code</code> past the Return address (EIP) because there might not be enough room. </p> <p>However, the NOP s...
<p>The return address can come before the <code>shellcode+nop sled</code> or after. For instance if you are writing to a variable close the top of the stack you might have to write your <code>nop sled+shell code</code> past the Return address (EIP) because there might not be enough room. </p> <p>However, the NOP s...
8, 136, 823, 10606, 78469
buffer-overflow, c, security, shellcode, x86
<h1>Buffer overflow attack format</h1> <p>Usually we all see the basic buffer overflow format which has :- <code>NOPs + shellcode + return_address</code></p> <p>Why dont we use, <code>NOPs + return_address + shellcode?</code> where we make the return address point to the start of the shellcode?</p> <p>Im guessing tha...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,644
bash
# Buffer overflow attack format Usually we all see the basic buffer overflow format which has :- `NOPs + shellcode + return_address` Why dont we use, `NOPs + return_address + shellcode?` where we make the return address point to the start of the shellcode? Im guessing that this is because we might be trying to write...
The return address can come before the `shellcode+nop sled` or after. For instance if you are writing to a variable close the top of the stack you might have to write your `nop sled+shell code` past the Return address (EIP) because there might not be enough room. However, the NOP sled will always be next to the shell ...
5077836
bash - how to find current shell command
7
2011-02-22 11:59:34
<p>When I run a command, I need to set some shell environment variable that holds the current command from inside ".bashrc". Actually I need to update PROMPT_COMMAND whenever a command is run, and I need the whole command line, from where I will pick relevant value. </p> <pre><code>PROMPT_COMMAND='TITLE=`echo !!`; ech...
8,805
1,678,010
2011-02-22 16:02:35
5,080,576
11
2011-02-22 16:02:35
26,428
2011-02-22 16:02:35
https://stackoverflow.com/q/5077836
https://stackoverflow.com/a/5080576
<p>If you're trying to update the title of the xterm, you can use a DEBUG trap:</p> <pre><code>trap 'echo "$BASH_COMMAND"' DEBUG </code></pre> <p>See this <a href="http://www.davidpashley.com/articles/xterm-titles-with-bash.html" rel="noreferrer">blog post</a>.</p>
<p>If you're trying to update the title of the xterm, you can use a DEBUG trap:</p> <pre><code>trap 'echo "$BASH_COMMAND"' DEBUG </code></pre> <p>See this <a href="http://www.davidpashley.com/articles/xterm-titles-with-bash.html" rel="noreferrer">blog post</a>.</p>
387, 1318, 9013
bash, environment-variables, history
<h1>bash - how to find current shell command</h1> <p>When I run a command, I need to set some shell environment variable that holds the current command from inside ".bashrc". Actually I need to update PROMPT_COMMAND whenever a command is run, and I need the whole command line, from where I will pick relevant value. </p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,645
bash
# bash - how to find current shell command When I run a command, I need to set some shell environment variable that holds the current command from inside ".bashrc". Actually I need to update PROMPT_COMMAND whenever a command is run, and I need the whole command line, from where I will pick relevant value. ``` PROMPT_...
If you're trying to update the title of the xterm, you can use a DEBUG trap: ``` trap 'echo "$BASH_COMMAND"' DEBUG ``` See this [blog post](http://www.davidpashley.com/articles/xterm-titles-with-bash.html).
4196161
Bash read backspace button behavior problem
7
2010-11-16 16:04:42
<p>When using read in bash, pressing backspace does not delete the last character entered, but appears to append a backspace to the input buffer. Is there any way I can change it so that delete removes the last key typed from the input? If so how?</p> <p>Here's a short example prog I'm using it with if it's of any hel...
7,434
421,652
2018-12-16 12:10:27
4,196,460
11
2010-11-16 16:32:56
188,031
2012-11-29 19:23:19
https://stackoverflow.com/q/4196161
https://stackoverflow.com/a/4196460
<p>The option <code>-n nchars</code> turns the terminal into raw mode, so your best chance is to rely on <code>readline</code> (-e)<a href="http://ss64.com/bash/read.html" rel="noreferrer"> [docs]</a>: </p> <pre><code>$ read -n10 -e VAR </code></pre> <p>BTW, nice idea, although I would leave the end of the word to th...
<p>The option <code>-n nchars</code> turns the terminal into raw mode, so your best chance is to rely on <code>readline</code> (-e)<a href="http://ss64.com/bash/read.html" rel="noreferrer"> [docs]</a>: </p> <pre><code>$ read -n10 -e VAR </code></pre> <p>BTW, nice idea, although I would leave the end of the word to th...
387, 35759
backspace, bash
<h1>Bash read backspace button behavior problem</h1> <p>When using read in bash, pressing backspace does not delete the last character entered, but appears to append a backspace to the input buffer. Is there any way I can change it so that delete removes the last key typed from the input? If so how?</p> <p>Here's a sh...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,646
bash
# Bash read backspace button behavior problem When using read in bash, pressing backspace does not delete the last character entered, but appears to append a backspace to the input buffer. Is there any way I can change it so that delete removes the last key typed from the input? If so how? Here's a short example prog...
The option `-n nchars` turns the terminal into raw mode, so your best chance is to rely on `readline` (-e) [[docs]](http://ss64.com/bash/read.html): ``` $ read -n10 -e VAR ``` BTW, nice idea, although I would leave the end of the word to the user (it's a knee-jerk reaction to press *return*).
4181342
What is this character ` called?
7
2010-11-15 04:16:14
<p>I never noticed the character ` (the one in the same key as tilde ~). There is another single quote character ' in the same key as ". I see that the characters ` and ' aren't interchangeable whereas ' and " are. <br> I spent a lot of time due to that when compiling GTK programs. It gave error (file not found), and f...
3,254
null
2010-11-15 04:42:18
4,181,344
11
2010-11-15 04:16:42
126,042
2010-11-15 04:16:42
https://stackoverflow.com/q/4181342
https://stackoverflow.com/a/4181344
<p>It's typically called a "<a href="http://en.wikipedia.org/wiki/Grave_accent" rel="noreferrer">backtick</a>", and in bash, it is used for <a href="http://tldp.org/LDP/abs/html/commandsub.html" rel="noreferrer">command substitution</a> (although the <code>$(cmd)</code> construct is usually preferred due to easier nest...
<p>It's typically called a "<a href="http://en.wikipedia.org/wiki/Grave_accent" rel="noreferrer">backtick</a>", and in bash, it is used for <a href="http://tldp.org/LDP/abs/html/commandsub.html" rel="noreferrer">command substitution</a> (although the <code>$(cmd)</code> construct is usually preferred due to easier nest...
8, 58, 127, 387, 1231
bash, c, command-line, gtk, linux
<h1>What is this character ` called?</h1> <p>I never noticed the character ` (the one in the same key as tilde ~). There is another single quote character ' in the same key as ". I see that the characters ` and ' aren't interchangeable whereas ' and " are. <br> I spent a lot of time due to that when compiling GTK progr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,647
bash
# What is this character ` called? I never noticed the character ` (the one in the same key as tilde ~). There is another single quote character ' in the same key as ". I see that the characters ` and ' aren't interchangeable whereas ' and " are. I spent a lot of time due to that when compiling GTK programs. It gav...
It's typically called a "[backtick](http://en.wikipedia.org/wiki/Grave_accent)", and in bash, it is used for [command substitution](http://tldp.org/LDP/abs/html/commandsub.html) (although the `$(cmd)` construct is usually preferred due to easier nesting).
3807761
Run `head` on a text file inside a zipped archive without unpacking the archive
7
2010-09-27 20:51:04
<p>Greetings,</p> <p>I've taken over from a prior team and writing ETL jobs which process csv files. I use a combination of shell scripts and perl on ubuntu. The csv files are huge; they arrive as zipped archives. Unzipped, many are more than 30Gb - yes, that's a G</p> <p>Legacy process is a batch job running on cron...
3,254
371,814
2010-09-28 07:51:38
3,807,807
11
2010-09-27 20:57:41
6,782
2010-09-28 07:51:38
https://stackoverflow.com/q/3807761
https://stackoverflow.com/a/3807807
<p>The <a href="http://linux.die.net/man/1/unzip" rel="noreferrer"><code>unzip</code></a> command line utility has a <code>-p</code> option which dumps a file to standard out. Just pipe that into <a href="http://linux.die.net/man/1/head" rel="noreferrer"><code>head</code></a> and it'll not bother extracting the whole...
<p>The <a href="http://linux.die.net/man/1/unzip" rel="noreferrer"><code>unzip</code></a> command line utility has a <code>-p</code> option which dumps a file to standard out. Just pipe that into <a href="http://linux.die.net/man/1/head" rel="noreferrer"><code>head</code></a> and it'll not bother extracting the whole...
390, 580, 881, 1357, 2278
etl, parsing, perl, shell, zip
<h1>Run `head` on a text file inside a zipped archive without unpacking the archive</h1> <p>Greetings,</p> <p>I've taken over from a prior team and writing ETL jobs which process csv files. I use a combination of shell scripts and perl on ubuntu. The csv files are huge; they arrive as zipped archives. Unzipped, many a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,648
bash
# Run `head` on a text file inside a zipped archive without unpacking the archive Greetings, I've taken over from a prior team and writing ETL jobs which process csv files. I use a combination of shell scripts and perl on ubuntu. The csv files are huge; they arrive as zipped archives. Unzipped, many are more than 30G...
The [`unzip`](http://linux.die.net/man/1/unzip) command line utility has a `-p` option which dumps a file to standard out. Just pipe that into [`head`](http://linux.die.net/man/1/head) and it'll not bother extracting the whole file to disk. Alternatively, from [`perldoc IO::Compress::Zip`](http://p3rl.org/IO%3a%3aComp...
3498799
unix commandline for inline replacement of all newlines in file with <br>\n
7
2010-08-17 02:01:31
<pre><code>sed 's/$/&lt;br&gt;/' mytext.txt </code></pre> <p>worked but output it all on the command line. I want it to just do the replacement WITHIN the specified file itself. Should I be using another tool?</p>
7,820
404,039
2012-01-13 15:40:44
3,498,818
11
2010-08-17 02:05:23
23,744
2010-08-17 02:57:43
https://stackoverflow.com/q/3498799
https://stackoverflow.com/a/3498818
<p>If you have gnu sed, you can use the <code>-i</code> option, which will do the replacement in place.</p> <pre><code>sed -i 's/$/&lt;br&gt;/' mytext.txt </code></pre> <p>Otherwise you will have to redirect to another file and rename it over the old one.</p> <pre><code>sed 's/$/&lt;br&gt;/' mytext.txt &gt; mytext.t...
<p>If you have gnu sed, you can use the <code>-i</code> option, which will do the replacement in place.</p> <pre><code>sed -i 's/$/&lt;br&gt;/' mytext.txt </code></pre> <p>Otherwise you will have to redirect to another file and rename it over the old one.</p> <pre><code>sed 's/$/&lt;br&gt;/' mytext.txt &gt; mytext.t...
34, 387, 1231, 5282
bash, command-line, sed, unix
<h1>unix commandline for inline replacement of all newlines in file with <br>\n</h1> <pre><code>sed 's/$/&lt;br&gt;/' mytext.txt </code></pre> <p>worked but output it all on the command line. I want it to just do the replacement WITHIN the specified file itself. Should I be using another tool?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,649
bash
# unix commandline for inline replacement of all newlines in file with \n ``` sed 's/$/<br>/' mytext.txt ``` worked but output it all on the command line. I want it to just do the replacement WITHIN the specified file itself. Should I be using another tool?
If you have gnu sed, you can use the `-i` option, which will do the replacement in place. ``` sed -i 's/$/<br>/' mytext.txt ``` Otherwise you will have to redirect to another file and rename it over the old one. ``` sed 's/$/<br>/' mytext.txt > mytext.txt.new && mv mytext.txt.new mytext.txt ```
3273049
Forcing a python script to take input from STDIN
7
2010-07-17 19:58:22
<p>A python script I need to run takes input only from a file passed as a command line argument, like so:</p> <pre><code>$ markdown.py input_file </code></pre> <p>Is there any way to get it to accept input from STDIN instead? I want to be able to do this through Bash, without significantly modifying the python script...
3,986
394,835
2013-03-21 11:48:48
3,273,071
11
2010-07-17 20:04:57
126,042
2010-07-17 20:04:57
https://stackoverflow.com/q/3273049
https://stackoverflow.com/a/3273071
<p>I'm not sure how portable it is, but on Unix-y systems you can name <code>/dev/stdin</code> as your file:</p> <pre><code>$ echo -n hi there | wc /dev/stdin 0 2 8 /dev/stdin </code></pre>
<p>I'm not sure how portable it is, but on Unix-y systems you can name <code>/dev/stdin</code> as your file:</p> <pre><code>$ echo -n hi there | wc /dev/stdin 0 2 8 /dev/stdin </code></pre>
16, 387
bash, python
<h1>Forcing a python script to take input from STDIN</h1> <p>A python script I need to run takes input only from a file passed as a command line argument, like so:</p> <pre><code>$ markdown.py input_file </code></pre> <p>Is there any way to get it to accept input from STDIN instead? I want to be able to do this throu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,650
bash
# Forcing a python script to take input from STDIN A python script I need to run takes input only from a file passed as a command line argument, like so: ``` $ markdown.py input_file ``` Is there any way to get it to accept input from STDIN instead? I want to be able to do this through Bash, without significantly mo...
I'm not sure how portable it is, but on Unix-y systems you can name `/dev/stdin` as your file: ``` $ echo -n hi there | wc /dev/stdin 0 2 8 /dev/stdin ```
3222379
How to efficiently convert long int to dotted quad IP in bash
7
2010-07-11 08:28:49
<p>I have a lot of IP addresses in a large mysql DB stored as long int's. I need an efficient/quick way to convert them back to an IP within a BASH shell script ( or have mysql return the results as an IP?? ).</p> <p>Note: specifically don't want to call perl, awk, or other 'language'.</p>
11,387
336,263
2014-03-18 16:55:48
3,222,390
11
2010-07-11 08:32:46
60,950
2010-07-11 08:32:46
https://stackoverflow.com/q/3222379
https://stackoverflow.com/a/3222390
<p>See the <a href="http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html#function_inet-ntoa" rel="noreferrer"><code>INET_NTOA</code></a> function, you can use that to convert the number to an IP on the MySQL server.</p>
<p>See the <a href="http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html#function_inet-ntoa" rel="noreferrer"><code>INET_NTOA</code></a> function, you can use that to convert the number to an IP on the MySQL server.</p>
21, 387
bash, mysql
<h1>How to efficiently convert long int to dotted quad IP in bash</h1> <p>I have a lot of IP addresses in a large mysql DB stored as long int's. I need an efficient/quick way to convert them back to an IP within a BASH shell script ( or have mysql return the results as an IP?? ).</p> <p>Note: specifically don't want t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,651
bash
# How to efficiently convert long int to dotted quad IP in bash I have a lot of IP addresses in a large mysql DB stored as long int's. I need an efficient/quick way to convert them back to an IP within a BASH shell script ( or have mysql return the results as an IP?? ). Note: specifically don't want to call perl, awk...
See the [`INET_NTOA`](http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html#function_inet-ntoa) function, you can use that to convert the number to an IP on the MySQL server.
2680274
How to removing leading section in bash
7
2010-04-21 04:13:56
<p>How can I remove parts of a string up to a certain character?</p> <p>Ex.) If I have the string <code>testFile.txt.1</code> and <code>testFile.txt.12345</code> how can I remove the <code>1</code> and <code>12345</code>?</p> <p>EDIT: I meant to remove and throw away the first part of a string up to a certain charact...
12,383
295,183
2015-06-30 15:40:28
2,680,295
11
2010-04-21 04:20:06
131,527
2010-04-21 04:20:06
https://stackoverflow.com/q/2680274
https://stackoverflow.com/a/2680295
<p>using just bash facilities</p> <pre><code>$ s=testFile.txt.1 $ echo ${s%.*} testFile.txt $ s=testFile.txt.12345 $ echo ${s%.*} testFile.txt </code></pre> <p>to remove before leading zero</p> <pre><code>$ echo ${s#*.} txt.12345 </code></pre> <p>Other method, you can split your string up using IFS</p> <pre><code...
<p>using just bash facilities</p> <pre><code>$ s=testFile.txt.1 $ echo ${s%.*} testFile.txt $ s=testFile.txt.12345 $ echo ${s%.*} testFile.txt </code></pre> <p>to remove before leading zero</p> <pre><code>$ echo ${s#*.} txt.12345 </code></pre> <p>Other method, you can split your string up using IFS</p> <pre><code...
139, 387
bash, string
<h1>How to removing leading section in bash</h1> <p>How can I remove parts of a string up to a certain character?</p> <p>Ex.) If I have the string <code>testFile.txt.1</code> and <code>testFile.txt.12345</code> how can I remove the <code>1</code> and <code>12345</code>?</p> <p>EDIT: I meant to remove and throw away t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,652
bash
# How to removing leading section in bash How can I remove parts of a string up to a certain character? Ex.) If I have the string `testFile.txt.1` and `testFile.txt.12345` how can I remove the `1` and `12345`? EDIT: I meant to remove and throw away the first part of a string up to a certain character and keep the en...
using just bash facilities ``` $ s=testFile.txt.1 $ echo ${s%.*} testFile.txt $ s=testFile.txt.12345 $ echo ${s%.*} testFile.txt ``` to remove before leading zero ``` $ echo ${s#*.} txt.12345 ``` Other method, you can split your string up using IFS ``` $ s=testFile.txt.12345 $ IFS="." $ set -- $s $ echo $1 testFi...
2494902
how to write a bash script like the ones used in init.d?
7
2010-03-22 18:51:25
<p>I have to write a bash script that makes lot of things. I'd like to print messages as nice as init scripts do. For example: </p> <pre><code> Doing A... [OK] Doing B... [ERROR] .... </code></pre> <p>Do you know any way to make this?</p> <p>Thanks in advance</p>
6,755
288,247
2015-02-09 13:52:23
2,494,928
11
2010-03-22 18:56:39
29,809
2010-03-22 18:56:39
https://stackoverflow.com/q/2494902
https://stackoverflow.com/a/2494928
<p>On all my Linux boxes, the code to do that is in the file:</p> <pre><code>/etc/init.d/functions </code></pre> <p>If you include that file (<code>. /etc/init.d/functions</code>) and then run your code doing this:</p> <pre><code>action /path/to/prog args </code></pre> <p>you will get the functionality you want.</p...
<p>On all my Linux boxes, the code to do that is in the file:</p> <pre><code>/etc/init.d/functions </code></pre> <p>If you include that file (<code>. /etc/init.d/functions</code>) and then run your code doing this:</p> <pre><code>action /path/to/prog args </code></pre> <p>you will get the functionality you want.</p...
387, 531
bash, scripting
<h1>how to write a bash script like the ones used in init.d?</h1> <p>I have to write a bash script that makes lot of things. I'd like to print messages as nice as init scripts do. For example: </p> <pre><code> Doing A... [OK] Doing B... [ERROR] .... </code></pre> <p>Do you know any way to make this?</p> <p>Th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,653
bash
# how to write a bash script like the ones used in init.d? I have to write a bash script that makes lot of things. I'd like to print messages as nice as init scripts do. For example: ``` Doing A... [OK] Doing B... [ERROR] .... ``` Do you know any way to make this? Thanks in advance
On all my Linux boxes, the code to do that is in the file: ``` /etc/init.d/functions ``` If you include that file (`. /etc/init.d/functions`) and then run your code doing this: ``` action /path/to/prog args ``` you will get the functionality you want.
2391272
gawk / awk: piping date to getline *sometimes* won't work
7
2010-03-06 03:46:57
<p>I'm attempting to convert dates from one format to another: From e.g. "October 29, 2005" to 2005-10-29. I have a list of 625 dates. I use Awk.</p> <p>The conversion works -- most of the time. Hovewer, sometimes the conversion won't happen at all, and the variable supposed to hold the (converted) date remains undefi...
4,610
694,469
2011-09-27 13:56:10
2,391,314
11
2010-03-06 04:07:51
66,516
2011-09-27 13:56:10
https://stackoverflow.com/q/2391272
https://stackoverflow.com/a/2391314
<p>Whenever you open a pipe or file for reading or writing in <code>awk</code>, the latter <strong>will first check</strong> (using an internal hash) <strong>whether it already has a pipe or file with the same name</strong> (still) open; if so, <strong>it will reuse the existing file descriptor</strong> instead of reop...
<p>Whenever you open a pipe or file for reading or writing in <code>awk</code>, the latter <strong>will first check</strong> (using an internal hash) <strong>whether it already has a pipe or file with the same name</strong> (still) open; if so, <strong>it will reuse the existing file descriptor</strong> instead of reop...
387, 990, 5813, 13037, 13089
awk, bash, gawk, getline, pipe
<h1>gawk / awk: piping date to getline *sometimes* won't work</h1> <p>I'm attempting to convert dates from one format to another: From e.g. "October 29, 2005" to 2005-10-29. I have a list of 625 dates. I use Awk.</p> <p>The conversion works -- most of the time. Hovewer, sometimes the conversion won't happen at all, an...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,654
bash
# gawk / awk: piping date to getline *sometimes* won't work I'm attempting to convert dates from one format to another: From e.g. "October 29, 2005" to 2005-10-29. I have a list of 625 dates. I use Awk. The conversion works -- most of the time. Hovewer, sometimes the conversion won't happen at all, and the variable s...
Whenever you open a pipe or file for reading or writing in `awk`, the latter **will first check** (using an internal hash) **whether it already has a pipe or file with the same name** (still) open; if so, **it will reuse the existing file descriptor** instead of reopening the pipe or file. In your case, all entries wh...
1741546
How to input special character in cmd?
7
2009-11-16 11:17:07
<p>I have written a c program that retrieves arguments from the command line under Windows. One of the arguments is a regular expression. So I need to retrieve special characters such as "( , .", etc., but cmd.exe treats "(" as a special character.</p> <p>How could I input these special character?</p> <p>thanks.</p>
29,493
193,251
2012-07-23 07:29:20
1,741,555
11
2009-11-16 11:18:21
73,070
2009-11-16 12:02:36
https://stackoverflow.com/q/1741546
https://stackoverflow.com/a/1741555
<p>You can put the arguments in quotes:</p> <pre><code>myprogram.exe "(this is some text, with special characters.)" </code></pre> <p>Though I wouldn't assume that parentheses cause problems <em>unless</em> you are using blocks for conditional statements or loops in a batch file. The usual array of characters that ar...
<p>You can put the arguments in quotes:</p> <pre><code>myprogram.exe "(this is some text, with special characters.)" </code></pre> <p>Though I wouldn't assume that parentheses cause problems <em>unless</em> you are using blocks for conditional statements or loops in a batch file. The usual array of characters that ar...
390, 2631
cmd, shell
<h1>How to input special character in cmd?</h1> <p>I have written a c program that retrieves arguments from the command line under Windows. One of the arguments is a regular expression. So I need to retrieve special characters such as "( , .", etc., but cmd.exe treats "(" as a special character.</p> <p>How could I inp...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,655
bash
# How to input special character in cmd? I have written a c program that retrieves arguments from the command line under Windows. One of the arguments is a regular expression. So I need to retrieve special characters such as "( , .", etc., but cmd.exe treats "(" as a special character. How could I input these special...
You can put the arguments in quotes: ``` myprogram.exe "(this is some text, with special characters.)" ``` Though I wouldn't assume that parentheses cause problems *unless* you are using blocks for conditional statements or loops in a batch file. The usual array of characters that are treated specially by the shell a...
913788
Powershell being too clever
7
2009-05-27 03:20:55
<p>Apologies for what is probably a newbish question.</p> <p>I am writing some Powershell scripts that run various queries against AD. They will usually return a bunch of results, which are easy to deal with, ie:</p> <pre><code>$results = myQuery write-host "Returned " + $results.Count + " results." foreach ($result ...
340
102,648
2009-05-28 22:38:21
913,815
11
2009-05-27 03:31:47
102,937
2009-05-27 03:31:47
https://stackoverflow.com/q/913788
https://stackoverflow.com/a/913815
<p>Change the first line of code to</p> <pre><code>$results = @(myQuery) </code></pre> <p>This will always return an array. See <a href="http://blogs.msdn.com/powershell/archive/2007/01/23/array-literals-in-powershell.aspx" rel="nofollow noreferrer">this blog entry</a> for additional details.</p>
<p>Change the first line of code to</p> <pre><code>$results = @(myQuery) </code></pre> <p>This will always return an array. See <a href="http://blogs.msdn.com/powershell/archive/2007/01/23/array-literals-in-powershell.aspx" rel="nofollow noreferrer">this blog entry</a> for additional details.</p>
526
powershell
<h1>Powershell being too clever</h1> <p>Apologies for what is probably a newbish question.</p> <p>I am writing some Powershell scripts that run various queries against AD. They will usually return a bunch of results, which are easy to deal with, ie:</p> <pre><code>$results = myQuery write-host "Returned " + $results....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,656
bash
# Powershell being too clever Apologies for what is probably a newbish question. I am writing some Powershell scripts that run various queries against AD. They will usually return a bunch of results, which are easy to deal with, ie: ``` $results = myQuery write-host "Returned " + $results.Count + " results." foreach...
Change the first line of code to ``` $results = @(myQuery) ``` This will always return an array. See [this blog entry](http://blogs.msdn.com/powershell/archive/2007/01/23/array-literals-in-powershell.aspx) for additional details.
158359
In PowerShell, how can I determine if the current drive is a networked drive or not?
7
2008-10-01 16:01:23
<p>I need to know, from within Powershell, if the current drive is a mapped drive or not.</p> <p>Unfortunately, Get-PSDrive is not working "as expected":</p> <pre><code>PS:24 H:\temp &gt;get-psdrive h Name Provider Root CurrentLocation ---- -------- ---- --------------- H Fi...
8,041
12,344
2015-08-24 17:52:29
158,456
11
2008-10-01 16:19:27
2,459
2008-10-01 16:19:27
https://stackoverflow.com/q/158359
https://stackoverflow.com/a/158456
<p>Use the .NET framework:</p> <pre><code>PS H:\&gt; $x = new-object system.io.driveinfo("h:\") PS H:\&gt; $x.drivetype Network </code></pre>
<p>Use the .NET framework:</p> <pre><code>PS H:\&gt; $x = new-object system.io.driveinfo("h:\") PS H:\&gt; $x.drivetype Network </code></pre>
9, 526, 794, 10211
c#, mapped-drive, network-programming, powershell
<h1>In PowerShell, how can I determine if the current drive is a networked drive or not?</h1> <p>I need to know, from within Powershell, if the current drive is a mapped drive or not.</p> <p>Unfortunately, Get-PSDrive is not working "as expected":</p> <pre><code>PS:24 H:\temp &gt;get-psdrive h Name Provider ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,657
bash
# In PowerShell, how can I determine if the current drive is a networked drive or not? I need to know, from within Powershell, if the current drive is a mapped drive or not. Unfortunately, Get-PSDrive is not working "as expected": ``` PS:24 H:\temp >get-psdrive h Name Provider Root CurrentLocation ...
Use the .NET framework: ``` PS H:\> $x = new-object system.io.driveinfo("h:\") PS H:\> $x.drivetype Network ```
79667070
Linux character class matching not working for this expression
6
2025-06-16 04:59:48
<p>I'm trying to write a matcher that matches any of v1.65.x, v1.66.x or v1.67.x. But the moment I introduce a character class, it doesn't work with either a list of characters or a range:</p> <pre><code>if [[ &quot;v1.67.x&quot; =~ &quot;v1.67&quot; ]]; then echo matches; else echo no match fi </code></pre> <p>outputs...
107
474,323
2025-06-16 18:11:03
79,667,090
11
2025-06-16 05:23:39
893,780
2025-06-16 18:11:03
https://stackoverflow.com/q/79667070
https://stackoverflow.com/a/79667090
<p>This is explained <a href="https://www.gnu.org/software/bash/manual/bash.html#index-_005b_005b" rel="nofollow noreferrer">in the fine manual</a>:</p> <blockquote> <p>If any part of the pattern is quoted, the quoted portion is matched literally. This means every character in the quoted portion matches itself, ins...
<p>This is explained <a href="https://www.gnu.org/software/bash/manual/bash.html#index-_005b_005b" rel="nofollow noreferrer">in the fine manual</a>:</p> <blockquote> <p>If any part of the pattern is quoted, the quoted portion is matched literally. This means every character in the quoted portion matches itself, ins...
18, 387
bash, regex
<h1>Linux character class matching not working for this expression</h1> <p>I'm trying to write a matcher that matches any of v1.65.x, v1.66.x or v1.67.x. But the moment I introduce a character class, it doesn't work with either a list of characters or a range:</p> <pre><code>if [[ &quot;v1.67.x&quot; =~ &quot;v1.67&quo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,658
bash
# Linux character class matching not working for this expression I'm trying to write a matcher that matches any of v1.65.x, v1.66.x or v1.67.x. But the moment I introduce a character class, it doesn't work with either a list of characters or a range: ``` if [[ "v1.67.x" =~ "v1.67" ]]; then echo matches; else echo no ...
This is explained [in the fine manual](https://www.gnu.org/software/bash/manual/bash.html#index-_005b_005b): > If any part of the pattern is quoted, the quoted portion is matched literally. This means every character in the quoted portion matches itself, instead of having any special pattern matching meaning. Without...
79501828
How to remove the progress bar from Remove-Item in PowerShell 7.5?
6
2025-03-11 18:52:08
<p>I have a PowerShell build script that deletes the previously built directory using <code>Remove-Item</code>. It works just fine, but since version 7.5 it produces a <a href="https://github.com/PowerShell/PowerShell/pull/20778" rel="noreferrer">yellow progress bar</a> as output that I don't want but can't seem to get...
516
3,574,641
2025-03-11 19:17:22
79,501,886
11
2025-03-11 19:17:22
15,339,544
2025-03-11 19:17:22
https://stackoverflow.com/q/79501828
https://stackoverflow.com/a/79501886
<p>You can suppress the progress output by setting the <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.5#-progressaction" rel="noreferrer"><code>-ProgressAction</code> common parameter</a>. Alternatively, you can also set the <a href=...
<p>You can suppress the progress output by setting the <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.5#-progressaction" rel="noreferrer"><code>-ProgressAction</code> common parameter</a>. Alternatively, you can also set the <a href=...
526, 549
powershell, ubuntu
<h1>How to remove the progress bar from Remove-Item in PowerShell 7.5?</h1> <p>I have a PowerShell build script that deletes the previously built directory using <code>Remove-Item</code>. It works just fine, but since version 7.5 it produces a <a href="https://github.com/PowerShell/PowerShell/pull/20778" rel="noreferre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,659
bash
# How to remove the progress bar from Remove-Item in PowerShell 7.5? I have a PowerShell build script that deletes the previously built directory using `Remove-Item`. It works just fine, but since version 7.5 it produces a [yellow progress bar](https://github.com/PowerShell/PowerShell/pull/20778) as output that I don'...
You can suppress the progress output by setting the [`-ProgressAction` common parameter](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.5#-progressaction). Alternatively, you can also set the [`$ProgressPreference`](https://learn.microsoft.co...
76752653
How to do "export PYTHONPATH=." on windows powershell?
6
2023-07-24 08:29:05
<p>On a Linux session I can set an environment variable like</p> <pre><code>export PYTHONPATH=. </code></pre> <p>How to do that on a windows Powershell? I found <a href="https://stackoverflow.com/questions/54647001/bash-export-command-in-powershell">THIS</a> and tried</p> <pre><code> [Environment]::SetEnvironmentVariab...
8,771
1,581,090
2023-07-24 13:06:53
76,752,824
11
2023-07-24 08:53:03
9,417,491
2023-07-24 13:06:53
https://stackoverflow.com/q/76752653
https://stackoverflow.com/a/76752824
<pre><code>$env:PYTHONPATH = $pwd </code></pre> <p>You forgot a colon in the last version. Also the . doesn't work here, but you can use the built-in variable $pwd (current directory).</p> <p>I find <strong>$env:NAME</strong> the easiest way to get environment variables in Powershell. It also follows the Microsoft docu...
<pre><code>$env:PYTHONPATH = $pwd </code></pre> <p>You forgot a colon in the last version. Also the . doesn't work here, but you can use the built-in variable $pwd (current directory).</p> <p>I find <strong>$env:NAME</strong> the easiest way to get environment variables in Powershell. It also follows the Microsoft docu...
64, 526
powershell, windows
<h1>How to do "export PYTHONPATH=." on windows powershell?</h1> <p>On a Linux session I can set an environment variable like</p> <pre><code>export PYTHONPATH=. </code></pre> <p>How to do that on a windows Powershell? I found <a href="https://stackoverflow.com/questions/54647001/bash-export-command-in-powershell">THIS</...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,660
bash
# How to do "export PYTHONPATH=." on windows powershell? On a Linux session I can set an environment variable like ``` export PYTHONPATH=. ``` How to do that on a windows Powershell? I found [THIS](https://stackoverflow.com/questions/54647001/bash-export-command-in-powershell) and tried ``` [Environment]::SetEnvir...
``` $env:PYTHONPATH = $pwd ``` You forgot a colon in the last version. Also the . doesn't work here, but you can use the built-in variable $pwd (current directory). I find **$env:NAME** the easiest way to get environment variables in Powershell. It also follows the Microsoft documentation: [about_Environment_Variable...
71308079
I'm getting "Error 403" when installing rails
6
2022-03-01 11:51:52
<p>I'm trying to install rails -v 5.2.2 on wsl ubuntu 18.04. Im met with following error:</p> <pre><code>ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Forbidden 403 (https://api.rubygems.org/quick/Marshal.4.8/nokogiri-1.13.3-x64-unknown.gemspec.rz) </code></pre> <p>I'm relatively new...
4,943
18,291,916
2022-03-31 00:08:58
71,685,064
11
2022-03-30 23:03:04
18,637,016
2022-03-31 00:08:58
https://stackoverflow.com/q/71308079
https://stackoverflow.com/a/71685064
<p>I had the same issue with <code>-v 5.2.3</code>. What worked for me was updating RubyGems with:</p> <pre><code>gem update --system </code></pre> <p>Then again:</p> <pre><code>gem install rails --version 5.2.3 </code></pre> <p>and no issues this time.</p>
<p>I had the same issue with <code>-v 5.2.3</code>. What worked for me was updating RubyGems with:</p> <pre><code>gem update --system </code></pre> <p>Then again:</p> <pre><code>gem install rails --version 5.2.3 </code></pre> <p>and no issues this time.</p>
387, 4984
bash, ruby-on-rails
<h1>I'm getting "Error 403" when installing rails</h1> <p>I'm trying to install rails -v 5.2.2 on wsl ubuntu 18.04. Im met with following error:</p> <pre><code>ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Forbidden 403 (https://api.rubygems.org/quick/Marshal.4.8/nokogiri-1.13.3-x64-...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,661
bash
# I'm getting "Error 403" when installing rails I'm trying to install rails -v 5.2.2 on wsl ubuntu 18.04. Im met with following error: ``` ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Forbidden 403 (https://api.rubygems.org/quick/Marshal.4.8/nokogiri-1.13.3-x64-unknown.gemspec.rz)...
I had the same issue with `-v 5.2.3`. What worked for me was updating RubyGems with: ``` gem update --system ``` Then again: ``` gem install rails --version 5.2.3 ``` and no issues this time.
71562728
Find with shell with different and/or conditions
6
2022-03-21 18:54:25
<p>I'm trying to find files or folders in a directory based on different conditions:</p> <ul> <li>all files that start with a W or,</li> <li>all the files ending with an X or,</li> <li>all files starting with Y and ending with Z!.</li> </ul> <p>This has been my best bet so far:</p> <pre><code>find -name 'w*' || find -n...
12,913
12,582,439
2024-07-29 09:20:49
71,562,783
11
2022-03-21 18:58:48
874,188
2024-07-29 09:20:49
https://stackoverflow.com/q/71562728
https://stackoverflow.com/a/71562783
<p>You can specify multiple predicates with <code>-o</code> to OR them.</p> <pre><code>find -name 'w*' -o -name '*x' -o -name 'y*z!' </code></pre> <p>Equivalently, you can use a single <code>-regex</code> which captures all these conditions.</p> <pre><code>find -regex '.*/\(w[^/]*\|[^/]*x\|y[^/]*z!\)' </code></pre> <p>...
<p>You can specify multiple predicates with <code>-o</code> to OR them.</p> <pre><code>find -name 'w*' -o -name '*x' -o -name 'y*z!' </code></pre> <p>Equivalently, you can use a single <code>-regex</code> which captures all these conditions.</p> <pre><code>find -regex '.*/\(w[^/]*\|[^/]*x\|y[^/]*z!\)' </code></pre> <p>...
58, 390, 10193
find, linux, shell
<h1>Find with shell with different and/or conditions</h1> <p>I'm trying to find files or folders in a directory based on different conditions:</p> <ul> <li>all files that start with a W or,</li> <li>all the files ending with an X or,</li> <li>all files starting with Y and ending with Z!.</li> </ul> <p>This has been my ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,662
bash
# Find with shell with different and/or conditions I'm trying to find files or folders in a directory based on different conditions: - all files that start with a W or, - all the files ending with an X or, - all files starting with Y and ending with Z!. This has been my best bet so far: ``` find -name 'w*' || find ...
You can specify multiple predicates with `-o` to OR them. ``` find -name 'w*' -o -name '*x' -o -name 'y*z!' ``` Equivalently, you can use a single `-regex` which captures all these conditions. ``` find -regex '.*/\(w[^/]*\|[^/]*x\|y[^/]*z!\)' ``` (Notice how the argument to `-regex` is applied to the entire path, a...
70622552
How do I unset all variables which start with a certain prefix in Bash?
6
2022-01-07 14:18:52
<p>I have a long list of parameters set in the environmental variables in a VM, e.g.</p> <pre><code>MYCONFIG_1=config1 MYCONFIG_2=list2 MYCONFIG_3=random3 MYCONFIG_4=somethingelse4 MYCONFIG_5=thanksforyourhelp5 </code></pre> <p>I would like to unset all of these in one go, without specifying them each individually (as ...
1,502
14,406,999
2022-01-07 14:39:04
70,622,629
11
2022-01-07 14:24:00
13,809,001
2022-01-07 14:39:04
https://stackoverflow.com/q/70622552
https://stackoverflow.com/a/70622629
<p>You can do it in a single command, assuming your shell is <code>bash</code></p> <pre><code>unset ${!MYCONFIG*} </code></pre> <p>Note that this will unset all variables beginning with <code>MYCONFIG</code> (no matter if those are environment variables or not).</p>
<p>You can do it in a single command, assuming your shell is <code>bash</code></p> <pre><code>unset ${!MYCONFIG*} </code></pre> <p>Note that this will unset all variables beginning with <code>MYCONFIG</code> (no matter if those are environment variables or not).</p>
58, 360, 387, 3574, 9013
bash, config, environment-variables, linux, parameters
<h1>How do I unset all variables which start with a certain prefix in Bash?</h1> <p>I have a long list of parameters set in the environmental variables in a VM, e.g.</p> <pre><code>MYCONFIG_1=config1 MYCONFIG_2=list2 MYCONFIG_3=random3 MYCONFIG_4=somethingelse4 MYCONFIG_5=thanksforyourhelp5 </code></pre> <p>I would lik...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,663
bash
# How do I unset all variables which start with a certain prefix in Bash? I have a long list of parameters set in the environmental variables in a VM, e.g. ``` MYCONFIG_1=config1 MYCONFIG_2=list2 MYCONFIG_3=random3 MYCONFIG_4=somethingelse4 MYCONFIG_5=thanksforyourhelp5 ``` I would like to unset all of these in one ...
You can do it in a single command, assuming your shell is `bash` ``` unset ${!MYCONFIG*} ``` Note that this will unset all variables beginning with `MYCONFIG` (no matter if those are environment variables or not).
67497396
Compare two hashes using Powershell
6
2021-05-12 04:35:04
<p>I have two files in the same directory I wish to compare hashes, <strong>Release.zip</strong> and <strong>release821hash.txt</strong></p> <p>The first command I have to use is <code>get-filehash Release.zip -a md5</code> The second command I have to use is <code>get-content release821hash.txt</code></p> <p>I then h...
16,192
12,120,561
2025-06-21 14:33:22
67,497,574
11
2021-05-12 05:01:55
52,598
2021-05-12 05:01:55
https://stackoverflow.com/q/67497396
https://stackoverflow.com/a/67497574
<p><code>Get-FileHash</code> returns an object containing, among other things, the hash. To get the actual hash, you'll have use the <code>Hash</code> property of the object.</p> <p>So you could do</p> <pre><code>$fileHash = (Get-FileHash Release.zip -a md5).Hash </code></pre> <p><code>Get-Content</code> might return a...
<p><code>Get-FileHash</code> returns an object containing, among other things, the hash. To get the actual hash, you'll have use the <code>Hash</code> property of the object.</p> <p>So you could do</p> <pre><code>$fileHash = (Get-FileHash Release.zip -a md5).Hash </code></pre> <p><code>Get-Content</code> might return a...
526
powershell
<h1>Compare two hashes using Powershell</h1> <p>I have two files in the same directory I wish to compare hashes, <strong>Release.zip</strong> and <strong>release821hash.txt</strong></p> <p>The first command I have to use is <code>get-filehash Release.zip -a md5</code> The second command I have to use is <code>get-cont...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,664
bash
# Compare two hashes using Powershell I have two files in the same directory I wish to compare hashes, **Release.zip** and **release821hash.txt** The first command I have to use is `get-filehash Release.zip -a md5` The second command I have to use is `get-content release821hash.txt` I then have to use the -eq to com...
`Get-FileHash` returns an object containing, among other things, the hash. To get the actual hash, you'll have use the `Hash` property of the object. So you could do ``` $fileHash = (Get-FileHash Release.zip -a md5).Hash ``` `Get-Content` might return a single string but it also might return an array of strings, dep...
66904779
CMD pipe different form Powershell pipe?
6
2021-04-01 12:45:09
<p>I am trying to pipe Node.js output to preatty-pino</p> <p><code>node .\dist\GameNode.js | pino-pretty</code></p> <p>running this in the CMD I get my formated output but running it inside a powershell I get nothing. I read that Powershell is using objects when piping, so I tried</p> <p><code>node .\dist\GameNode.js |...
1,039
8,808,871
2023-10-13 15:17:29
66,905,220
11
2021-04-01 13:14:16
45,375
2023-10-13 15:17:29
https://stackoverflow.com/q/66904779
https://stackoverflow.com/a/66905220
<p><sup>Note: The specific <code>pino-pretty</code> problem described in the question is <em>not</em> resolved by the information below. Lukas (the OP) has filed a bug report <a href="https://github.com/pinojs/pino-pretty/issues/173" rel="nofollow noreferrer">here</a>.</sup></p> <p>It's surprising that you get <em>not...
<p><sup>Note: The specific <code>pino-pretty</code> problem described in the question is <em>not</em> resolved by the information below. Lukas (the OP) has filed a bug report <a href="https://github.com/pinojs/pino-pretty/issues/173" rel="nofollow noreferrer">here</a>.</sup></p> <p>It's surprising that you get <em>not...
526, 2631, 5813
cmd, pipe, powershell
<h1>CMD pipe different form Powershell pipe?</h1> <p>I am trying to pipe Node.js output to preatty-pino</p> <p><code>node .\dist\GameNode.js | pino-pretty</code></p> <p>running this in the CMD I get my formated output but running it inside a powershell I get nothing. I read that Powershell is using objects when piping,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,665
bash
# CMD pipe different form Powershell pipe? I am trying to pipe Node.js output to preatty-pino `node .\dist\GameNode.js | pino-pretty` running this in the CMD I get my formated output but running it inside a powershell I get nothing. I read that Powershell is using objects when piping, so I tried `node .\dist\GameNo...
Note: The specific `pino-pretty` problem described in the question is *not* resolved by the information below. Lukas (the OP) has filed a bug report [here](https://github.com/pinojs/pino-pretty/issues/173). It's surprising that you get *nothing*, but the **fundamental difference** is: - **`cmd.exe`'s pipeline conduct...
65313138
How do I deal with dashes in a property name in powershell
6
2020-12-15 20:22:32
<p>I am trying to write the Active Directory parameter msRTCSIP-PrimaryUserAddress to a variable in powershell. For some reason, it seems to be choking on the dash in the property name. Does anyone know a way around it? I was able put other property in the variable that do not have a dash.</p> <pre><code>$sip = $sip...
4,011
4,709,378
2020-12-15 20:54:13
65,313,236
11
2020-12-15 20:31:01
3,474,677
2020-12-15 20:31:01
https://stackoverflow.com/q/65313138
https://stackoverflow.com/a/65313236
<p>You can put it in quotes like so:</p> <pre><code>$sip = $sipaccount.'msRTCSIP-PrimaryUserAddress' </code></pre>
<p>You can put it in quotes like so:</p> <pre><code>$sip = $sipaccount.'msRTCSIP-PrimaryUserAddress' </code></pre>
367, 526, 4898
powershell, properties, syntax
<h1>How do I deal with dashes in a property name in powershell</h1> <p>I am trying to write the Active Directory parameter msRTCSIP-PrimaryUserAddress to a variable in powershell. For some reason, it seems to be choking on the dash in the property name. Does anyone know a way around it? I was able put other property...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,666
bash
# How do I deal with dashes in a property name in powershell I am trying to write the Active Directory parameter msRTCSIP-PrimaryUserAddress to a variable in powershell. For some reason, it seems to be choking on the dash in the property name. Does anyone know a way around it? I was able put other property in the vari...
You can put it in quotes like so: ``` $sip = $sipaccount.'msRTCSIP-PrimaryUserAddress' ```
65186262
How can you restrict/control the navigation routes the user can visit based on login status/role?
6
2020-12-07 17:15:33
<p>For my Xamarin.Forms app, I am looking for a way to check if a user has the right role/authentication status to access a page. I know Angular has route guards that can be reused for different routes to check for an authentication status. Is there something similar in Xamarin.Forms?</p>
4,504
7,177,314
2021-06-04 10:21:10
65,187,674
11
2020-12-07 18:51:39
5,228,202
2021-06-04 10:21:10
https://stackoverflow.com/q/65186262
https://stackoverflow.com/a/65187674
<p>Here is an example showing how you can control the visibility or navigation to your pages based on the login status of the user.</p> <p>By default Shell will always displays initially the first element defined in <code>AppShell.xaml</code>, in this case it will be <code>Login.xaml</code> page.</p> <p>In the below ex...
<p>Here is an example showing how you can control the visibility or navigation to your pages based on the login status of the user.</p> <p>By default Shell will always displays initially the first element defined in <code>AppShell.xaml</code>, in this case it will be <code>Login.xaml</code> page.</p> <p>In the below ex...
9, 1117, 80035, 104707, 138516
c#, xamarin, xamarin.forms, xamarin.forms.shell, xaml
<h1>How can you restrict/control the navigation routes the user can visit based on login status/role?</h1> <p>For my Xamarin.Forms app, I am looking for a way to check if a user has the right role/authentication status to access a page. I know Angular has route guards that can be reused for different routes to check fo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,667
bash
# How can you restrict/control the navigation routes the user can visit based on login status/role? For my Xamarin.Forms app, I am looking for a way to check if a user has the right role/authentication status to access a page. I know Angular has route guards that can be reused for different routes to check for an auth...
Here is an example showing how you can control the visibility or navigation to your pages based on the login status of the user. By default Shell will always displays initially the first element defined in `AppShell.xaml`, in this case it will be `Login.xaml` page. In the below example "Page3" will be visible initial...
62099966
How do i access AWS SAM-CLI through bash on windows?
6
2020-05-30 08:41:43
<p>I am running Windows 10 and can only access AWS SAM through command prompt but not bash. When i try to use bash, i get a <code>bash: sam: command not found</code> error.</p> <p>If it helps, I currently have installed AWS CLI v2 and have installed it via an MSI file.</p> <p>Why am i not able to use SAM through bash?<...
3,214
7,573,706
2025-03-18 04:53:43
63,728,121
11
2020-09-03 16:40:28
6,658,955
2020-09-03 16:40:28
https://stackoverflow.com/q/62099966
https://stackoverflow.com/a/63728121
<p>Do you tried <code>sam.cmd</code>?</p> <p>Sometimes bash don't know how to execute <code>.cmd</code> files. Here is a <a href="https://github.com/aws/aws-sam-cli/issues/448#issuecomment-578323595" rel="noreferrer">thread</a> with this problem.</p> <p>You can try <a href="https://github.com/aws/aws-sam-cli/issues/448...
<p>Do you tried <code>sam.cmd</code>?</p> <p>Sometimes bash don't know how to execute <code>.cmd</code> files. Here is a <a href="https://github.com/aws/aws-sam-cli/issues/448#issuecomment-578323595" rel="noreferrer">thread</a> with this problem.</p> <p>You can try <a href="https://github.com/aws/aws-sam-cli/issues/448...
64, 387, 9938, 33388, 99166
amazon-web-services, aws-cli, bash, command-prompt, windows
<h1>How do i access AWS SAM-CLI through bash on windows?</h1> <p>I am running Windows 10 and can only access AWS SAM through command prompt but not bash. When i try to use bash, i get a <code>bash: sam: command not found</code> error.</p> <p>If it helps, I currently have installed AWS CLI v2 and have installed it via a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,668
bash
# How do i access AWS SAM-CLI through bash on windows? I am running Windows 10 and can only access AWS SAM through command prompt but not bash. When i try to use bash, i get a `bash: sam: command not found` error. If it helps, I currently have installed AWS CLI v2 and have installed it via an MSI file. Why am i not ...
Do you tried `sam.cmd`? Sometimes bash don't know how to execute `.cmd` files. Here is a [thread](https://github.com/aws/aws-sam-cli/issues/448#issuecomment-578323595) with this problem. You can try [this solution](https://github.com/aws/aws-sam-cli/issues/448#issuecomment-590382892) too: ``` alias sam='sam.cmd' ```
63142061
Configure Visual Studio Code task to execute multiple shell commands in sequence
6
2020-07-28 20:11:55
<p>Is there a possibility, to add multiple shell commands in sequence to a Visual Studio Code task with separate arguments and options? I managed to execute multiple commands using <code>&amp;&amp;</code> to chain then together to a single command, as you could in any Linux shell. But i guess, there has to be a better ...
7,750
12,828,370
2020-07-29 19:48:02
63,161,225
11
2020-07-29 19:37:13
12,828,370
2020-07-29 19:48:02
https://stackoverflow.com/q/63142061
https://stackoverflow.com/a/63161225
<p>Thanks to the many comments i found a solution which works well by setting &quot;dependsOrder&quot; to &quot;sequence&quot;:</p> <pre><code>{ &quot;tasks&quot;: [ { &quot;type&quot;: &quot;shell&quot;, &quot;label&quot;: &quot;build project&quot;, &quot;dependsOrder&qu...
<p>Thanks to the many comments i found a solution which works well by setting &quot;dependsOrder&quot; to &quot;sequence&quot;:</p> <pre><code>{ &quot;tasks&quot;: [ { &quot;type&quot;: &quot;shell&quot;, &quot;label&quot;: &quot;build project&quot;, &quot;dependsOrder&qu...
390, 1508, 8822, 111608, 125835
cmake, json, shell, visual-studio-code, vscode-tasks
<h1>Configure Visual Studio Code task to execute multiple shell commands in sequence</h1> <p>Is there a possibility, to add multiple shell commands in sequence to a Visual Studio Code task with separate arguments and options? I managed to execute multiple commands using <code>&amp;&amp;</code> to chain then together to...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,669
bash
# Configure Visual Studio Code task to execute multiple shell commands in sequence Is there a possibility, to add multiple shell commands in sequence to a Visual Studio Code task with separate arguments and options? I managed to execute multiple commands using `&&` to chain then together to a single command, as you co...
Thanks to the many comments i found a solution which works well by setting "dependsOrder" to "sequence": ``` { "tasks": [ { "type": "shell", "label": "build project", "dependsOrder": "sequence", "dependsOn": [ "Cmake", "make cl...
62823266
kubectl exec works on single commands, but I cannot enter a bash shell
6
2020-07-09 20:34:24
<p>I'm on <strong>macOS Catalina 10.15.4</strong>, and I'm using <strong>minikube v1.11.0</strong> and <strong>kubernetes v1.18.3</strong>, both installed from brew. Minikube is initialized with the docker engine.</p> <p>The initialization command is set up like so:</p> <pre><code> containers: - name: data...
15,727
8,463,089
2020-07-19 03:09:00
62,825,293
11
2020-07-09 23:41:37
2,989,261
2020-07-19 03:09:00
https://stackoverflow.com/q/62823266
https://stackoverflow.com/a/62825293
<p><code>minikube kubectl</code> needs the <code>--</code> after the command when you want to use it with arguments:</p> <pre class="lang-sh prettyprint-override"><code>$ minikube kubectl -- exec --stdin --tty --namespace=tools test-pod -- sh </code></pre> <p>You can also use plain <code>kubectl</code></p> <p>If would ...
<p><code>minikube kubectl</code> needs the <code>--</code> after the command when you want to use it with arguments:</p> <pre class="lang-sh prettyprint-override"><code>$ minikube kubectl -- exec --stdin --tty --namespace=tools test-pod -- sh </code></pre> <p>You can also use plain <code>kubectl</code></p> <p>If would ...
387, 90304, 106338, 120010, 122407
bash, docker, kubectl, kubernetes, minikube
<h1>kubectl exec works on single commands, but I cannot enter a bash shell</h1> <p>I'm on <strong>macOS Catalina 10.15.4</strong>, and I'm using <strong>minikube v1.11.0</strong> and <strong>kubernetes v1.18.3</strong>, both installed from brew. Minikube is initialized with the docker engine.</p> <p>The initialization ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,670
bash
# kubectl exec works on single commands, but I cannot enter a bash shell I'm on **macOS Catalina 10.15.4**, and I'm using **minikube v1.11.0** and **kubernetes v1.18.3**, both installed from brew. Minikube is initialized with the docker engine. The initialization command is set up like so: ``` containers: ...
`minikube kubectl` needs the `--` after the command when you want to use it with arguments: ``` $ minikube kubectl -- exec --stdin --tty --namespace=tools test-pod -- sh ``` You can also use plain `kubectl` If would just make sure that your `~/.kube/config` is pointing to the right minikube context/cluster. Typicall...
61426902
Use bash, Azure CLI and REST API to access CosmosDB - how to get token and hash right?
6
2020-04-25 14:06:29
<p>My ultimate goal is to upload a document to an existing CosmosDB (SQL) instance using bash and Azure CLI. Trouble is: Azure CLI does <a href="https://learn.microsoft.com/en-us/cli/azure/cosmosdb?view=azure-cli-latest" rel="noreferrer">not offer a command to modify documents</a>.</p> <p>To work around this I looked ...
6,615
304,870
2021-07-09 15:05:18
61,457,934
11
2020-04-27 11:32:26
304,870
2020-04-29 14:12:21
https://stackoverflow.com/q/61426902
https://stackoverflow.com/a/61457934
<p>Thanks for your support @Gaurav Mantri and @Mark Brown. Your comments helped avoid death by a million paper cuts :-)</p> <p>I've started a repository where I collect Azure CLI bash scripts. Find it at <a href="https://github.com/Krumelur/AzureScripts" rel="noreferrer">https://github.com/Krumelur/AzureScripts</a></p...
<p>Thanks for your support @Gaurav Mantri and @Mark Brown. Your comments helped avoid death by a million paper cuts :-)</p> <p>I've started a repository where I collect Azure CLI bash scripts. Find it at <a href="https://github.com/Krumelur/AzureScripts" rel="noreferrer">https://github.com/Krumelur/AzureScripts</a></p...
387, 14158, 108105, 126330
azure, azure-cli, azure-cosmosdb, bash
<h1>Use bash, Azure CLI and REST API to access CosmosDB - how to get token and hash right?</h1> <p>My ultimate goal is to upload a document to an existing CosmosDB (SQL) instance using bash and Azure CLI. Trouble is: Azure CLI does <a href="https://learn.microsoft.com/en-us/cli/azure/cosmosdb?view=azure-cli-latest" rel...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,671
bash
# Use bash, Azure CLI and REST API to access CosmosDB - how to get token and hash right? My ultimate goal is to upload a document to an existing CosmosDB (SQL) instance using bash and Azure CLI. Trouble is: Azure CLI does [not offer a command to modify documents](https://learn.microsoft.com/en-us/cli/azure/cosmosdb?vi...
Thanks for your support @Gaurav Mantri and @Mark Brown. Your comments helped avoid death by a million paper cuts :-) I've started a repository where I collect Azure CLI bash scripts. Find it at <https://github.com/Krumelur/AzureScripts> Let me answer my own question(s) and provide a script that reads the existing DBs...
61313906
Is it possible authenticate both Connect-AzAccount and Connect-AzureAD using MFA with a single user login prompt?
6
2020-04-20 01:39:45
<p>I set up a visual studio project template that runs setup scripts to automatically register an application and create application insights for the app. The problem is the app registration uses the AzureAD module while the application insights (and the resource group creation if needed) use the Az modules, so I end ...
7,182
5,879,844
2020-09-18 17:56:07
61,335,244
11
2020-04-21 02:57:48
10,505,040
2020-04-21 02:57:48
https://stackoverflow.com/q/61313906
https://stackoverflow.com/a/61335244
<p>If you want to use the same session to connect Azure and Azure AD in PowerShell, please refer to the following script</p> <pre><code>Connect-AzAccount $context=Get-AzContext Connect-AzureAD -TenantId $context.Tenant.TenantId -AccountId $context.Account.Id Get-AzureADUser </code></pre> <p><a href="https://i.sstatic...
<p>If you want to use the same session to connect Azure and Azure AD in PowerShell, please refer to the following script</p> <pre><code>Connect-AzAccount $context=Get-AzContext Connect-AzureAD -TenantId $context.Tenant.TenantId -AccountId $context.Account.Id Get-AzureADUser </code></pre> <p><a href="https://i.sstatic...
526, 14158, 93887
azure, azure-active-directory, powershell
<h1>Is it possible authenticate both Connect-AzAccount and Connect-AzureAD using MFA with a single user login prompt?</h1> <p>I set up a visual studio project template that runs setup scripts to automatically register an application and create application insights for the app. The problem is the app registration uses ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,672
bash
# Is it possible authenticate both Connect-AzAccount and Connect-AzureAD using MFA with a single user login prompt? I set up a visual studio project template that runs setup scripts to automatically register an application and create application insights for the app. The problem is the app registration uses the AzureA...
If you want to use the same session to connect Azure and Azure AD in PowerShell, please refer to the following script ``` Connect-AzAccount $context=Get-AzContext Connect-AzureAD -TenantId $context.Tenant.TenantId -AccountId $context.Account.Id Get-AzureADUser ``` [![enter image description here](https://i.sstatic.ne...
61149392
How can I print contents of a text file in git bash?
6
2020-04-10 22:09:08
<p>How can I print contents of a text file in git bash?</p> <p>I added to the text file through git bash using echo "Hello World!" > my_text.txt now I just want to be able to view only in git bash.</p>
8,771
13,282,755
2020-04-10 22:12:05
61,149,418
11
2020-04-10 22:12:05
10,681,992
2020-04-10 22:12:05
https://stackoverflow.com/q/61149392
https://stackoverflow.com/a/61149418
<p><code>cat &lt;your file&gt;</code> for example</p>
<p><code>cat &lt;your file&gt;</code> for example</p>
61874
git-bash
<h1>How can I print contents of a text file in git bash?</h1> <p>How can I print contents of a text file in git bash?</p> <p>I added to the text file through git bash using echo "Hello World!" > my_text.txt now I just want to be able to view only in git bash.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,673
bash
# How can I print contents of a text file in git bash? How can I print contents of a text file in git bash? I added to the text file through git bash using echo "Hello World!" > my_text.txt now I just want to be able to view only in git bash.
`cat <your file>` for example
60353691
PowerShell: Importing 16MB CSV Into PowerShell Variable Creates >600MB's of PowerShell Memory Usage
6
2020-02-22 15:30:06
<p>I'm trying to understand why PowerShell's memory balloons so much when I import a file that's ~16MB's as a variable. I can understand there's additional memory structure around that variable but I'm just trying to understand why it's THAT high. Here's what I'm doing below - just a stripped down simplistic snippet of...
2,413
12,314,579
2022-10-13 18:34:13
60,356,120
11
2020-02-22 19:45:55
45,375
2022-10-13 18:34:13
https://stackoverflow.com/q/60353691
https://stackoverflow.com/a/60356120
<p><em>Generally</em> speaking, <a href="https://stackoverflow.com/users/1701026/iron">iRon</a>'s advice in a comment on the question is worth heeding (the specific question is addressed in the section that follows this one):</p> <blockquote> <p><strong>To keep memory usage low, use <em>streaming</em> of objects <em>i...
<p><em>Generally</em> speaking, <a href="https://stackoverflow.com/users/1701026/iron">iRon</a>'s advice in a comment on the question is worth heeding (the specific question is addressed in the section that follows this one):</p> <blockquote> <p><strong>To keep memory usage low, use <em>streaming</em> of objects <em>i...
61, 526, 20897, 26280, 122469
import-csv, memory, memory-profiling, powershell, pscustomobject
<h1>PowerShell: Importing 16MB CSV Into PowerShell Variable Creates >600MB's of PowerShell Memory Usage</h1> <p>I'm trying to understand why PowerShell's memory balloons so much when I import a file that's ~16MB's as a variable. I can understand there's additional memory structure around that variable but I'm just tryi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,674
bash
# PowerShell: Importing 16MB CSV Into PowerShell Variable Creates >600MB's of PowerShell Memory Usage I'm trying to understand why PowerShell's memory balloons so much when I import a file that's ~16MB's as a variable. I can understand there's additional memory structure around that variable but I'm just trying to und...
*Generally* speaking, [iRon](https://stackoverflow.com/users/1701026/iron)'s advice in a comment on the question is worth heeding (the specific question is addressed in the section that follows this one): > **To keep memory usage low, use *streaming* of objects *in the pipeline* rather than *collecting them in memory ...
59665791
profile.ps1 how import scripts and functions
6
2020-01-09 14:07:50
<p>I have some functions and scripts what I make myself. The issue is that I am not sure where that save and how to load. </p> <p>On local profile I have this: C:\Users\Plazma\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1</p> <p>With this: </p> <pre><code>Import-Module c:\Users\Plazma\Documents\Window...
3,547
10,580,911
2020-01-09 14:50:36
59,666,534
11
2020-01-09 14:50:36
584,676
2020-01-09 14:50:36
https://stackoverflow.com/q/59665791
https://stackoverflow.com/a/59666534
<p>I've never seen <code>Import-Module</code> used to import the definitions from a script, I don't even know if this would work. Usually one would dot-source <code>.</code> library scripts from their <code>$profile</code> like so:</p> <p>Microsoft.Powershell_profile.ps1</p> <pre><code>. c:\Users\Plazma\Documents\Win...
<p>I've never seen <code>Import-Module</code> used to import the definitions from a script, I don't even know if this would work. Usually one would dot-source <code>.</code> library scripts from their <code>$profile</code> like so:</p> <p>Microsoft.Powershell_profile.ps1</p> <pre><code>. c:\Users\Plazma\Documents\Win...
526
powershell
<h1>profile.ps1 how import scripts and functions</h1> <p>I have some functions and scripts what I make myself. The issue is that I am not sure where that save and how to load. </p> <p>On local profile I have this: C:\Users\Plazma\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1</p> <p>With this: </p> <pr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
11,675
bash
# profile.ps1 how import scripts and functions I have some functions and scripts what I make myself. The issue is that I am not sure where that save and how to load. On local profile I have this: C:\Users\Plazma\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 With this: ``` Import-Module c:\Users\Plazm...
I've never seen `Import-Module` used to import the definitions from a script, I don't even know if this would work. Usually one would dot-source `.` library scripts from their `$profile` like so: Microsoft.Powershell_profile.ps1 ``` . c:\Users\Plazma\Documents\WindowsPowerShell\Get-serialnumber.ps1 . c:\Users\Plazma\...