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
40680812
MySQL Git Bash winpty mysqldump stdout is not a tty and stdin is not a tty
18
2016-11-18 15:32:46
<p>Please help with MySQL Git Bash winpty mysqldump. "winpty mysqldump" is not working in Git Bash. Here the details of the error:</p> <p><strong>Git Bash</strong></p> <pre><code>$ winpty mysqldump -u root -p employeedb &gt; "E:\Working\SQL\MySQL\MySQL-Queries\mysqldump\SQL-dump\employeedb_backup.sql" stdout is not a...
16,267
5,264,370
2018-01-31 05:55:02
40,791,559
14
2016-11-24 16:55:39
6,311,905
2017-06-16 23:48:31
https://stackoverflow.com/q/40680812
https://stackoverflow.com/a/40791559
<p>The error is actually from <code>winpty</code> because you are trying to redirect output to a file and it expects a terminal for interactive use.</p> <p>Normally, native Git bash commands like <code>git</code>, <code>ssh</code> and all output redirection like <code>node --version | clip</code> should work without <...
<p>The error is actually from <code>winpty</code> because you are trying to redirect output to a file and it expects a terminal for interactive use.</p> <p>Normally, native Git bash commands like <code>git</code>, <code>ssh</code> and all output redirection like <code>node --version | clip</code> should work without <...
21, 61874
git-bash, mysql
<h1>MySQL Git Bash winpty mysqldump stdout is not a tty and stdin is not a tty</h1> <p>Please help with MySQL Git Bash winpty mysqldump. "winpty mysqldump" is not working in Git Bash. Here the details of the error:</p> <p><strong>Git Bash</strong></p> <pre><code>$ winpty mysqldump -u root -p employeedb &gt; "E:\Worki...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,566
bash
# MySQL Git Bash winpty mysqldump stdout is not a tty and stdin is not a tty Please help with MySQL Git Bash winpty mysqldump. "winpty mysqldump" is not working in Git Bash. Here the details of the error: **Git Bash** ``` $ winpty mysqldump -u root -p employeedb > "E:\Working\SQL\MySQL\MySQL-Queries\mysqldump\SQL-du...
The error is actually from `winpty` because you are trying to redirect output to a file and it expects a terminal for interactive use. Normally, native Git bash commands like `git`, `ssh` and all output redirection like `node --version | clip` should work without `winpty`. These `mysql` commands are different in that...
38090455
What is the simplest way to make matplotlib in OSX work in a virtual environment?
18
2016-06-29 04:34:14
<p>I just discovered that <code>matplotlib</code> has issue with virtual environments. I tried the solutions in the <a href="http://matplotlib.org/faq/virtualenv_faq.html">FAQs</a> but they didn't work. An ideal solution should only involve <code>pip</code> commands, but it might be hard or unrealistic to request that....
8,393
1,601,580
2018-05-17 12:10:25
38,161,572
14
2016-07-02 15:15:20
1,490,091
2017-06-03 00:27:12
https://stackoverflow.com/q/38090455
https://stackoverflow.com/a/38161572
<p><strong>Update:</strong></p> <p>With Python3, you can use the built-in implementation of <code>virtualenv</code> via <code>-m venv</code>:</p> <pre><code>python -m venv &lt;name of virtualenv&gt; source &lt;name of virtualenv&gt;/bin/activate </code></pre> <p>Python3's builtin implementation builds the virtualenv...
<p><strong>Update:</strong></p> <p>With Python3, you can use the built-in implementation of <code>virtualenv</code> via <code>-m venv</code>:</p> <pre><code>python -m venv &lt;name of virtualenv&gt; source &lt;name of virtualenv&gt;/bin/activate </code></pre> <p>Python3's builtin implementation builds the virtualenv...
16, 369, 387, 7979
bash, macos, matplotlib, python
<h1>What is the simplest way to make matplotlib in OSX work in a virtual environment?</h1> <p>I just discovered that <code>matplotlib</code> has issue with virtual environments. I tried the solutions in the <a href="http://matplotlib.org/faq/virtualenv_faq.html">FAQs</a> but they didn't work. An ideal solution should o...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,567
bash
# What is the simplest way to make matplotlib in OSX work in a virtual environment? I just discovered that `matplotlib` has issue with virtual environments. I tried the solutions in the [FAQs](http://matplotlib.org/faq/virtualenv_faq.html) but they didn't work. An ideal solution should only involve `pip` commands, but...
**Update:** With Python3, you can use the built-in implementation of `virtualenv` via `-m venv`: ``` python -m venv <name of virtualenv> source <name of virtualenv>/bin/activate ``` Python3's builtin implementation builds the virtualenv such that Python is set up as a framework, so no need to configure anything to g...
19950620
how to hide password in command line with **** and get the value into .bat file and .sh file
18
2013-11-13 09:56:01
<p>My .bat file command to get user input from command line is</p> <pre><code>set /p weblogicpassword=Enter weblogic password:%=% </code></pre> <p>My .sh file command to get user input from bash script is </p> <pre><code>echo -n "Enter weblogic password: " read weblogicpassword </code></pre> <p>Now when we enter so...
87,267
2,878,317
2017-01-21 08:28:09
19,950,690
14
2013-11-13 09:59:38
551,045
2013-11-13 11:07:26
https://stackoverflow.com/q/19950620
https://stackoverflow.com/a/19950690
<p>For bash its <code>read -s</code>. </p> <p><code>-s Silent mode. If input is coming from a terminal, characters are not echoed.</code></p> <p>For batch it seems to be more complicated.</p> <p>Read about it here: <a href="https://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file">Can I mask...
<p>For bash its <code>read -s</code>. </p> <p><code>-s Silent mode. If input is coming from a terminal, characters are not echoed.</code></p> <p>For batch it seems to be more complicated.</p> <p>Read about it here: <a href="https://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file">Can I mask...
387, 2631, 7002, 9938
bash, batch-file, cmd, command-prompt
<h1>how to hide password in command line with **** and get the value into .bat file and .sh file</h1> <p>My .bat file command to get user input from command line is</p> <pre><code>set /p weblogicpassword=Enter weblogic password:%=% </code></pre> <p>My .sh file command to get user input from bash script is </p> <pre>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,568
bash
# how to hide password in command line with **** and get the value into .bat file and .sh file My .bat file command to get user input from command line is ``` set /p weblogicpassword=Enter weblogic password:%=% ``` My .sh file command to get user input from bash script is ``` echo -n "Enter weblogic password: " rea...
For bash its `read -s`. `-s Silent mode. If input is coming from a terminal, characters are not echoed.` For batch it seems to be more complicated. Read about it here: [Can I mask an input text in a bat file](https://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file)
5896223
Using find to delete all subdirectories (and their files)
18
2011-05-05 10:28:14
<p>I'm sure this is straight forward and answered somewhere, but I didn't manage to find what I was looking for. Basically, I'm trying to run a cron script to clear the contents of a given directory every 7 days. So far I have tried the following,</p> <pre><code>find /myDir -mtime 7 -exec rm -rf {} \; </code></pre> ...
16,349
706,380
2017-06-15 13:43:26
5,896,314
14
2011-05-05 10:34:25
719,147
2011-05-05 10:34:25
https://stackoverflow.com/q/5896223
https://stackoverflow.com/a/5896314
<p>Try:</p> <pre><code>find /myDir -mindepth 1 -mtime 7 -exec rm -rf {} \; </code></pre>
<p>Try:</p> <pre><code>find /myDir -mindepth 1 -mtime 7 -exec rm -rf {} \; </code></pre>
387, 578, 5610, 10193, 34708
bash, find, recursion, rm, subdirectory
<h1>Using find to delete all subdirectories (and their files)</h1> <p>I'm sure this is straight forward and answered somewhere, but I didn't manage to find what I was looking for. Basically, I'm trying to run a cron script to clear the contents of a given directory every 7 days. So far I have tried the following,</p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,569
bash
# Using find to delete all subdirectories (and their files) I'm sure this is straight forward and answered somewhere, but I didn't manage to find what I was looking for. Basically, I'm trying to run a cron script to clear the contents of a given directory every 7 days. So far I have tried the following, ``` find /myD...
Try: ``` find /myDir -mindepth 1 -mtime 7 -exec rm -rf {} \; ```
5306604
how to make this "action-packed, random data" being echoed in a terminal?
18
2011-03-15 01:43:00
<p>OK, this isn't really a question to achieve anything practical, but still it is a serious question and I hope it will be taken seriously and mods won't punish me for this :)</p> <p>I'm sure majority of you have seen some good action movie, where CIA or FBI or hackers or any other "pc nerds" are "retrieving some inf...
7,817
616,855
2016-01-02 00:11:24
5,306,613
14
2011-03-15 01:45:00
26,428
2011-03-16 02:32:07
https://stackoverflow.com/q/5306604
https://stackoverflow.com/a/5306613
<p>There's a utility call <a href="http://linux.die.net/man/1/script"><code>script</code></a> (ironically) that does what you're talking about. It can even record timing data so the playback is done at the same rate the original actions were performed.</p> <p>To start recording and capture timing data:</p> <pre><code...
<p>There's a utility call <a href="http://linux.die.net/man/1/script"><code>script</code></a> (ironically) that does what you're talking about. It can even record timing data so the playback is done at the same rate the original actions were performed.</p> <p>To start recording and capture timing data:</p> <pre><code...
58, 390, 391, 549
linux, shell, terminal, ubuntu
<h1>how to make this "action-packed, random data" being echoed in a terminal?</h1> <p>OK, this isn't really a question to achieve anything practical, but still it is a serious question and I hope it will be taken seriously and mods won't punish me for this :)</p> <p>I'm sure majority of you have seen some good action ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,570
bash
# how to make this "action-packed, random data" being echoed in a terminal? OK, this isn't really a question to achieve anything practical, but still it is a serious question and I hope it will be taken seriously and mods won't punish me for this :) I'm sure majority of you have seen some good action movie, where CIA...
There's a utility call [`script`](http://linux.die.net/man/1/script) (ironically) that does what you're talking about. It can even record timing data so the playback is done at the same rate the original actions were performed. To start recording and capture timing data: ``` $ script -t script.out 2>timing.out ``` W...
46236580
How to enable shell command completion for gcloud?
17
2017-09-15 09:44:32
<p>I'm trying to install the Google Cloud SDK on a Mac (following <a href="https://cloud.google.com/sdk/docs/quickstart-mac-os-x" rel="noreferrer">https://cloud.google.com/sdk/docs/quickstart-mac-os-x</a>), using the <code>install.sh</code> script:</p> <pre><code>~/Downloads$ ./google-cloud-sdk/install.sh </code></pre...
27,667
995,862
2019-07-11 10:57:15
46,236,915
14
2017-09-15 10:01:12
995,862
2017-09-15 10:01:12
https://stackoverflow.com/q/46236580
https://stackoverflow.com/a/46236915
<p>The trick was to run the <code>install.sh</code> using <code>sudo</code> as described in the update. After that I needed to restart the terminal (as described in the instructions) for the changes to take effect.</p>
<p>The trick was to run the <code>install.sh</code> using <code>sudo</code> as described in the update. After that I needed to restart the terminal (as described in the instructions) for the changes to take effect.</p>
387, 390, 99304
bash, google-cloud-platform, shell
<h1>How to enable shell command completion for gcloud?</h1> <p>I'm trying to install the Google Cloud SDK on a Mac (following <a href="https://cloud.google.com/sdk/docs/quickstart-mac-os-x" rel="noreferrer">https://cloud.google.com/sdk/docs/quickstart-mac-os-x</a>), using the <code>install.sh</code> script:</p> <pre><...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,571
bash
# How to enable shell command completion for gcloud? I'm trying to install the Google Cloud SDK on a Mac (following <https://cloud.google.com/sdk/docs/quickstart-mac-os-x>), using the `install.sh` script: ``` ~/Downloads$ ./google-cloud-sdk/install.sh ``` In the logged output, I see the following instructions: ``` ...
The trick was to run the `install.sh` using `sudo` as described in the update. After that I needed to restart the terminal (as described in the instructions) for the changes to take effect.
26809898
Invoke MSYS2 Shell from Command Prompt or PowerShell
17
2014-11-07 20:53:50
<p>Starting from Command Prompt or PowerShell (either is fine; I can figure out how to do the other given one), how can I invoke the MSYS2 shell to run a command?</p> <h3>More specific issue</h3> <p>I'm including this information to avoid an XY problem, but I strongly believe this is best solved by the answer to the ...
25,098
1,394,393
2019-09-01 10:20:52
26,811,432
14
2014-11-07 22:52:42
3,257,826
2019-09-01 10:20:52
https://stackoverflow.com/q/26809898
https://stackoverflow.com/a/26811432
<p>We're working hard to fix our messy update procedure, we want it to be trouble-free.</p> <p>You can see some examples of how we invoke MSYS2 from a batch file when we create a new installer in:</p> <p><a href="https://github.com/Alexpux/MSYS2-packages/blob/master/msys2-installer/make-msys2-installer.bat" rel="nore...
<p>We're working hard to fix our messy update procedure, we want it to be trouble-free.</p> <p>You can see some examples of how we invoke MSYS2 from a batch file when we create a new installer in:</p> <p><a href="https://github.com/Alexpux/MSYS2-packages/blob/master/msys2-installer/make-msys2-installer.bat" rel="nore...
390, 105819
msys2, shell
<h1>Invoke MSYS2 Shell from Command Prompt or PowerShell</h1> <p>Starting from Command Prompt or PowerShell (either is fine; I can figure out how to do the other given one), how can I invoke the MSYS2 shell to run a command?</p> <h3>More specific issue</h3> <p>I'm including this information to avoid an XY problem, bu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,572
bash
# Invoke MSYS2 Shell from Command Prompt or PowerShell Starting from Command Prompt or PowerShell (either is fine; I can figure out how to do the other given one), how can I invoke the MSYS2 shell to run a command? ### More specific issue I'm including this information to avoid an XY problem, but I strongly believe ...
We're working hard to fix our messy update procedure, we want it to be trouble-free. You can see some examples of how we invoke MSYS2 from a batch file when we create a new installer in: <https://github.com/Alexpux/MSYS2-packages/blob/master/msys2-installer/make-msys2-installer.bat> But as @StevenPenny suggests, ``...
24605656
Run du on parallel
17
2014-07-07 08:00:51
<p>I have a very big storage disk (16T). I want to run 'du' on it to figure out how much each subdirectory takes. However, that takes a very long time. Luckily, I have at my disposal a cluster of computers. I can therefore run 'du' on parallel, each job runs on a separate subdirectory, and write a simple script that do...
6,953
54,248
2017-11-16 16:27:51
24,973,805
14
2014-07-26 17:45:58
363,028
2014-07-26 17:45:58
https://stackoverflow.com/q/24605656
https://stackoverflow.com/a/24973805
<p>It is simple to do it using GNU Parallel:</p> <pre><code>parallel du ::: */* </code></pre>
<p>It is simple to do it using GNU Parallel:</p> <pre><code>parallel du ::: */* </code></pre>
353, 387, 2829, 26163
bash, csh, du, parallel-processing
<h1>Run du on parallel</h1> <p>I have a very big storage disk (16T). I want to run 'du' on it to figure out how much each subdirectory takes. However, that takes a very long time. Luckily, I have at my disposal a cluster of computers. I can therefore run 'du' on parallel, each job runs on a separate subdirectory, and w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,573
bash
# Run du on parallel I have a very big storage disk (16T). I want to run 'du' on it to figure out how much each subdirectory takes. However, that takes a very long time. Luckily, I have at my disposal a cluster of computers. I can therefore run 'du' on parallel, each job runs on a separate subdirectory, and write a si...
It is simple to do it using GNU Parallel: ``` parallel du ::: */* ```
15558101
Case insensitive comparison in Bash
17
2013-03-21 21:06:06
<p>I'm trying to write a comparison in a while statement that's case insensitive. Basically, I'm simply trying to shorten the following to act on a yes or no question prompt to the user ...</p> <pre><code>while[ $yn == "y" | $yn == "Y" | $yn == "Yes" | $yn == "yes" ] ; do </code></pre> <p>What would be the best way ...
22,721
2,150,250
2018-09-13 21:32:31
15,558,159
14
2013-03-21 21:09:27
465,183
2013-03-21 21:29:59
https://stackoverflow.com/q/15558101
https://stackoverflow.com/a/15558159
<pre><code>shopt -s nocasematch while [[ $yn == y || $yn == "yes" ]] ; do </code></pre> <p>or :</p> <pre><code>shopt -s nocasematch while [[ $yn =~ (y|yes) ]] ; do </code></pre> <h2>Note</h2> <ul> <li><code>[[</code> is a bash keyword similar to (but more powerful than) the <code>[</code> command. See <a href="http...
<pre><code>shopt -s nocasematch while [[ $yn == y || $yn == "yes" ]] ; do </code></pre> <p>or :</p> <pre><code>shopt -s nocasematch while [[ $yn =~ (y|yes) ]] ; do </code></pre> <h2>Note</h2> <ul> <li><code>[[</code> is a bash keyword similar to (but more powerful than) the <code>[</code> command. See <a href="http...
367, 387
bash, syntax
<h1>Case insensitive comparison in Bash</h1> <p>I'm trying to write a comparison in a while statement that's case insensitive. Basically, I'm simply trying to shorten the following to act on a yes or no question prompt to the user ...</p> <pre><code>while[ $yn == "y" | $yn == "Y" | $yn == "Yes" | $yn == "yes" ] ; do ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,574
bash
# Case insensitive comparison in Bash I'm trying to write a comparison in a while statement that's case insensitive. Basically, I'm simply trying to shorten the following to act on a yes or no question prompt to the user ... ``` while[ $yn == "y" | $yn == "Y" | $yn == "Yes" | $yn == "yes" ] ; do ``` What would be th...
``` shopt -s nocasematch while [[ $yn == y || $yn == "yes" ]] ; do ``` or : ``` shopt -s nocasematch while [[ $yn =~ (y|yes) ]] ; do ``` ## Note - `[[` is a bash keyword similar to (but more powerful than) the `[` command. See <http://mywiki.wooledge.org/BashFAQ/031> and <http://mywiki.wooledge.org/BashGuide/TestsA...
14806296
Garbage collection in bash
17
2013-02-11 05:18:06
<p>Does bash run a garbage collector? Can it be controlled via some command line options? I can't find anything on the net about this.</p> <p>I have a bash script that runs and over a few days its memory usage increases. I want to know where the memory is going.</p>
11,845
366,817
2013-02-11 06:46:25
14,807,176
14
2013-02-11 06:46:25
1,899,640
2013-02-11 06:46:25
https://stackoverflow.com/q/14806296
https://stackoverflow.com/a/14807176
<p>Bash does not run a garbage collector as such. Since it has no concept of references, there is no need to find data without references. It does free memory no longer in use, though.</p> <p>Here's a simple demonstration of memory usage before and after declaring and overwriting a large variable. Memory usage goes up...
<p>Bash does not run a garbage collector as such. Since it has no concept of references, there is no need to find data without references. It does free memory no longer in use, though.</p> <p>Here's a simple demonstration of memory usage before and after declaring and overwriting a large variable. Memory usage goes up...
58, 387
bash, linux
<h1>Garbage collection in bash</h1> <p>Does bash run a garbage collector? Can it be controlled via some command line options? I can't find anything on the net about this.</p> <p>I have a bash script that runs and over a few days its memory usage increases. I want to know where the memory is going.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,575
bash
# Garbage collection in bash Does bash run a garbage collector? Can it be controlled via some command line options? I can't find anything on the net about this. I have a bash script that runs and over a few days its memory usage increases. I want to know where the memory is going.
Bash does not run a garbage collector as such. Since it has no concept of references, there is no need to find data without references. It does free memory no longer in use, though. Here's a simple demonstration of memory usage before and after declaring and overwriting a large variable. Memory usage goes up then down...
8535947
XSLT 2.0 transformation via linux shell
17
2011-12-16 15:00:07
<p>I want to perform an XSLT 2.0 transformation by the use of command line executions. I heard that i could use the Saxon library by a shell command like:</p> <pre><code>java -jar sax.jar -input foo.xml -xsl foo.xsl -output bar.xml </code></pre> <p>Does anyone know how exactly I can achieve that goal?</p> <p>By the way...
14,679
675,065
2022-07-21 14:55:38
8,535,996
14
2011-12-16 15:04:17
252,228
2022-07-21 14:55:38
https://stackoverflow.com/q/8535947
https://stackoverflow.com/a/8535996
<p>The documentation of Saxon is online: <a href="http://www.saxonica.com/documentation/#!using-xsl/commandline" rel="nofollow noreferrer">http://www.saxonica.com/documentation/#!using-xsl/commandline</a>. So you need:</p> <pre><code>java -jar saxon9he.jar -xsl:foo.xsl -s:foo.xml -o:bar.xml </code></pre>
<p>The documentation of Saxon is online: <a href="http://www.saxonica.com/documentation/#!using-xsl/commandline" rel="nofollow noreferrer">http://www.saxonica.com/documentation/#!using-xsl/commandline</a>. So you need:</p> <pre><code>java -jar saxon9he.jar -xsl:foo.xsl -s:foo.xml -o:bar.xml </code></pre>
17, 272, 390, 4841, 5398
jar, java, saxon, shell, xslt
<h1>XSLT 2.0 transformation via linux shell</h1> <p>I want to perform an XSLT 2.0 transformation by the use of command line executions. I heard that i could use the Saxon library by a shell command like:</p> <pre><code>java -jar sax.jar -input foo.xml -xsl foo.xsl -output bar.xml </code></pre> <p>Does anyone know how e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,576
bash
# XSLT 2.0 transformation via linux shell I want to perform an XSLT 2.0 transformation by the use of command line executions. I heard that i could use the Saxon library by a shell command like: ``` java -jar sax.jar -input foo.xml -xsl foo.xsl -output bar.xml ``` Does anyone know how exactly I can achieve that goal?...
The documentation of Saxon is online: <http://www.saxonica.com/documentation/#!using-xsl/commandline>. So you need: ``` java -jar saxon9he.jar -xsl:foo.xsl -s:foo.xml -o:bar.xml ```
7180082
grep output into array
17
2011-08-24 17:58:28
<p>Guys How can I make this work</p> <blockquote> <p>`find /xyz/abc/music/ |grep def`</p> </blockquote> <p>I don't want to store the array in any temporary variable. How can we directly operate on this array.</p> <p>so to get the 1st element of that array </p> <blockquote> <p>echo ${$(`find /xyz/abc/music/ |gre...
47,178
910,149
2014-05-13 11:41:54
7,180,101
14
2011-08-24 18:00:08
308,392
2011-08-24 18:12:19
https://stackoverflow.com/q/7180082
https://stackoverflow.com/a/7180101
<p>If you just need the first element (or rather line), you can use <code>head</code>:</p> <pre><code>`find /xyz/abc/music/ |grep def | head -n 1` </code></pre> <p>If you need access to arbitrary elements, you can store the array first, and then retrieve the element:</p> <pre><code>arr=(`find /xyz/abc/music/ |grep d...
<p>If you just need the first element (or rather line), you can use <code>head</code>:</p> <pre><code>`find /xyz/abc/music/ |grep def | head -n 1` </code></pre> <p>If you need access to arbitrary elements, you can store the array first, and then retrieve the element:</p> <pre><code>arr=(`find /xyz/abc/music/ |grep d...
114, 387, 1271
arrays, bash, grep
<h1>grep output into array</h1> <p>Guys How can I make this work</p> <blockquote> <p>`find /xyz/abc/music/ |grep def`</p> </blockquote> <p>I don't want to store the array in any temporary variable. How can we directly operate on this array.</p> <p>so to get the 1st element of that array </p> <blockquote> <p>ech...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,577
bash
# grep output into array Guys How can I make this work > `find /xyz/abc/music/ |grep def` I don't want to store the array in any temporary variable. How can we directly operate on this array. so to get the 1st element of that array > echo ${$(`find /xyz/abc/music/ |grep def`)[0]} > Please help me How I can achieve...
If you just need the first element (or rather line), you can use `head`: ``` `find /xyz/abc/music/ |grep def | head -n 1` ``` If you need access to arbitrary elements, you can store the array first, and then retrieve the element: ``` arr=(`find /xyz/abc/music/ |grep def`) echo ${arr[n]} ``` but this will not put ea...
6827870
Capturing colorized output to a bash variable
17
2011-07-26 09:20:13
<p>I want to capture the color output from <code>git status</code> in a variable and print it later.</p> <p>So far I have come up to:</p> <pre><code>status=$(git status -s) echo -e "$status" </code></pre> <p>The above script keeps the newline intact (thx to <a href="https://stackoverflow.com/q/613572/146272">Capturi...
3,924
146,272
2015-11-22 22:06:45
6,827,961
14
2011-07-26 09:28:20
259,310
2011-07-26 09:28:20
https://stackoverflow.com/q/6827870
https://stackoverflow.com/a/6827961
<p>The problem is not that bash strips the color output before storing the text, but that <code>git</code> refuses to produce the colored output int he first place, probably because it can tell that its STDOUT is not a terminal. Many commands do this (e.g. <code>ls</code>). Most of these have an option telling them to ...
<p>The problem is not that bash strips the color output before storing the text, but that <code>git</code> refuses to produce the colored output int he first place, probably because it can tell that its STDOUT is not a terminal. Many commands do this (e.g. <code>ls</code>). Most of these have an option telling them to ...
276, 387, 6439
bash, colors, variables
<h1>Capturing colorized output to a bash variable</h1> <p>I want to capture the color output from <code>git status</code> in a variable and print it later.</p> <p>So far I have come up to:</p> <pre><code>status=$(git status -s) echo -e "$status" </code></pre> <p>The above script keeps the newline intact (thx to <a h...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,578
bash
# Capturing colorized output to a bash variable I want to capture the color output from `git status` in a variable and print it later. So far I have come up to: ``` status=$(git status -s) echo -e "$status" ``` The above script keeps the newline intact (thx to [Capturing multiple line output into a Bash variable](h...
The problem is not that bash strips the color output before storing the text, but that `git` refuses to produce the colored output int he first place, probably because it can tell that its STDOUT is not a terminal. Many commands do this (e.g. `ls`). Most of these have an option telling them to use color anyway, for use...
6297271
Is "export" needed, when setting a variable in .bashrc?
17
2011-06-09 18:08:45
<p>I wonder if there is a need to use "export" when setting a variable in .bashrc.</p> <p>In my tests editing .bashrc there was no difference between</p> <pre><code>foo=bar </code></pre> <p>and</p> <pre><code>export foo=bar </code></pre> <p>In both cases, after login "echo $foo" outputs "bar".</p> <p>I am using D...
8,156
568,737
2023-06-16 00:39:02
6,297,339
14
2011-06-09 18:13:47
265,804
2011-06-09 18:13:47
https://stackoverflow.com/q/6297271
https://stackoverflow.com/a/6297339
<p>Try creating a shell script that accesses the <code>foo</code> variable.</p> <p>If <code>foo</code> was <code>export</code>'ed, it will be visible in the shell script, otherwise it won't.</p>
<p>Try creating a shell script that accesses the <code>foo</code> variable.</p> <p>If <code>foo</code> was <code>export</code>'ed, it will be visible in the shell script, otherwise it won't.</p>
276, 387, 4167
bash, export, variables
<h1>Is "export" needed, when setting a variable in .bashrc?</h1> <p>I wonder if there is a need to use "export" when setting a variable in .bashrc.</p> <p>In my tests editing .bashrc there was no difference between</p> <pre><code>foo=bar </code></pre> <p>and</p> <pre><code>export foo=bar </code></pre> <p>In both c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,579
bash
# Is "export" needed, when setting a variable in .bashrc? I wonder if there is a need to use "export" when setting a variable in .bashrc. In my tests editing .bashrc there was no difference between ``` foo=bar ``` and ``` export foo=bar ``` In both cases, after login "echo $foo" outputs "bar". I am using Debian ...
Try creating a shell script that accesses the `foo` variable. If `foo` was `export`'ed, it will be visible in the shell script, otherwise it won't.
3852616
xargs with command that open editor leaves shell in weird state
17
2010-10-04 03:09:36
<p>I tried to make an alias for committing several different git projects. I tried something like </p> <pre><code>cat projectPaths | \ xargs -I project git --git-dir=project/.git --work-tree=project commit -a </code></pre> <p>where projectPaths is a file containing the paths to all the projects I want to commit. Th...
5,409
465,488
2018-11-02 21:41:15
3,852,702
14
2010-10-04 03:37:24
89,817
2010-10-04 03:37:24
https://stackoverflow.com/q/3852616
https://stackoverflow.com/a/3852702
<p>The problem is that since you're running xargs (and hence git and hence vim) in a pipeline, its stdin is taken from the output of <code>cat projectPaths</code> rather than the terminal; this is confusing vim. Fortunately, the solution is simple: add the <code>-o</code> flag to xargs, and it'll start git (and hence ...
<p>The problem is that since you're running xargs (and hence git and hence vim) in a pipeline, its stdin is taken from the output of <code>cat projectPaths</code> rather than the terminal; this is confusing vim. Fortunately, the solution is simple: add the <code>-o</code> flag to xargs, and it'll start git (and hence ...
34, 293, 387, 531
bash, scripting, unix, vi
<h1>xargs with command that open editor leaves shell in weird state</h1> <p>I tried to make an alias for committing several different git projects. I tried something like </p> <pre><code>cat projectPaths | \ xargs -I project git --git-dir=project/.git --work-tree=project commit -a </code></pre> <p>where projectPaths...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,580
bash
# xargs with command that open editor leaves shell in weird state I tried to make an alias for committing several different git projects. I tried something like ``` cat projectPaths | \ xargs -I project git --git-dir=project/.git --work-tree=project commit -a ``` where projectPaths is a file containing the paths to ...
The problem is that since you're running xargs (and hence git and hence vim) in a pipeline, its stdin is taken from the output of `cat projectPaths` rather than the terminal; this is confusing vim. Fortunately, the solution is simple: add the `-o` flag to xargs, and it'll start git (and hence vim) with input from /dev/...
65980636
Is anybody having this Powershell "Update-Help" command, issue?
16
2021-01-31 15:06:45
<p>I am trying to download and install Help files for all the commands but it won't work. I am using Powershell 7.1.1 inside the Windows Terminal.</p> <pre><code>Update-Help: Failed to update Help for the module(s) 'ConfigDefender, PSReadline' with UI culture(s) {en-US} : One or more errors occurred. (Response status c...
10,292
14,333,734
2024-05-06 02:27:51
65,982,117
14
2021-01-31 17:24:50
14,333,734
2023-06-23 10:23:01
https://stackoverflow.com/q/65980636
https://stackoverflow.com/a/65982117
<p>Solved, thanks to another post I've found on stackoverflow. <a href="https://answers.microsoft.com/en-us/windows/forum/all/updateing-powershell-user-help-files/07afd880-c543-4e56-9446-1e9eb509003d" rel="nofollow noreferrer">According to this Microsoft Forum</a>, the below command should bypass any errors and give yo...
<p>Solved, thanks to another post I've found on stackoverflow. <a href="https://answers.microsoft.com/en-us/windows/forum/all/updateing-powershell-user-help-files/07afd880-c543-4e56-9446-1e9eb509003d" rel="nofollow noreferrer">According to this Microsoft Forum</a>, the below command should bypass any errors and give yo...
526, 144089
powershell, powershell-7.0
<h1>Is anybody having this Powershell "Update-Help" command, issue?</h1> <p>I am trying to download and install Help files for all the commands but it won't work. I am using Powershell 7.1.1 inside the Windows Terminal.</p> <pre><code>Update-Help: Failed to update Help for the module(s) 'ConfigDefender, PSReadline' wit...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,581
bash
# Is anybody having this Powershell "Update-Help" command, issue? I am trying to download and install Help files for all the commands but it won't work. I am using Powershell 7.1.1 inside the Windows Terminal. ``` Update-Help: Failed to update Help for the module(s) 'ConfigDefender, PSReadline' with UI culture(s) {en...
Solved, thanks to another post I've found on stackoverflow. [According to this Microsoft Forum](https://answers.microsoft.com/en-us/windows/forum/all/updateing-powershell-user-help-files/07afd880-c543-4e56-9446-1e9eb509003d), the below command should bypass any errors and give you a successful run of cmdlet `Update-Hel...
27722205
'New-AzureStorageContext' is not recognized
16
2014-12-31 14:04:05
<p>I'm trying to run a PowerShell script that functions on a colleague's computer, but is failing on mine on this line:</p> <pre><code>Set-Variable -Name StorageContext -Value (New-AzureStorageContext -ConnectionString $storageConnectionString) </code></pre> <p>My error is:</p> <blockquote> <p>New-AzureStorageCont...
45,041
980,799
2023-09-21 17:21:56
56,055,633
14
2019-05-09 08:50:24
8,841,378
2023-09-21 17:21:56
https://stackoverflow.com/q/27722205
https://stackoverflow.com/a/56055633
<p>I have same problem with you. My problem is that I was using the wrong command: <code>AzureStorageContext</code>. It should be <code>AzStorageContext</code>.</p>
<p>I have same problem with you. My problem is that I was using the wrong command: <code>AzureStorageContext</code>. It should be <code>AzStorageContext</code>.</p>
526, 14158
azure, powershell
<h1>'New-AzureStorageContext' is not recognized</h1> <p>I'm trying to run a PowerShell script that functions on a colleague's computer, but is failing on mine on this line:</p> <pre><code>Set-Variable -Name StorageContext -Value (New-AzureStorageContext -ConnectionString $storageConnectionString) </code></pre> <p>My ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,582
bash
# 'New-AzureStorageContext' is not recognized I'm trying to run a PowerShell script that functions on a colleague's computer, but is failing on mine on this line: ``` Set-Variable -Name StorageContext -Value (New-AzureStorageContext -ConnectionString $storageConnectionString) ``` My error is: > New-AzureStorageCont...
I have same problem with you. My problem is that I was using the wrong command: `AzureStorageContext`. It should be `AzStorageContext`.
49503805
echo command color not working
16
2018-03-27 03:14:55
<p>I have a code like this:</p> <pre><code>#!/bin/bash COLOR_REST='\e[0m' COLOR_GREEN='\e[0;32m' echo -e "${COLOR_GREEN}OK${COLOR_REST}" </code></pre> <p>When I copy and paste the code into my iTerm, it displays <code>OK</code> in the color of green.</p> <p><a href="https://i.sstatic.net/gukJB.png" rel="noreferrer"...
9,910
1,408,347
2022-03-28 23:23:05
49,504,086
14
2018-03-27 03:52:43
236,465
2018-03-27 03:52:43
https://stackoverflow.com/q/49503805
https://stackoverflow.com/a/49504086
<p>Use</p> <pre><code>#!/bin/bash COLOR_REST="$(tput sgr0)" COLOR_GREEN="$(tput setaf 2)" printf '%s%s%s\n' $COLOR_GREEN 'OK' $COLOR_REST </code></pre> <p>which uses printf to avoid <code>echo</code> options and <code>tput</code> to be portable across different terminals.</p>
<p>Use</p> <pre><code>#!/bin/bash COLOR_REST="$(tput sgr0)" COLOR_GREEN="$(tput setaf 2)" printf '%s%s%s\n' $COLOR_GREEN 'OK' $COLOR_REST </code></pre> <p>which uses printf to avoid <code>echo</code> options and <code>tput</code> to be portable across different terminals.</p>
369, 387, 6439, 13824
bash, colors, echo, macos
<h1>echo command color not working</h1> <p>I have a code like this:</p> <pre><code>#!/bin/bash COLOR_REST='\e[0m' COLOR_GREEN='\e[0;32m' echo -e "${COLOR_GREEN}OK${COLOR_REST}" </code></pre> <p>When I copy and paste the code into my iTerm, it displays <code>OK</code> in the color of green.</p> <p><a href="https://i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,583
bash
# echo command color not working I have a code like this: ``` #!/bin/bash COLOR_REST='\e[0m' COLOR_GREEN='\e[0;32m' echo -e "${COLOR_GREEN}OK${COLOR_REST}" ``` When I copy and paste the code into my iTerm, it displays `OK` in the color of green. [![enter image description here](https://i.sstatic.net/gukJB.png)](ht...
Use ``` #!/bin/bash COLOR_REST="$(tput sgr0)" COLOR_GREEN="$(tput setaf 2)" printf '%s%s%s\n' $COLOR_GREEN 'OK' $COLOR_REST ``` which uses printf to avoid `echo` options and `tput` to be portable across different terminals.
46467523
How to change picture background color using ImageMagick?
16
2017-09-28 11:00:34
<p>I want to change my picture background color, This is my source <a href="http://cdn.mayike.com/emotion/img/attached/1/image/dt/20170916/18/20170916180007_833.png" rel="noreferrer">http://cdn.mayike.com/emotion/img/attached/1/image/dt/20170916/18/20170916180007_833.png</a>.<br><br> If I want to change the background ...
29,626
7,664,948
2018-07-06 23:29:00
46,474,064
14
2017-09-28 16:28:12
7,355,741
2017-09-28 16:28:12
https://stackoverflow.com/q/46467523
https://stackoverflow.com/a/46474064
<p>I do not think you will get a perfect result due to the fact that your image is not binary. Nevertheless in Imagemagick you have two choices. First you could just change all white to red:</p> <pre><code>convert 20170916180007_833.png.jpeg -fuzz 25% -fill red -opaque white -flatten result1.png </code></pre> <p><a h...
<p>I do not think you will get a perfect result due to the fact that your image is not binary. Nevertheless in Imagemagick you have two choices. First you could just change all white to red:</p> <pre><code>convert 20170916180007_833.png.jpeg -fuzz 25% -fill red -opaque white -flatten result1.png </code></pre> <p><a h...
58, 390, 6554
imagemagick, linux, shell
<h1>How to change picture background color using ImageMagick?</h1> <p>I want to change my picture background color, This is my source <a href="http://cdn.mayike.com/emotion/img/attached/1/image/dt/20170916/18/20170916180007_833.png" rel="noreferrer">http://cdn.mayike.com/emotion/img/attached/1/image/dt/20170916/18/2017...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,584
bash
# How to change picture background color using ImageMagick? I want to change my picture background color, This is my source <http://cdn.mayike.com/emotion/img/attached/1/image/dt/20170916/18/20170916180007_833.png>. If I want to change the background color to another color, what should I do? If I want to cha...
I do not think you will get a perfect result due to the fact that your image is not binary. Nevertheless in Imagemagick you have two choices. First you could just change all white to red: ``` convert 20170916180007_833.png.jpeg -fuzz 25% -fill red -opaque white -flatten result1.png ``` [![enter image description here...
34793704
Reset bash history search position
16
2016-01-14 15:44:10
<p>In a terminal the Bash history can be searched easily with <kbd>Ctrl</kbd>+<kbd>r</kbd>. But what if I cannot find what I am looking for? I am stuck in the middle of my history. What if a want to search again from the beginning?</p> <p>Is there another shortcut to reset the history search?</p>
2,215
3,751,845
2019-06-07 15:19:51
34,794,365
14
2016-01-14 16:13:52
3,266,847
2016-01-14 16:13:52
https://stackoverflow.com/q/34793704
https://stackoverflow.com/a/34794365
<p>There is <kbd>Meta</kbd> + <kbd>></kbd>, which is bound to <code>end-of-history</code> and useful if you're in the middle of your history. The meta key is usually the <kbd>Alt</kbd> key.</p> <p>If you see that your incremental history search isn't successful, you can use <kbd>Ctrl</kbd> + <kbd>G</kbd>, which is bou...
<p>There is <kbd>Meta</kbd> + <kbd>></kbd>, which is bound to <code>end-of-history</code> and useful if you're in the middle of your history. The meta key is usually the <kbd>Alt</kbd> key.</p> <p>If you see that your incremental history search isn't successful, you can use <kbd>Ctrl</kbd> + <kbd>G</kbd>, which is bou...
58, 387, 391, 4198
bash, keyboard-shortcuts, linux, terminal
<h1>Reset bash history search position</h1> <p>In a terminal the Bash history can be searched easily with <kbd>Ctrl</kbd>+<kbd>r</kbd>. But what if I cannot find what I am looking for? I am stuck in the middle of my history. What if a want to search again from the beginning?</p> <p>Is there another shortcut to reset t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,585
bash
# Reset bash history search position In a terminal the Bash history can be searched easily with `Ctrl`+`r`. But what if I cannot find what I am looking for? I am stuck in the middle of my history. What if a want to search again from the beginning? Is there another shortcut to reset the history search?
There is `Meta` + `>`, which is bound to `end-of-history` and useful if you're in the middle of your history. The meta key is usually the `Alt` key. If you see that your incremental history search isn't successful, you can use `Ctrl` + `G`, which is bound to `abort` and restores the previous line and history position....
27268358
Create directory in hadoop filesystem
16
2014-12-03 09:47:44
<p>I'm new to hadoop. I am trying to create a directory in hdfs but I am not able to create.</p> <p>I have logged into "hduser" hence I assumed /home/hduser" pre-exists as Unix fs. So I tried to create hadoop directory using below command. </p> <pre><code>[hduser@Virus ~]$ hadoop fs -mkdir /home/hduser/mydata/ 14/12...
84,046
2,310,989
2021-10-31 06:24:43
31,146,005
14
2015-06-30 18:43:00
2,294,772
2018-04-18 05:48:49
https://stackoverflow.com/q/27268358
https://stackoverflow.com/a/31146005
<p>To leave safe mode, try below command since <code>hadoop dfsadmin -safemode</code> is deprecated in newer distribution of Hadoop:</p> <pre><code> hdfs dfsadmin -safemode leave </code></pre> <p>By default, user's <code>home</code> directory in hdfs exists with '/user/hduser' not as /home/hduser'.</p> <p>If you tri...
<p>To leave safe mode, try below command since <code>hadoop dfsadmin -safemode</code> is deprecated in newer distribution of Hadoop:</p> <pre><code> hdfs dfsadmin -safemode leave </code></pre> <p>By default, user's <code>home</code> directory in hdfs exists with '/user/hduser' not as /home/hduser'.</p> <p>If you tri...
390, 1995, 11225, 40255
command-line-interface, hadoop, hdfs, shell
<h1>Create directory in hadoop filesystem</h1> <p>I'm new to hadoop. I am trying to create a directory in hdfs but I am not able to create.</p> <p>I have logged into "hduser" hence I assumed /home/hduser" pre-exists as Unix fs. So I tried to create hadoop directory using below command. </p> <pre><code>[hduser@Virus ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,586
bash
# Create directory in hadoop filesystem I'm new to hadoop. I am trying to create a directory in hdfs but I am not able to create. I have logged into "hduser" hence I assumed /home/hduser" pre-exists as Unix fs. So I tried to create hadoop directory using below command. ``` [hduser@Virus ~]$ hadoop fs -mkdir /home/hd...
To leave safe mode, try below command since `hadoop dfsadmin -safemode` is deprecated in newer distribution of Hadoop: ``` hdfs dfsadmin -safemode leave ``` By default, user's `home` directory in hdfs exists with '/user/hduser' not as /home/hduser'. If you tried to create directory directly like below then it will ...
18731610
xargs with multiple commands
16
2013-09-11 02:12:14
<p>In the current directory, I'd like to print the filename and contents in it. I can print filenames or contents separately by</p> <pre><code>find . | grep "file_for_print" | xargs echo find . | grep "file_for_print" | xargs cat </code></pre> <p>but what I want is printing them together like this:</p> <pre><code>fi...
28,733
930,071
2017-08-14 05:55:27
18,731,704
14
2013-09-11 02:26:03
1,566,221
2017-08-14 05:37:29
https://stackoverflow.com/q/18731610
https://stackoverflow.com/a/18731704
<p>To start with, there is virtually no difference between:</p> <pre><code>find . | grep "file_for_print" | xargs echo </code></pre> <p>and</p> <pre><code>find . -name "file_for_print*" </code></pre> <p>except that the second one will not match filenames like <code>this_is_not_the_file_for_print</code>, and it will...
<p>To start with, there is virtually no difference between:</p> <pre><code>find . | grep "file_for_print" | xargs echo </code></pre> <p>and</p> <pre><code>find . -name "file_for_print*" </code></pre> <p>except that the second one will not match filenames like <code>this_is_not_the_file_for_print</code>, and it will...
387, 10326
bash, xargs
<h1>xargs with multiple commands</h1> <p>In the current directory, I'd like to print the filename and contents in it. I can print filenames or contents separately by</p> <pre><code>find . | grep "file_for_print" | xargs echo find . | grep "file_for_print" | xargs cat </code></pre> <p>but what I want is printing them ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,587
bash
# xargs with multiple commands In the current directory, I'd like to print the filename and contents in it. I can print filenames or contents separately by ``` find . | grep "file_for_print" | xargs echo find . | grep "file_for_print" | xargs cat ``` but what I want is printing them together like this: ``` file1 li...
To start with, there is virtually no difference between: ``` find . | grep "file_for_print" | xargs echo ``` and ``` find . -name "file_for_print*" ``` except that the second one will not match filenames like `this_is_not_the_file_for_print`, and it will print the filenames one per line. It will also be a lot faste...
8537473
Is there an equivalent of "this" in powershell?
16
2011-12-16 16:56:25
<p>Basically I have this code:</p> <pre><code>$file = $web.GetFile("Pages/default.aspx") $file.CheckOut() </code></pre> <p>and I was wondering if there is anyway to use a pipe and the powershell equivalent of <code>this</code> to rewrite it as:</p> <pre><code>$web.GetFile("Pages/default.aspx") | $this.CheckOut() </c...
15,023
226,897
2017-10-24 01:00:34
8,537,574
14
2011-12-16 17:02:52
153,982
2011-12-16 17:02:52
https://stackoverflow.com/q/8537473
https://stackoverflow.com/a/8537574
<p>What you're looking for is <code>$_</code> and it represents the current object in the pipeline. However you can only access <code>$_</code> in a scriptblock of a command that takes pipeline input e.g.:</p> <pre><code>$web.GetFile("Pages/default.aspx") | Foreach-Object -Process {$_.Checkout()} </code></pre> <p>Ho...
<p>What you're looking for is <code>$_</code> and it represents the current object in the pipeline. However you can only access <code>$_</code> in a scriptblock of a command that takes pipeline input e.g.:</p> <pre><code>$web.GetFile("Pages/default.aspx") | Foreach-Object -Process {$_.Checkout()} </code></pre> <p>Ho...
526
powershell
<h1>Is there an equivalent of "this" in powershell?</h1> <p>Basically I have this code:</p> <pre><code>$file = $web.GetFile("Pages/default.aspx") $file.CheckOut() </code></pre> <p>and I was wondering if there is anyway to use a pipe and the powershell equivalent of <code>this</code> to rewrite it as:</p> <pre><code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,588
bash
# Is there an equivalent of "this" in powershell? Basically I have this code: ``` $file = $web.GetFile("Pages/default.aspx") $file.CheckOut() ``` and I was wondering if there is anyway to use a pipe and the powershell equivalent of `this` to rewrite it as: ``` $web.GetFile("Pages/default.aspx") | $this.CheckOut() `...
What you're looking for is `$_` and it represents the current object in the pipeline. However you can only access `$_` in a scriptblock of a command that takes pipeline input e.g.: ``` $web.GetFile("Pages/default.aspx") | Foreach-Object -Process {$_.Checkout()} ``` However there are aliases for the Foreach-Object cmd...
7663481
Trapping getopt invalid options
16
2011-10-05 15:06:58
<p>I'm using <code>getopt</code> (not <code>getops</code>) to provide the ability for my bash script to process options and switches (both long --option and short -o forms).</p> <p>I'd like to be able to trap invalid options and handle them, typically echoing out that the user should try <code>cmd --help</code> and th...
21,299
467,386
2013-11-02 02:27:24
7,675,307
14
2011-10-06 13:56:07
96,588
2011-10-06 13:56:07
https://stackoverflow.com/q/7663481
https://stackoverflow.com/a/7675307
<p><a href="https://github.com/l0b0/tilde/blob/master/scripts/make-links.sh#L68" rel="noreferrer">This</a> sort of style works for me:</p> <pre><code>params="$(getopt -o d:h -l diff:,help --name "$cmdname" -- "$@")" if [ $? -ne 0 ] then usage fi eval set -- "$params" unset params while true do case $1 in ...
<p><a href="https://github.com/l0b0/tilde/blob/master/scripts/make-links.sh#L68" rel="noreferrer">This</a> sort of style works for me:</p> <pre><code>params="$(getopt -o d:h -l diff:,help --name "$cmdname" -- "$@")" if [ $? -ne 0 ] then usage fi eval set -- "$params" unset params while true do case $1 in ...
387, 390, 6107, 10831
bash, case, getopt, shell
<h1>Trapping getopt invalid options</h1> <p>I'm using <code>getopt</code> (not <code>getops</code>) to provide the ability for my bash script to process options and switches (both long --option and short -o forms).</p> <p>I'd like to be able to trap invalid options and handle them, typically echoing out that the user ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,589
bash
# Trapping getopt invalid options I'm using `getopt` (not `getops`) to provide the ability for my bash script to process options and switches (both long --option and short -o forms). I'd like to be able to trap invalid options and handle them, typically echoing out that the user should try `cmd --help` and then exiti...
[This](https://github.com/l0b0/tilde/blob/master/scripts/make-links.sh#L68) sort of style works for me: ``` params="$(getopt -o d:h -l diff:,help --name "$cmdname" -- "$@")" if [ $? -ne 0 ] then usage fi eval set -- "$params" unset params while true do case $1 in -d|--diff) diff_exec=(${...
2472273
How do I run a sudo command in Emacs?
16
2010-03-18 18:07:17
<p>I'm trying to create shortcut keys for some commonly used sudo shell commands (for example, having <code>C-c s</code> run <code>(shell-command "sudo /etc/init.d/apache2 restart")</code>).</p> <p>I tried using a straight-up shell-command call as above, but it just outputs the following to the <code>*Shell Command Ou...
8,818
190,887
2022-08-27 17:14:08
2,473,152
14
2010-03-18 20:29:51
17,637
2012-11-15 11:53:48
https://stackoverflow.com/q/2472273
https://stackoverflow.com/a/2473152
<p>How about:</p> <pre><code>(shell-command (concat "echo " (shell-quote-argument (read-passwd "Password? ")) " | sudo -S your_command_here")) </code></pre>
<p>How about:</p> <pre><code>(shell-command (concat "echo " (shell-quote-argument (read-passwd "Password? ")) " | sudo -S your_command_here")) </code></pre>
371, 390, 1674
emacs, shell, sudo
<h1>How do I run a sudo command in Emacs?</h1> <p>I'm trying to create shortcut keys for some commonly used sudo shell commands (for example, having <code>C-c s</code> run <code>(shell-command "sudo /etc/init.d/apache2 restart")</code>).</p> <p>I tried using a straight-up shell-command call as above, but it just outpu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,590
bash
# How do I run a sudo command in Emacs? I'm trying to create shortcut keys for some commonly used sudo shell commands (for example, having `C-c s` run `(shell-command "sudo /etc/init.d/apache2 restart")`). I tried using a straight-up shell-command call as above, but it just outputs the following to the `*Shell Comman...
How about: ``` (shell-command (concat "echo " (shell-quote-argument (read-passwd "Password? ")) " | sudo -S your_command_here")) ```
1824115
Display socket options
16
2009-12-01 05:11:05
<p>How I can see from shell what socket options are set? In particular I'm interesting to know if SO_BROADCAST is set?</p>
18,166
135,960
2020-05-25 21:44:16
1,824,239
14
2009-12-01 05:52:43
9,530
2009-12-01 05:52:43
https://stackoverflow.com/q/1824115
https://stackoverflow.com/a/1824239
<p>You can use <a href="http://linux.die.net/man/8/lsof" rel="noreferrer"><code>lsof(8)</code></a>. If <code>PID</code> is the process ID and <code>FD</code> is the file descriptor number of the socket you're interested in, you can do this:</p> <pre><code>lsof -a -p PID -d FD -T f </code></pre> <p>To list all IPv4 s...
<p>You can use <a href="http://linux.die.net/man/8/lsof" rel="noreferrer"><code>lsof(8)</code></a>. If <code>PID</code> is the process ID and <code>FD</code> is the file descriptor number of the socket you're interested in, you can do this:</p> <pre><code>lsof -a -p PID -d FD -T f </code></pre> <p>To list all IPv4 s...
58, 390
linux, shell
<h1>Display socket options</h1> <p>How I can see from shell what socket options are set? In particular I'm interesting to know if SO_BROADCAST is set?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,591
bash
# Display socket options How I can see from shell what socket options are set? In particular I'm interesting to know if SO_BROADCAST is set?
You can use [`lsof(8)`](http://linux.die.net/man/8/lsof). If `PID` is the process ID and `FD` is the file descriptor number of the socket you're interested in, you can do this: ``` lsof -a -p PID -d FD -T f ``` To list all IPv4 sockets of a process: ``` lsof -a -p PID -i 4 -T f ``` This will print out the socket op...
369990
Is it possible to customize error display in powershell?
16
2008-12-15 22:56:58
<p>I find the standard Powershell display of errors (red text, multi-line display) a bit distracting. Is it possible to customize this?</p>
16,576
34,438
2016-10-26 13:17:52
370,052
14
2008-12-15 23:20:59
40,405
2011-11-01 20:25:53
https://stackoverflow.com/q/369990
https://stackoverflow.com/a/370052
<p>Yes and yes.</p> <p>You can use the built-in <code>$host</code> object if all you want to do is change the text color. However, you can't change the error message itself - that's hardcoded.</p> <p>What you could do is (a) suppress the error messages, and instead (b) trap the errors and display your own.</p> <p>Ac...
<p>Yes and yes.</p> <p>You can use the built-in <code>$host</code> object if all you want to do is change the text color. However, you can't change the error message itself - that's hardcoded.</p> <p>What you could do is (a) suppress the error messages, and instead (b) trap the errors and display your own.</p> <p>Ac...
526, 964
customization, powershell
<h1>Is it possible to customize error display in powershell?</h1> <p>I find the standard Powershell display of errors (red text, multi-line display) a bit distracting. Is it possible to customize this?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,592
bash
# Is it possible to customize error display in powershell? I find the standard Powershell display of errors (red text, multi-line display) a bit distracting. Is it possible to customize this?
Yes and yes. You can use the built-in `$host` object if all you want to do is change the text color. However, you can't change the error message itself - that's hardcoded. What you could do is (a) suppress the error messages, and instead (b) trap the errors and display your own. Accomplish (a) by setting `$ErrorActi...
52649122
Check function exists in PowerShell module
15
2018-10-04 14:23:14
<p>I’ve the following PowerShell script which searches in a directory for PowerShell module). All found modules will be imported and stored in a list (using the -PassThru) option. The scrip iterates over the imported modules and invokes a function defined in the module:</p> <pre><code># Discover and import all modules...
11,578
1,320,170
2024-01-24 18:52:17
52,649,216
14
2018-10-04 14:27:51
3,829,407
2018-10-04 14:27:51
https://stackoverflow.com/q/52649122
https://stackoverflow.com/a/52649216
<p><code>Get-Command</code> can tell you this. You can even use module scope to be sure it comes from a specific module</p> <pre><code>get-command activedirectory\get-aduser -erroraction silentlycontinue </code></pre> <p>For example. Evaluate that in an if statement and you should be good to go. </p>
<p><code>Get-Command</code> can tell you this. You can even use module scope to be sure it comes from a specific module</p> <pre><code>get-command activedirectory\get-aduser -erroraction silentlycontinue </code></pre> <p>For example. Evaluate that in an if statement and you should be good to go. </p>
526
powershell
<h1>Check function exists in PowerShell module</h1> <p>I’ve the following PowerShell script which searches in a directory for PowerShell module). All found modules will be imported and stored in a list (using the -PassThru) option. The scrip iterates over the imported modules and invokes a function defined in the modul...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,593
bash
# Check function exists in PowerShell module I’ve the following PowerShell script which searches in a directory for PowerShell module). All found modules will be imported and stored in a list (using the -PassThru) option. The scrip iterates over the imported modules and invokes a function defined in the module: ``` #...
`Get-Command` can tell you this. You can even use module scope to be sure it comes from a specific module ``` get-command activedirectory\get-aduser -erroraction silentlycontinue ``` For example. Evaluate that in an if statement and you should be good to go.
44794821
Macports: assume yes on "Continue Y/N" prompts?
15
2017-06-28 06:09:19
<p>I'm a complete noob when it comes to macports. I've just started a new job, they've given me a new work laptop and a basic bash script filled with just over 20,000 ports. I'm running macports 2.4.1 on OS X Sierra.</p> <p>Occasionally a port wants my password, usually to allow a port to run on startup. So simply cre...
3,800
7,024,304
2018-09-07 07:54:12
44,808,833
14
2017-06-28 17:14:01
5,041,452
2017-12-30 23:06:46
https://stackoverflow.com/q/44794821
https://stackoverflow.com/a/44808833
<p>Add the <code>-N</code> flag to the port command so "interactive questions are not asked."</p> <p>From <code>man port</code>:</p> <pre><code> -N Non-interactive mode, interactive questions are not asked </code></pre>
<p>Add the <code>-N</code> flag to the port command so "interactive questions are not asked."</p> <p>From <code>man port</code>:</p> <pre><code> -N Non-interactive mode, interactive questions are not asked </code></pre>
369, 387, 8199
bash, macos, macports
<h1>Macports: assume yes on "Continue Y/N" prompts?</h1> <p>I'm a complete noob when it comes to macports. I've just started a new job, they've given me a new work laptop and a basic bash script filled with just over 20,000 ports. I'm running macports 2.4.1 on OS X Sierra.</p> <p>Occasionally a port wants my password,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,594
bash
# Macports: assume yes on "Continue Y/N" prompts? I'm a complete noob when it comes to macports. I've just started a new job, they've given me a new work laptop and a basic bash script filled with just over 20,000 ports. I'm running macports 2.4.1 on OS X Sierra. Occasionally a port wants my password, usually to allo...
Add the `-N` flag to the port command so "interactive questions are not asked." From `man port`: ``` -N Non-interactive mode, interactive questions are not asked ```
44059885
PowerShell Remove Junction
15
2017-05-19 01:02:26
<p>As of Windows 10 PowerShell is finally capable of creating Junctions and links natively.</p> <p>Howerver the Remove-Item function seems to be unaware of the junction and tries to remove the directory asking for confirmation and if it should recursively delete items within.</p> <p>So, the question is: Is there a wa...
23,245
333,492
2025-08-18 09:58:06
44,060,418
14
2017-05-19 02:21:36
3,829,407
2017-05-19 02:21:36
https://stackoverflow.com/q/44059885
https://stackoverflow.com/a/44060418
<blockquote> <p>Is there a way to remove a junction using PowerShell?</p> </blockquote> <p>Currently, at least in PowerShell v5, <a href="https://github.com/PowerShell/PowerShell/issues/621" rel="noreferrer">this is considered "fixed"</a>. What you can do is use the <code>-Force</code> switch, else you will get an e...
<blockquote> <p>Is there a way to remove a junction using PowerShell?</p> </blockquote> <p>Currently, at least in PowerShell v5, <a href="https://github.com/PowerShell/PowerShell/issues/621" rel="noreferrer">this is considered "fixed"</a>. What you can do is use the <code>-Force</code> switch, else you will get an e...
526, 40006
junction, powershell
<h1>PowerShell Remove Junction</h1> <p>As of Windows 10 PowerShell is finally capable of creating Junctions and links natively.</p> <p>Howerver the Remove-Item function seems to be unaware of the junction and tries to remove the directory asking for confirmation and if it should recursively delete items within.</p> <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,595
bash
# PowerShell Remove Junction As of Windows 10 PowerShell is finally capable of creating Junctions and links natively. Howerver the Remove-Item function seems to be unaware of the junction and tries to remove the directory asking for confirmation and if it should recursively delete items within. So, the question is: ...
> Is there a way to remove a junction using PowerShell? Currently, at least in PowerShell v5, [this is considered "fixed"](https://github.com/PowerShell/PowerShell/issues/621). What you can do is use the `-Force` switch, else you will get an error calling the path an NTFS junction. The reason that I at least use the q...
43902878
Run Powershell script from URL without temporary file
15
2017-05-10 21:15:56
<p>I want to write a PowerShell script that runs a PowerShell script stored at a URL, passing both custom arguments and forwarding any arguments that are given to this PowerShell. Concretely, I can do:</p> <pre><code>$VAR=Invoke-WebRequest http://example.com/powershell.ps1 $TEMP=New-TemporaryFile $FILE=$TEMP.FullName ...
33,485
160,673
2025-05-13 08:06:38
43,903,244
14
2017-05-10 21:47:11
3,425,553
2017-05-16 21:36:09
https://stackoverflow.com/q/43902878
https://stackoverflow.com/a/43903244
<p>You can convert content to script block and then invoke it as command with arguments </p> <pre><code>$Script = Invoke-WebRequest 'http://example.com/powershell.ps1' $ScriptBlock = [Scriptblock]::Create($Script.Content) Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList ($args + @('someargument')) </code></pre>
<p>You can convert content to script block and then invoke it as command with arguments </p> <pre><code>$Script = Invoke-WebRequest 'http://example.com/powershell.ps1' $ScriptBlock = [Scriptblock]::Create($Script.Content) Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList ($args + @('someargument')) </code></pre>
526
powershell
<h1>Run Powershell script from URL without temporary file</h1> <p>I want to write a PowerShell script that runs a PowerShell script stored at a URL, passing both custom arguments and forwarding any arguments that are given to this PowerShell. Concretely, I can do:</p> <pre><code>$VAR=Invoke-WebRequest http://example.c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,596
bash
# Run Powershell script from URL without temporary file I want to write a PowerShell script that runs a PowerShell script stored at a URL, passing both custom arguments and forwarding any arguments that are given to this PowerShell. Concretely, I can do: ``` $VAR=Invoke-WebRequest http://example.com/powershell.ps1 $T...
You can convert content to script block and then invoke it as command with arguments ``` $Script = Invoke-WebRequest 'http://example.com/powershell.ps1' $ScriptBlock = [Scriptblock]::Create($Script.Content) Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList ($args + @('someargument')) ```
41553303
Pass groovy variable to shell script
15
2017-01-09 17:11:56
<p>I just started learning groovy.I want to pass the svnSourcePath and svnDestPath to shell script in the svn copy command. But URL not rendered.</p> <pre><code>node { stage 'Copy Svn code' def svnSourcePath = "${svnBaseURL}${svnAppCode}${svnEnvDev}${SVN_DEV_PACKAGE}" def svnDestPath = "${svnBaseURL}${svnAppCode}${s...
29,277
905,628
2022-12-26 06:32:42
41,597,369
14
2017-01-11 17:43:41
905,628
2017-01-11 17:43:41
https://stackoverflow.com/q/41553303
https://stackoverflow.com/a/41597369
<p>added the single quotes and plus operater('+ variable +') around the variable. Now it is working</p> <pre><code>svn copy '''+svnSourcePath+' '+svnDestPath+''' -m 'promote dev to test' --username $SVN_USER --password $SVN_PWD ''' </code></pre>
<p>added the single quotes and plus operater('+ variable +') around the variable. Now it is working</p> <pre><code>svn copy '''+svnSourcePath+' '+svnDestPath+''' -m 'promote dev to test' --username $SVN_USER --password $SVN_PWD ''' </code></pre>
390, 849, 64999, 79229
cloudbees, groovy, jenkins, shell
<h1>Pass groovy variable to shell script</h1> <p>I just started learning groovy.I want to pass the svnSourcePath and svnDestPath to shell script in the svn copy command. But URL not rendered.</p> <pre><code>node { stage 'Copy Svn code' def svnSourcePath = "${svnBaseURL}${svnAppCode}${svnEnvDev}${SVN_DEV_PACKAGE}" de...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,597
bash
# Pass groovy variable to shell script I just started learning groovy.I want to pass the svnSourcePath and svnDestPath to shell script in the svn copy command. But URL not rendered. ``` node { stage 'Copy Svn code' def svnSourcePath = "${svnBaseURL}${svnAppCode}${svnEnvDev}${SVN_DEV_PACKAGE}" def svnDestPath = "${s...
added the single quotes and plus operater('+ variable +') around the variable. Now it is working ``` svn copy '''+svnSourcePath+' '+svnDestPath+''' -m 'promote dev to test' --username $SVN_USER --password $SVN_PWD ''' ```
40165593
What is a sourced shell function?
15
2016-10-20 22:34:51
<p>In the nvm <a href="https://github.com/creationix/nvm/blob/master/README.markdown" rel="noreferrer">README.markdown</a> it says</p> <blockquote> <p>Please note that <code>which nvm</code> will not work, since <code>nvm</code> is a sourced shell function, not an executable binary.</p> </blockquote> <p>What I fo...
1,338
3,885,927
2016-10-20 23:20:54
40,165,622
14
2016-10-20 22:37:06
14,122
2016-10-20 22:44:03
https://stackoverflow.com/q/40165593
https://stackoverflow.com/a/40165622
<p>This verbiage is sloppy. <code>nvm</code> is simply a shell function defined by sourcing the file in which that function is defined. That doesn't change the function in any qualitative way: It would be the same function, with all the same behaviors, if you'd typed it in by hand, so applying "sourced" as a modifier i...
<p>This verbiage is sloppy. <code>nvm</code> is simply a shell function defined by sourcing the file in which that function is defined. That doesn't change the function in any qualitative way: It would be the same function, with all the same behaviors, if you'd typed it in by hand, so applying "sourced" as a modifier i...
387, 81748
bash, nvm
<h1>What is a sourced shell function?</h1> <p>In the nvm <a href="https://github.com/creationix/nvm/blob/master/README.markdown" rel="noreferrer">README.markdown</a> it says</p> <blockquote> <p>Please note that <code>which nvm</code> will not work, since <code>nvm</code> is a sourced shell function, not an executa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,598
bash
# What is a sourced shell function? In the nvm [README.markdown](https://github.com/creationix/nvm/blob/master/README.markdown) it says > Please note that `which nvm` will not work, since `nvm` is a sourced shell > function, not an executable binary. What I found is the nvm install process will update the `.bashrc` ...
This verbiage is sloppy. `nvm` is simply a shell function defined by sourcing the file in which that function is defined. That doesn't change the function in any qualitative way: It would be the same function, with all the same behaviors, if you'd typed it in by hand, so applying "sourced" as a modifier is a bit mislea...
17916201
Background spawned process in Expect
15
2013-07-29 04:43:19
<p>I'm using expect to start an application on my server:</p> <pre><code>#!/usr/bin/expect set timeout -1 spawn "bin/start-all.sh" expect { -re "Found MongoDB in" { send "y\r"; exp_continue } -re "Found Hadoop in" { send "y\r"; exp_continue } -re "Going to start Hadoop" { interact } } </code></pre> <p>I...
11,517
739,282
2019-09-24 00:39:18
32,545,624
14
2015-09-13 02:04:20
1,296,044
2017-04-07 03:38:16
https://stackoverflow.com/q/17916201
https://stackoverflow.com/a/32545624
<p>I had the same problem and figured this out.</p> <p>When <code>expect</code> exits, it sends a <code>SIGHUP</code> (hangup signal) to the spawned subprocess. By default, this <code>SIGHUP</code> causes termination of the spawned process.</p> <p>If you want the underlying process not to die from <code>SIGHUP</code>...
<p>I had the same problem and figured this out.</p> <p>When <code>expect</code> exits, it sends a <code>SIGHUP</code> (hangup signal) to the spawned subprocess. By default, this <code>SIGHUP</code> causes termination of the spawned process.</p> <p>If you want the underlying process not to die from <code>SIGHUP</code>...
34, 390, 5881, 9048, 15292
background-process, expect, shell, tcl, unix
<h1>Background spawned process in Expect</h1> <p>I'm using expect to start an application on my server:</p> <pre><code>#!/usr/bin/expect set timeout -1 spawn "bin/start-all.sh" expect { -re "Found MongoDB in" { send "y\r"; exp_continue } -re "Found Hadoop in" { send "y\r"; exp_continue } -re "Going to st...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,599
bash
# Background spawned process in Expect I'm using expect to start an application on my server: ``` #!/usr/bin/expect set timeout -1 spawn "bin/start-all.sh" expect { -re "Found MongoDB in" { send "y\r"; exp_continue } -re "Found Hadoop in" { send "y\r"; exp_continue } -re "Going to start Hadoop" { intera...
I had the same problem and figured this out. When `expect` exits, it sends a `SIGHUP` (hangup signal) to the spawned subprocess. By default, this `SIGHUP` causes termination of the spawned process. If you want the underlying process not to die from `SIGHUP` you have two easy options. Both work well: 1) Ask `expect` ...
26797651
Creation of .ebextensions folder in aws elastic beanstalk
15
2014-11-07 09:06:44
<p>I am trying to deploy a shellscript script to install a program when autoscaling triggers on aws elastic beanstalk.</p> <p>I have searched on google and it all points to the creation of .ebextensions to use a config file to install the program upon start up May i know how do i create this?</p> <p>Many thanks for t...
20,741
4,226,241
2014-11-11 09:32:58
26,804,625
14
2014-11-07 15:32:25
3,107,308
2014-11-07 15:32:25
https://stackoverflow.com/q/26797651
https://stackoverflow.com/a/26804625
<p>You need to do the following (obviously catering for your requirements):</p> <p>In the root on your packaged software create a folder called <strong>.ebextensions</strong></p> <pre><code>drwxr-xr-x 4 root root 4096 Sep 30 13:39 . dr-xr-x--- 7 root root 4096 Nov 4 15:22 .. drwxr-xr-x 2 root root 4096 N...
<p>You need to do the following (obviously catering for your requirements):</p> <p>In the root on your packaged software create a folder called <strong>.ebextensions</strong></p> <pre><code>drwxr-xr-x 4 root root 4096 Sep 30 13:39 . dr-xr-x--- 7 root root 4096 Nov 4 15:22 .. drwxr-xr-x 2 root root 4096 N...
390, 33388, 105747
amazon-elastic-beanstalk, amazon-web-services, shell
<h1>Creation of .ebextensions folder in aws elastic beanstalk</h1> <p>I am trying to deploy a shellscript script to install a program when autoscaling triggers on aws elastic beanstalk.</p> <p>I have searched on google and it all points to the creation of .ebextensions to use a config file to install the program upon ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,600
bash
# Creation of .ebextensions folder in aws elastic beanstalk I am trying to deploy a shellscript script to install a program when autoscaling triggers on aws elastic beanstalk. I have searched on google and it all points to the creation of .ebextensions to use a config file to install the program upon start up May i k...
You need to do the following (obviously catering for your requirements): In the root on your packaged software create a folder called **.ebextensions** ``` drwxr-xr-x 4 root root 4096 Sep 30 13:39 . dr-xr-x--- 7 root root 4096 Nov 4 15:22 .. drwxr-xr-x 2 root root 4096 Nov 4 15:22 .ebextensions ``` In ...
18477785
Bash: Why does parent script not terminate on SIGINT when child script traps SIGINT?
15
2013-08-28 00:59:29
<p>script1.sh:</p> <pre><code> #!/bin/bash ./script2.sh echo after-script </code></pre> <p>script2.sh:</p> <pre><code>#!/bin/bash function handler { exit 130 } trap handler SIGINT while true; do true; done </code></pre> <p>When I start script1.sh from a terminal, and then use <kbd>Ctrl</kbd>+<kbd>C</kbd>...
4,255
1,109,986
2020-02-07 23:14:54
18,479,195
14
2013-08-28 03:59:12
1,162,501
2013-08-28 19:23:25
https://stackoverflow.com/q/18477785
https://stackoverflow.com/a/18479195
<p><strong>New answer:</strong></p> <p>This question is far more interesting than I originally suspected. The answer is essentially given here:</p> <p><a href="https://stackoverflow.com/questions/4717118/what-happens-to-a-sigint-c-when-sent-to-a-perl-script-containing-children">What happens to a SIGINT (^C) when sen...
<p><strong>New answer:</strong></p> <p>This question is far more interesting than I originally suspected. The answer is essentially given here:</p> <p><a href="https://stackoverflow.com/questions/4717118/what-happens-to-a-sigint-c-when-sent-to-a-perl-script-containing-children">What happens to a SIGINT (^C) when sen...
58, 387, 5910
bash, linux, process
<h1>Bash: Why does parent script not terminate on SIGINT when child script traps SIGINT?</h1> <p>script1.sh:</p> <pre><code> #!/bin/bash ./script2.sh echo after-script </code></pre> <p>script2.sh:</p> <pre><code>#!/bin/bash function handler { exit 130 } trap handler SIGINT while true; do true; done </code...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,601
bash
# Bash: Why does parent script not terminate on SIGINT when child script traps SIGINT? script1.sh: ``` #!/bin/bash ./script2.sh echo after-script ``` script2.sh: ``` #!/bin/bash function handler { exit 130 } trap handler SIGINT while true; do true; done ``` When I start script1.sh from a terminal, and ...
**New answer:** This question is far more interesting than I originally suspected. The answer is essentially given here: [What happens to a SIGINT (^C) when sent to a perl script containing children?](https://stackoverflow.com/questions/4717118/what-happens-to-a-sigint-c-when-sent-to-a-perl-script-containing-children...
14066992
What does minus mean in "exec 3>&-" and how do I use it?
15
2012-12-28 08:57:12
<p>I often have trouble figuring out certain language constructs because they won't register when googling or duckduckgoing them. With a bit of experimenting, it's often simple to figure it out, but I don't get this one.</p> <p>I often see stuff like <code>2&gt;&amp;1</code> or <code>3&gt;&amp;-</code> in bash scripts...
16,979
754,174
2012-12-28 09:16:32
14,067,174
14
2012-12-28 09:15:00
1,120,147
2012-12-28 09:15:00
https://stackoverflow.com/q/14066992
https://stackoverflow.com/a/14067174
<ol> <li><code>2&gt;&amp;1</code> means that stderr is redirected to stdout</li> <li><code>3&gt;&amp;-</code> means that file descriptor 3, opened for writing(same as stdout), is closed.</li> </ol> <p>You can see more examples of redirection <a href="http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide...
<ol> <li><code>2&gt;&amp;1</code> means that stderr is redirected to stdout</li> <li><code>3&gt;&amp;-</code> means that file descriptor 3, opened for writing(same as stdout), is closed.</li> </ol> <p>You can see more examples of redirection <a href="http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide...
387, 391, 4867, 10327, 31901
bash, http-redirect, sh, stdout, terminal
<h1>What does minus mean in "exec 3>&-" and how do I use it?</h1> <p>I often have trouble figuring out certain language constructs because they won't register when googling or duckduckgoing them. With a bit of experimenting, it's often simple to figure it out, but I don't get this one.</p> <p>I often see stuff like <c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,602
bash
# What does minus mean in "exec 3>&-" and how do I use it? I often have trouble figuring out certain language constructs because they won't register when googling or duckduckgoing them. With a bit of experimenting, it's often simple to figure it out, but I don't get this one. I often see stuff like `2>&1` or `3>&-` i...
1. `2>&1` means that stderr is redirected to stdout 2. `3>&-` means that file descriptor 3, opened for writing(same as stdout), is closed. You can see more examples of redirection [here](http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/x13082.html) 3. As for questions number 3, I think [this](http...
12922033
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
15
2012-10-16 19:24:21
<p>Occasionally I get this error when working on remote computers. It's hit or miss on which computer I get it on. But I am able to ping the computer and test-connection pans out. For example, the computer I got this error on today I was able to get to yesterday. I know the computer is on because It's right next me...
248,155
1,165,268
2022-04-05 23:43:33
12,923,953
14
2012-10-16 21:46:26
1,529,339
2012-10-25 23:11:33
https://stackoverflow.com/q/12922033
https://stackoverflow.com/a/12923953
<p>Check to see if the <code>Remote Procedure Call (RPC)</code> service is running. If it is, then it's a firewall issue between your workstation and the server. You can test it by temporary disabling the firewall and retrying the command. </p> <p>Edit after comment:</p> <p>Ok, it's a firewall issue. You'll have t...
<p>Check to see if the <code>Remote Procedure Call (RPC)</code> service is running. If it is, then it's a firewall issue between your workstation and the server. You can test it by temporary disabling the firewall and retrying the command. </p> <p>Edit after comment:</p> <p>Ok, it's a firewall issue. You'll have t...
526, 794
network-programming, powershell
<h1>The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)</h1> <p>Occasionally I get this error when working on remote computers. It's hit or miss on which computer I get it on. But I am able to ping the computer and test-connection pans out. For example, the computer I got this error on today I was ab...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,603
bash
# The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) Occasionally I get this error when working on remote computers. It's hit or miss on which computer I get it on. But I am able to ping the computer and test-connection pans out. For example, the computer I got this error on today I was able to get to...
Check to see if the `Remote Procedure Call (RPC)` service is running. If it is, then it's a firewall issue between your workstation and the server. You can test it by temporary disabling the firewall and retrying the command. Edit after comment: Ok, it's a firewall issue. You'll have to either limit the ports WMI/RPC...
8600958
Bash: Variable Expansion in Single Quote / Double Quote
15
2011-12-22 08:04:33
<p>I want to add a variable <code>${date}</code> in the following bash script:</p> <pre><code>ffmpeg -i in.flv -vf drawtext="fontfile=Sans.ttf:text='Today is ${date}':fontsize=6" out.flv </code></pre> <p>Obviously, <code>${date}</code> won't expand in single quote, <b>please also note that there is a double quote bey...
19,558
1,111,275
2012-03-15 00:20:50
8,600,980
14
2011-12-22 08:08:08
387,981
2011-12-22 08:08:08
https://stackoverflow.com/q/8600958
https://stackoverflow.com/a/8600980
<p><code>${date}</code> is expanded because it is between double quotes (the single quotes inside the double quotes are just characters)</p> <p>Test it with:</p> <pre><code>$ export date=SOMEVALUE $ echo ffmpeg -i in.flv -vf drawtext="fontfile=/usr/share/fonts/dejavu/DejaVuLGCSans.ttf:text='Today is ${date}':fontsize...
<p><code>${date}</code> is expanded because it is between double quotes (the single quotes inside the double quotes are just characters)</p> <p>Test it with:</p> <pre><code>$ export date=SOMEVALUE $ echo ffmpeg -i in.flv -vf drawtext="fontfile=/usr/share/fonts/dejavu/DejaVuLGCSans.ttf:text='Today is ${date}':fontsize...
58, 276, 367, 387, 3847
bash, ffmpeg, linux, syntax, variables
<h1>Bash: Variable Expansion in Single Quote / Double Quote</h1> <p>I want to add a variable <code>${date}</code> in the following bash script:</p> <pre><code>ffmpeg -i in.flv -vf drawtext="fontfile=Sans.ttf:text='Today is ${date}':fontsize=6" out.flv </code></pre> <p>Obviously, <code>${date}</code> won't expand in s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,604
bash
# Bash: Variable Expansion in Single Quote / Double Quote I want to add a variable `${date}` in the following bash script: ``` ffmpeg -i in.flv -vf drawtext="fontfile=Sans.ttf:text='Today is ${date}':fontsize=6" out.flv ``` Obviously, `${date}` won't expand in single quote, **please also note that there is a double ...
`${date}` is expanded because it is between double quotes (the single quotes inside the double quotes are just characters) Test it with: ``` $ export date=SOMEVALUE $ echo ffmpeg -i in.flv -vf drawtext="fontfile=/usr/share/fonts/dejavu/DejaVuLGCSans.ttf:text='Today is ${date}':fontsize=6" out.flv ffmpeg -i in.flv -vf...
8031073
How to check for no input in bash read?
15
2011-11-06 22:59:04
<p>I am looking for a conditional to avoid users from leaving an input value blank. Any suggestions?</p>
27,092
517,235
2022-12-29 12:30:23
8,031,091
14
2011-11-06 23:02:08
771,329
2011-11-06 23:02:08
https://stackoverflow.com/q/8031073
https://stackoverflow.com/a/8031091
<p>No inputs (or even spaces I believe) get entered as empty strings, so check input while the input var is empty:</p> <pre><code>input= while [[ $input = "" ]]; do read input done </code></pre>
<p>No inputs (or even spaces I believe) get entered as empty strings, so check input while the input var is empty:</p> <pre><code>input= while [[ $input = "" ]]; do read input done </code></pre>
387
bash
<h1>How to check for no input in bash read?</h1> <p>I am looking for a conditional to avoid users from leaving an input value blank. Any suggestions?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,605
bash
# How to check for no input in bash read? I am looking for a conditional to avoid users from leaving an input value blank. Any suggestions?
No inputs (or even spaces I believe) get entered as empty strings, so check input while the input var is empty: ``` input= while [[ $input = "" ]]; do read input done ```
3789894
Is command substitution $(foo) bashism?
15
2010-09-24 18:29:59
<p>There are two different syntaxes for command substitution,</p> <pre><code>FOO=$(echo bar) </code></pre> <p>and</p> <pre><code>FOO=`echo bar` </code></pre> <p>As far as I know, the first method is defined in Bash, while the second is defined in <code>sh</code>.</p> <p>Consider the following use of command substi...
3,942
360,899
2012-03-03 18:38:40
3,789,931
14
2010-09-24 18:36:02
422,597
2010-09-24 22:07:37
https://stackoverflow.com/q/3789894
https://stackoverflow.com/a/3789931
<p>It's the same thing. So no it's not a bashism nor related to bash only.</p> <blockquote> <p><strong>Command Substitution</strong><br> Command substitution allows the output of a command to be substituted in place of the command name itself. Command substitution occurs when the command is enclosed as follows:</p...
<p>It's the same thing. So no it's not a bashism nor related to bash only.</p> <blockquote> <p><strong>Command Substitution</strong><br> Command substitution allows the output of a command to be substituted in place of the command name itself. Command substitution occurs when the command is enclosed as follows:</p...
387, 1993, 10327
bash, posix, sh
<h1>Is command substitution $(foo) bashism?</h1> <p>There are two different syntaxes for command substitution,</p> <pre><code>FOO=$(echo bar) </code></pre> <p>and</p> <pre><code>FOO=`echo bar` </code></pre> <p>As far as I know, the first method is defined in Bash, while the second is defined in <code>sh</code>.</p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,606
bash
# Is command substitution $(foo) bashism? There are two different syntaxes for command substitution, ``` FOO=$(echo bar) ``` and ``` FOO=`echo bar` ``` As far as I know, the first method is defined in Bash, while the second is defined in `sh`. Consider the following use of command substitution in an `sh` script. ...
It's the same thing. So no it's not a bashism nor related to bash only. > **Command Substitution** > Command substitution allows the output of a command to be substituted in place of the command name itself. Command substitution occurs when the command is enclosed as follows: > > ``` > $(command) > ``` > > or ( ''ba...
3462075
Keep a file open forever within a bash script
15
2010-08-11 19:29:05
<p>I need a way to make a process keep a certain file open forever. Here's an example of what I have so far:</p> <p><code>sleep 1000 &gt; myfile &amp;</code></p> <p>It works for a thousand seconds, but really don't want to make some complicated sleep/loop statement. <a href="https://stackoverflow.com/questions/29351...
16,327
125,380
2021-12-14 10:58:40
3,462,138
14
2010-08-11 19:36:55
119,280
2010-08-11 19:36:55
https://stackoverflow.com/q/3462075
https://stackoverflow.com/a/3462138
<p>The reason that <code>cat&gt;myfile&amp;</code> works is because it re-directs standard input into a file. </p> <p>if you launch it with an ampersand (in background), it won't get ANY input, including end-of-file, which means it will forever wait and print nothing to the output file.</p> <p>You can get an equivale...
<p>The reason that <code>cat&gt;myfile&amp;</code> works is because it re-directs standard input into a file. </p> <p>if you launch it with an ampersand (in background), it won't get ANY input, including end-of-file, which means it will forever wait and print nothing to the output file.</p> <p>You can get an equivale...
387
bash
<h1>Keep a file open forever within a bash script</h1> <p>I need a way to make a process keep a certain file open forever. Here's an example of what I have so far:</p> <p><code>sleep 1000 &gt; myfile &amp;</code></p> <p>It works for a thousand seconds, but really don't want to make some complicated sleep/loop statem...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,607
bash
# Keep a file open forever within a bash script I need a way to make a process keep a certain file open forever. Here's an example of what I have so far: `sleep 1000 > myfile &` It works for a thousand seconds, but really don't want to make some complicated sleep/loop statement. [This post](https://stackoverflow.com...
The reason that `cat>myfile&` works is because it re-directs standard input into a file. if you launch it with an ampersand (in background), it won't get ANY input, including end-of-file, which means it will forever wait and print nothing to the output file. You can get an equivalent effect, except WITHOUT dependency...
3281999
Format-List: sort properties by name
15
2010-07-19 14:29:49
<p>Is it possible to sort the output of the Format-List cmdlet by property name?<br> Suppose that I have an object $x with two properties "A" and "B", and when I run Format-List with it I get</p> <pre><code>(PS) &gt; $x | Format-List B : value b A : value a </code></pre> <p>I would like to have</p> <pre><code>(PS) &...
30,252
15,622
2023-08-10 18:05:05
3,282,208
14
2010-07-19 14:57:49
323,582
2010-07-19 17:32:52
https://stackoverflow.com/q/3281999
https://stackoverflow.com/a/3282208
<p>AFAIK, <code>Format-List</code> does not provide such an option.</p> <p>For your particular example this should work:</p> <pre><code>$x | Select-Object A, B | Format-List </code></pre> <p>If the property set is not fixed/known then the procedure will be more tricky with use of <code>Get-Member</code> and some pre...
<p>AFAIK, <code>Format-List</code> does not provide such an option.</p> <p>For your particular example this should work:</p> <pre><code>$x | Select-Object A, B | Format-List </code></pre> <p>If the property set is not fixed/known then the procedure will be more tricky with use of <code>Get-Member</code> and some pre...
134, 526
powershell, sorting
<h1>Format-List: sort properties by name</h1> <p>Is it possible to sort the output of the Format-List cmdlet by property name?<br> Suppose that I have an object $x with two properties "A" and "B", and when I run Format-List with it I get</p> <pre><code>(PS) &gt; $x | Format-List B : value b A : value a </code></pre> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,608
bash
# Format-List: sort properties by name Is it possible to sort the output of the Format-List cmdlet by property name? Suppose that I have an object $x with two properties "A" and "B", and when I run Format-List with it I get ``` (PS) > $x | Format-List B : value b A : value a ``` I would like to have ``` (PS) > $x...
AFAIK, `Format-List` does not provide such an option. For your particular example this should work: ``` $x | Select-Object A, B | Format-List ``` If the property set is not fixed/known then the procedure will be more tricky with use of `Get-Member` and some preprocessing making sorted parameter array for `Select-Obj...
63432023
Running powershell script inside a bash script
14
2020-08-16 00:30:39
<p>In Powershell-<br/> How do I run a powershell script(.ps1) inside a bash script(.sh)<br/> I can run just the powershell script-<br/> &amp; .\scriptfile.ps1 <br/> and just the bash script.<br/> But when I try to run the powershell inside the bash script, I get <br/> file.ps1 : command not found<br/> Both scripts are ...
50,647
2,296,291
2024-04-17 15:00:42
63,432,492
14
2020-08-16 02:12:14
607,470
2020-08-16 04:05:21
https://stackoverflow.com/q/63432023
https://stackoverflow.com/a/63432492
<p>Are you trying</p> <pre><code>.\scriptfile.ps1 </code></pre> <p>? That should be</p> <pre><code>./scriptfile.ps1 </code></pre> <p>But also, when invoking powershell from a bash script, you'll need to either run the pwsh command like</p> <pre><code>pwsh ./scriptfile.ps1 </code></pre> <p>or the first line of your Powe...
<p>Are you trying</p> <pre><code>.\scriptfile.ps1 </code></pre> <p>? That should be</p> <pre><code>./scriptfile.ps1 </code></pre> <p>But also, when invoking powershell from a bash script, you'll need to either run the pwsh command like</p> <pre><code>pwsh ./scriptfile.ps1 </code></pre> <p>or the first line of your Powe...
387, 526
bash, powershell
<h1>Running powershell script inside a bash script</h1> <p>In Powershell-<br/> How do I run a powershell script(.ps1) inside a bash script(.sh)<br/> I can run just the powershell script-<br/> &amp; .\scriptfile.ps1 <br/> and just the bash script.<br/> But when I try to run the powershell inside the bash script, I get <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,609
bash
# Running powershell script inside a bash script In Powershell- How do I run a powershell script(.ps1) inside a bash script(.sh) I can run just the powershell script- & .\scriptfile.ps1 and just the bash script. But when I try to run the powershell inside the bash script, I get file.ps1 : command not fou...
Are you trying ``` .\scriptfile.ps1 ``` ? That should be ``` ./scriptfile.ps1 ``` But also, when invoking powershell from a bash script, you'll need to either run the pwsh command like ``` pwsh ./scriptfile.ps1 ``` or the first line of your Powershell script file should be a shebang (interpreter directive) like: ...
48537171
Packer can't execute shell provisioner as sudo
14
2018-01-31 07:55:47
<p>I have a <code>shell provisioner</code> in packer connected to a box with user <code>vagrant</code></p> <pre class="lang-json prettyprint-override"><code>{ "environment_vars": [ "HOME_DIR=/home/vagrant" ], "expect_disconnect": true, "scripts": [ "scripts/foo.sh" ], "type": "shell" } </code></pre...
31,365
2,587,904
2020-09-19 07:11:38
48,540,659
14
2018-01-31 11:06:59
226,174
2018-01-31 11:06:59
https://stackoverflow.com/q/48537171
https://stackoverflow.com/a/48540659
<p>You should override the <a href="https://www.packer.io/docs/provisioners/shell.html#execute_command" rel="noreferrer">execute_command</a>. Example:</p> <pre><code> "provisioners": [ { "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'", "scripts": [ "scripts/foo.s...
<p>You should override the <a href="https://www.packer.io/docs/provisioners/shell.html#execute_command" rel="noreferrer">execute_command</a>. Example:</p> <pre><code> "provisioners": [ { "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'", "scripts": [ "scripts/foo.s...
390, 8814, 12079, 24433
packer, provisioning, root, shell
<h1>Packer can't execute shell provisioner as sudo</h1> <p>I have a <code>shell provisioner</code> in packer connected to a box with user <code>vagrant</code></p> <pre class="lang-json prettyprint-override"><code>{ "environment_vars": [ "HOME_DIR=/home/vagrant" ], "expect_disconnect": true, "scripts": [ ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,610
bash
# Packer can't execute shell provisioner as sudo I have a `shell provisioner` in packer connected to a box with user `vagrant` ``` { "environment_vars": [ "HOME_DIR=/home/vagrant" ], "expect_disconnect": true, "scripts": [ "scripts/foo.sh" ], "type": "shell" } ``` where the content of the script ...
You should override the [execute_command](https://www.packer.io/docs/provisioners/shell.html#execute_command). Example: ``` "provisioners": [ { "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'", "scripts": [ "scripts/foo.sh" ], "type": "shell" } ...
45118089
Git - Rename multiple branches
14
2017-07-15 12:15:32
<p>Here we have a git repo which has multiple branches which start with the same prefix just like this: </p> <pre><code>pfx.branchName1 pfx.branchName2 pfx.branchName3 ... </code></pre> <p>So the question is how to quickly remove all the prefixes ("pfx.") from all the branches and get something like this: </p...
3,848
5,935,112
2021-05-26 12:29:46
45,118,832
14
2017-07-15 13:38:02
5,935,112
2021-05-26 12:29:46
https://stackoverflow.com/q/45118089
https://stackoverflow.com/a/45118832
<p>Found an universal command that searches for the branches which contain our desired string (e.g. <code>&quot;StringToFind&quot;</code>) and renames by replacing that part with the string we want (e.g. <code>&quot;ReplaceWith&quot;</code>):</p> <pre><code>git branch | grep &quot;StringToFind&quot; | awk '{original=$1...
<p>Found an universal command that searches for the branches which contain our desired string (e.g. <code>&quot;StringToFind&quot;</code>) and renames by replacing that part with the string we want (e.g. <code>&quot;ReplaceWith&quot;</code>):</p> <pre><code>git branch | grep &quot;StringToFind&quot; | awk '{original=$1...
119, 387
bash, git
<h1>Git - Rename multiple branches</h1> <p>Here we have a git repo which has multiple branches which start with the same prefix just like this: </p> <pre><code>pfx.branchName1 pfx.branchName2 pfx.branchName3 ... </code></pre> <p>So the question is how to quickly remove all the prefixes ("pfx.") from all the br...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,611
bash
# Git - Rename multiple branches Here we have a git repo which has multiple branches which start with the same prefix just like this: ``` pfx.branchName1 pfx.branchName2 pfx.branchName3 ... ``` So the question is how to quickly remove all the prefixes ("pfx.") from all the branches and get something like this:...
Found an universal command that searches for the branches which contain our desired string (e.g. `"StringToFind"`) and renames by replacing that part with the string we want (e.g. `"ReplaceWith"`): ``` git branch | grep "StringToFind" | awk '{original=$1; sub("StringToFind","ReplaceWith"); print original, $1}' | xargs...
40010820
Loop over files in HDFS directory
14
2016-10-13 01:22:13
<p>I need to loop over all csv files in a Hadoop file system. I can list all of the files in a HDFS directory with</p> <pre><code>&gt; hadoop fs -ls /path/to/directory Found 2 items drwxr-xr-x - hadoop hadoop 2 2016-10-12 16:20 /path/to/directory/tmp -rwxr-xr-x 3 hadoop hadoop 4691945927 2016-10-12 19:37 ...
17,456
3,891,715
2021-08-16 18:02:10
40,011,087
14
2016-10-13 02:00:55
6,928,591
2016-10-13 02:00:55
https://stackoverflow.com/q/40010820
https://stackoverflow.com/a/40011087
<p>This should work</p> <pre><code>for filename in `hadoop fs -ls /path/to/directory | awk '{print $NF}' | grep .csv$ | tr '\n' ' '` do echo $filename; done </code></pre>
<p>This should work</p> <pre><code>for filename in `hadoop fs -ls /path/to/directory | awk '{print $NF}' | grep .csv$ | tr '\n' ' '` do echo $filename; done </code></pre>
387, 1995, 40255
bash, hadoop, hdfs
<h1>Loop over files in HDFS directory</h1> <p>I need to loop over all csv files in a Hadoop file system. I can list all of the files in a HDFS directory with</p> <pre><code>&gt; hadoop fs -ls /path/to/directory Found 2 items drwxr-xr-x - hadoop hadoop 2 2016-10-12 16:20 /path/to/directory/tmp -rwxr-xr-x 3...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,612
bash
# Loop over files in HDFS directory I need to loop over all csv files in a Hadoop file system. I can list all of the files in a HDFS directory with ``` > hadoop fs -ls /path/to/directory Found 2 items drwxr-xr-x - hadoop hadoop 2 2016-10-12 16:20 /path/to/directory/tmp -rwxr-xr-x 3 hadoop hadoop 46919459...
This should work ``` for filename in `hadoop fs -ls /path/to/directory | awk '{print $NF}' | grep .csv$ | tr '\n' ' '` do echo $filename; done ```
37141039
Is there any difference between $@ and "$@"?
14
2016-05-10 14:11:38
<p>Is there any difference between <code>$@</code> and <code>"$@"</code>? </p> <p>I understand there may be differences for non special characters, but what about the <code>@</code> sign with input arguments?</p>
8,702
2,098,831
2016-05-10 14:40:44
37,141,139
14
2016-05-10 14:15:59
1,983,854
2016-05-10 14:37:14
https://stackoverflow.com/q/37141039
https://stackoverflow.com/a/37141139
<p>Yes!</p> <pre><code>$ cat a.sh echo "$@" echo $@ </code></pre> <p>Let's run it:</p> <pre><code>$ ./a.sh 2 "3 4" 5 2 3 4 5 # output for "$@" 2 3 4 5 # output for $@ -&gt; spaces are lost! </code></pre> <p>As you can see, using <code>$@</code> makes the parameters to ...
<p>Yes!</p> <pre><code>$ cat a.sh echo "$@" echo $@ </code></pre> <p>Let's run it:</p> <pre><code>$ ./a.sh 2 "3 4" 5 2 3 4 5 # output for "$@" 2 3 4 5 # output for $@ -&gt; spaces are lost! </code></pre> <p>As you can see, using <code>$@</code> makes the parameters to ...
387, 19863
bash, expansion
<h1>Is there any difference between $@ and "$@"?</h1> <p>Is there any difference between <code>$@</code> and <code>"$@"</code>? </p> <p>I understand there may be differences for non special characters, but what about the <code>@</code> sign with input arguments?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,613
bash
# Is there any difference between $@ and "$@"? Is there any difference between `$@` and `"$@"`? I understand there may be differences for non special characters, but what about the `@` sign with input arguments?
Yes! ``` $ cat a.sh echo "$@" echo $@ ``` Let's run it: ``` $ ./a.sh 2 "3 4" 5 2 3 4 5 # output for "$@" 2 3 4 5 # output for $@ -> spaces are lost! ``` As you can see, using `$@` makes the parameters to "lose" some content when used as a parameter. See -for example- [...
32841846
Get the return code of a C program in my shell program
14
2015-09-29 10:42:27
<p>Suppose I have a C program named <code>Foo.c</code> which is printing few things and returning a value named <code>rc</code> which I am executing in my shell program as follows :</p> <p><code>foobar=$(Foo | tail -1)</code></p> <p>Now, the variable foobar has the last printed value of the program <code>Foo</code>. ...
9,686
2,874,172
2015-09-30 07:07:18
32,843,127
14
2015-09-29 11:46:14
1,205,132
2015-09-29 11:46:14
https://stackoverflow.com/q/32841846
https://stackoverflow.com/a/32843127
<p>You can use "set -o pipefail" option.</p> <pre><code>[root@myserver Test]# set -o pipefail [root@myserver Test]# ./a.out | tail -l [root@myserver Test]# echo $? 100 </code></pre> <p>Here my program a.out returns 100. </p> <p>Or another options is to use pipestatus environment variable. You can read about it here....
<p>You can use "set -o pipefail" option.</p> <pre><code>[root@myserver Test]# set -o pipefail [root@myserver Test]# ./a.out | tail -l [root@myserver Test]# echo $? 100 </code></pre> <p>Here my program a.out returns 100. </p> <p>Or another options is to use pipestatus environment variable. You can read about it here....
8, 387, 390
bash, c, shell
<h1>Get the return code of a C program in my shell program</h1> <p>Suppose I have a C program named <code>Foo.c</code> which is printing few things and returning a value named <code>rc</code> which I am executing in my shell program as follows :</p> <p><code>foobar=$(Foo | tail -1)</code></p> <p>Now, the variable foo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,614
bash
# Get the return code of a C program in my shell program Suppose I have a C program named `Foo.c` which is printing few things and returning a value named `rc` which I am executing in my shell program as follows : `foobar=$(Foo | tail -1)` Now, the variable foobar has the last printed value of the program `Foo`. But...
You can use "set -o pipefail" option. ``` [root@myserver Test]# set -o pipefail [root@myserver Test]# ./a.out | tail -l [root@myserver Test]# echo $? 100 ``` Here my program a.out returns 100. Or another options is to use pipestatus environment variable. You can read about it here. <http://www.linuxnix.com/2011/03/p...
31547104
How to get the value of the PATH environment variable without expanding tokens?
14
2015-07-21 18:40:36
<p>I'm writing a PowerShell script to convert folder names to short names in the PATH environment variable and save the changes. It works correctly for explicit paths, but it expands tokens, so when I save my changes the tokens are replaced with explicit paths. I'd like to preserve the tokens.</p> <p>For example, if...
4,461
4,154
2018-10-24 21:17:31
31,548,093
14
2015-07-21 19:36:35
517,852
2015-07-21 21:54:46
https://stackoverflow.com/q/31547104
https://stackoverflow.com/a/31548093
<p>This isn't PowerShell per se, but a "feature" of the underlying Windows registry. The Path variable is of type REG_EXPAND_SZ which automatically expands environment variables on retrieval. I don't think you can get around it with the built-in cmdlets, but you can with the .NET <code>Microsoft.Win32.Registry</code> A...
<p>This isn't PowerShell per se, but a "feature" of the underlying Windows registry. The Path variable is of type REG_EXPAND_SZ which automatically expands environment variables on retrieval. I don't think you can get around it with the built-in cmdlets, but you can with the .NET <code>Microsoft.Win32.Registry</code> A...
526, 9013
environment-variables, powershell
<h1>How to get the value of the PATH environment variable without expanding tokens?</h1> <p>I'm writing a PowerShell script to convert folder names to short names in the PATH environment variable and save the changes. It works correctly for explicit paths, but it expands tokens, so when I save my changes the tokens ar...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,615
bash
# How to get the value of the PATH environment variable without expanding tokens? I'm writing a PowerShell script to convert folder names to short names in the PATH environment variable and save the changes. It works correctly for explicit paths, but it expands tokens, so when I save my changes the tokens are replaced...
This isn't PowerShell per se, but a "feature" of the underlying Windows registry. The Path variable is of type REG_EXPAND_SZ which automatically expands environment variables on retrieval. I don't think you can get around it with the built-in cmdlets, but you can with the .NET `Microsoft.Win32.Registry` APIs. Use the `...
24134530
how to exclude multiple pattern using grep
14
2014-06-10 06:44:07
<p>I want to exclude both <code>"*log*"</code> and <code>./tags</code> from grep. </p> <p>What i do is:</p> <pre><code>grep -rI "PatternToSearch" ./path --exclude="*log*" </code></pre> <p>or this:</p> <pre><code>grep -rI "PatternToSearch" ./path --exclude="tags" </code></pre> <p>is it possible to merge both exclu...
18,792
2,657,927
2025-01-22 19:19:52
24,155,448
14
2014-06-11 05:47:22
2,789,948
2014-06-11 05:47:22
https://stackoverflow.com/q/24134530
https://stackoverflow.com/a/24155448
<p>Try below:</p> <pre><code> grep -rI "PatternToSearch" ./path --exclude={*log*,tags} </code></pre> <p>Just use "," to separate patterns.</p> <p>Seems duplicated with <a href="https://stackoverflow.com/questions/10619160/how-do-i-use-the-grep-include-option-for-multiple-file-types">how do I use the grep --include o...
<p>Try below:</p> <pre><code> grep -rI "PatternToSearch" ./path --exclude={*log*,tags} </code></pre> <p>Just use "," to separate patterns.</p> <p>Seems duplicated with <a href="https://stackoverflow.com/questions/10619160/how-do-i-use-the-grep-include-option-for-multiple-file-types">how do I use the grep --include o...
58, 390, 1271, 1796
command, grep, linux, shell
<h1>how to exclude multiple pattern using grep</h1> <p>I want to exclude both <code>"*log*"</code> and <code>./tags</code> from grep. </p> <p>What i do is:</p> <pre><code>grep -rI "PatternToSearch" ./path --exclude="*log*" </code></pre> <p>or this:</p> <pre><code>grep -rI "PatternToSearch" ./path --exclude="tags" ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,616
bash
# how to exclude multiple pattern using grep I want to exclude both `"*log*"` and `./tags` from grep. What i do is: ``` grep -rI "PatternToSearch" ./path --exclude="*log*" ``` or this: ``` grep -rI "PatternToSearch" ./path --exclude="tags" ``` is it possible to merge both exclude patterns in one grep?
Try below: ``` grep -rI "PatternToSearch" ./path --exclude={*log*,tags} ``` Just use "," to separate patterns. Seems duplicated with [how do I use the grep --include option for multiple file types?](https://stackoverflow.com/questions/10619160/how-do-i-use-the-grep-include-option-for-multiple-file-types)
16318211
More succinct way of getting a registry value as a string than (Get-ItemProperty $key $valueName)._VALUENAME_?
14
2013-05-01 12:37:45
<p>The method for getting a value in a registry key from PowerShell is:</p> <pre><code>Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion CommonFilesDir </code></pre> <p>However, that command returns some extra properties I don't usually want:</p> <pre><code>CommonFilesDir : C:\Program Files\Common Fil...
21,611
95,195
2019-01-29 21:15:20
18,806,379
14
2013-09-14 21:04:59
1,913,219
2013-09-14 21:04:59
https://stackoverflow.com/q/16318211
https://stackoverflow.com/a/18806379
<p>I'm new to PowerShell, but it seems to work in PowerShell 2 and 3 if you leave out the registry value name in Get-ItemProperty, using the value name only as a property:</p> <pre><code>(Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion).CommonFilesDir </code></pre> <p>or even shorter with the alias:<...
<p>I'm new to PowerShell, but it seems to work in PowerShell 2 and 3 if you leave out the registry value name in Get-ItemProperty, using the value name only as a property:</p> <pre><code>(Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion).CommonFilesDir </code></pre> <p>or even shorter with the alias:<...
263, 526
powershell, registry
<h1>More succinct way of getting a registry value as a string than (Get-ItemProperty $key $valueName)._VALUENAME_?</h1> <p>The method for getting a value in a registry key from PowerShell is:</p> <pre><code>Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion CommonFilesDir </code></pre> <p>However, that ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,617
bash
# More succinct way of getting a registry value as a string than (Get-ItemProperty $key $valueName)._VALUENAME_? The method for getting a value in a registry key from PowerShell is: ``` Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion CommonFilesDir ``` However, that command returns some extra proper...
I'm new to PowerShell, but it seems to work in PowerShell 2 and 3 if you leave out the registry value name in Get-ItemProperty, using the value name only as a property: ``` (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion).CommonFilesDir ``` or even shorter with the alias: ``` (gp HKLM:\SOFTWARE\Mic...
18508628
How to install a windows service from command line specifying name and description?
14
2013-08-29 10:35:44
<p>I created a Windows service with Delphi for a client server application.</p> <p>To install it I use</p> <pre><code>c:\Test\MyService.exe /install (or /uninstall) </code></pre> <p>This installs the service and in Windows services it lists with "MyService" name and empty description.</p> <p>How to define a differe...
38,764
193,655
2014-09-10 21:33:48
18,508,828
14
2013-08-29 10:44:58
505,088
2013-08-29 10:50:35
https://stackoverflow.com/q/18508628
https://stackoverflow.com/a/18508828
<p>Windows already ships with the utility that you need, namely <code>sc create</code>.</p> <pre> >sc create /? DESCRIPTION: Creates a service entry in the registry and Service Database. USAGE: sc create [service name] [binPath= ] ... OPTIONS: NOTE: The option name includes the equal sign. A s...
<p>Windows already ships with the utility that you need, namely <code>sc create</code>.</p> <pre> >sc create /? DESCRIPTION: Creates a service entry in the registry and Service Database. USAGE: sc create [service name] [binPath= ] ... OPTIONS: NOTE: The option name includes the equal sign. A s...
2596, 7839
shellexecute, windows-services
<h1>How to install a windows service from command line specifying name and description?</h1> <p>I created a Windows service with Delphi for a client server application.</p> <p>To install it I use</p> <pre><code>c:\Test\MyService.exe /install (or /uninstall) </code></pre> <p>This installs the service and in Windows s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,618
bash
# How to install a windows service from command line specifying name and description? I created a Windows service with Delphi for a client server application. To install it I use ``` c:\Test\MyService.exe /install (or /uninstall) ``` This installs the service and in Windows services it lists with "MyService" name a...
Windows already ships with the utility that you need, namely `sc create`. ``` >sc create /? DESCRIPTION: Creates a service entry in the registry and Service Database. USAGE: sc create [service name] [binPath= ] ... OPTIONS: NOTE: The option name includes the equal sign. A space is required bet...
13359276
echo to stderr and tee to log file?
14
2012-11-13 10:41:51
<p>In bash script,</p> <blockquote> <p>echo "error" 1>&amp;2 | tee -a log</p> </blockquote> <p>will print stderr in screen but no log to file, how to do these at same time?</p>
15,311
735,035
2012-11-13 13:18:39
13,361,416
14
2012-11-13 13:18:39
1,057,909
2012-11-13 13:18:39
https://stackoverflow.com/q/13359276
https://stackoverflow.com/a/13361416
<p>To echo the text to both the log file and stderr, <em>but not stdout</em>, try this:</p> <pre><code>echo "error" | tee -a log 1&gt;&amp;2 </code></pre>
<p>To echo the text to both the log file and stderr, <em>but not stdout</em>, try this:</p> <pre><code>echo "error" | tee -a log 1&gt;&amp;2 </code></pre>
387
bash
<h1>echo to stderr and tee to log file?</h1> <p>In bash script,</p> <blockquote> <p>echo "error" 1>&amp;2 | tee -a log</p> </blockquote> <p>will print stderr in screen but no log to file, how to do these at same time?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,619
bash
# echo to stderr and tee to log file? In bash script, > echo "error" 1>&2 | tee -a log will print stderr in screen but no log to file, how to do these at same time?
To echo the text to both the log file and stderr, *but not stdout*, try this: ``` echo "error" | tee -a log 1>&2 ```
6686576
Easiest way to produce guitar chords in linux and/or python
14
2011-07-13 22:44:24
<p>What i'm trying to achieve is playing a guitar chord from my python application. I know (or can calculate) the frequencies in the chord if needed.</p> <p>I'm thinking that even if I do the low level leg work of producing multiple sine waves at the right frequencies it wont sound right due to the envelope needing to...
5,445
384,388
2012-06-14 12:48:39
11,033,287
14
2012-06-14 12:43:12
1,456,232
2012-06-14 12:43:12
https://stackoverflow.com/q/6686576
https://stackoverflow.com/a/11033287
<p>The manual gives this example:</p> <pre><code>play -n synth pl G2 pl B2 pl D3 pl G3 pl D4 pl G4 \ delay 0 .05 .1 .15 .2 .25 remix - fade 0 4 .1 norm -1 </code></pre> <p>This creates 6 simultaneous instances of synth (as separate audio channels), delays 5 of the channels by slightly increasing times,...
<p>The manual gives this example:</p> <pre><code>play -n synth pl G2 pl B2 pl D3 pl G3 pl D4 pl G4 \ delay 0 .05 .1 .15 .2 .25 remix - fade 0 4 .1 norm -1 </code></pre> <p>This creates 6 simultaneous instances of synth (as separate audio channels), delays 5 of the channels by slightly increasing times,...
16, 58, 348, 387, 59202
audio, bash, guitar, linux, python
<h1>Easiest way to produce guitar chords in linux and/or python</h1> <p>What i'm trying to achieve is playing a guitar chord from my python application. I know (or can calculate) the frequencies in the chord if needed.</p> <p>I'm thinking that even if I do the low level leg work of producing multiple sine waves at the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,620
bash
# Easiest way to produce guitar chords in linux and/or python What i'm trying to achieve is playing a guitar chord from my python application. I know (or can calculate) the frequencies in the chord if needed. I'm thinking that even if I do the low level leg work of producing multiple sine waves at the right frequenci...
The manual gives this example: ``` play -n synth pl G2 pl B2 pl D3 pl G3 pl D4 pl G4 \ delay 0 .05 .1 .15 .2 .25 remix - fade 0 4 .1 norm -1 ``` This creates 6 simultaneous instances of synth (as separate audio channels), delays 5 of the channels by slightly increasing times, then mixes them down to a ...
9506584
convert scientific notation bash script
14
2012-02-29 21:04:51
<p>I have a awk script that grabs numbers that I want. But the problem is they are in this kind of format: 1.8200E+02 </p> <p>In bash script this decimal notation is not supported so I was wonering anyone can help me with this problem.</p>
10,650
1,174,490
2017-08-02 15:18:53
9,506,733
14
2012-02-29 21:14:53
526,956
2012-02-29 21:28:18
https://stackoverflow.com/q/9506584
https://stackoverflow.com/a/9506733
<p>My last answer was wrong, sorry about that. You can use printf for this:</p> <pre><code>printf '%.0f' 1.8200E+02 182 </code></pre>
<p>My last answer was wrong, sorry about that. You can use printf for this:</p> <pre><code>printf '%.0f' 1.8200E+02 182 </code></pre>
387, 6250
bash, decimal
<h1>convert scientific notation bash script</h1> <p>I have a awk script that grabs numbers that I want. But the problem is they are in this kind of format: 1.8200E+02 </p> <p>In bash script this decimal notation is not supported so I was wonering anyone can help me with this problem.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,621
bash
# convert scientific notation bash script I have a awk script that grabs numbers that I want. But the problem is they are in this kind of format: 1.8200E+02 In bash script this decimal notation is not supported so I was wonering anyone can help me with this problem.
My last answer was wrong, sorry about that. You can use printf for this: ``` printf '%.0f' 1.8200E+02 182 ```
5546223
Signals received by bash when terminal is closed
14
2011-04-05 01:35:52
<p>Use trap to capture signals like this:</p> <pre><code>i=-1;while((++i&lt;33)); do trap "echo $i &gt;&gt; log.txt" $i; done </code></pre> <p>And close the terminal by force.</p> <p>The content in log.txt is then (under redhat linux):</p> <blockquote> <p>1</p> <p>18</p> <p>1</p> <p>17</p> ...
10,619
689,486
2011-04-06 13:41:57
5,547,386
14
2011-04-05 04:59:02
15,168
2011-04-05 08:05:54
https://stackoverflow.com/q/5546223
https://stackoverflow.com/a/5547386
<p>The first signal is SIGHUP; that gets sent to all processes in the process group when the terminal disconnects (hangs up - hence HUP).</p> <p>The second signal is SIGCONT (thanks, SiegeX, for the numbers). This is slightly surprising; it suggests you had a job stopped in the background which had to be allowed to r...
<p>The first signal is SIGHUP; that gets sent to all processes in the process group when the terminal disconnects (hangs up - hence HUP).</p> <p>The second signal is SIGCONT (thanks, SiegeX, for the numbers). This is slightly surprising; it suggests you had a job stopped in the background which had to be allowed to r...
387, 391, 2481
bash, signals, terminal
<h1>Signals received by bash when terminal is closed</h1> <p>Use trap to capture signals like this:</p> <pre><code>i=-1;while((++i&lt;33)); do trap "echo $i &gt;&gt; log.txt" $i; done </code></pre> <p>And close the terminal by force.</p> <p>The content in log.txt is then (under redhat linux):</p> <blockquote> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,622
bash
# Signals received by bash when terminal is closed Use trap to capture signals like this: ``` i=-1;while((++i<33)); do trap "echo $i >> log.txt" $i; done ``` And close the terminal by force. The content in log.txt is then (under redhat linux): > 1 > > 18 > > 1 > > 17 > > 0 Where these signals from?
The first signal is SIGHUP; that gets sent to all processes in the process group when the terminal disconnects (hangs up - hence HUP). The second signal is SIGCONT (thanks, SiegeX, for the numbers). This is slightly surprising; it suggests you had a job stopped in the background which had to be allowed to run again. ...
3086781
Bash's equivalent of Tcsh's ESC-p to jump to command starting with what you typed so far
14
2010-06-21 17:09:32
<p>I recently made the insanely long overdue switch from tcsh to bash. The only thing I miss is tcsh's <kbd>ESC</kbd>+<kbd>p</kbd> feature: Start typing a command and then hit <kbd>ESC</kbd>+<kbd>p</kbd> (I actually found the equivalent ctrl-[p easier to type) and it jumps to the most recent command in your history tha...
15,290
4,234
2017-08-11 09:20:11
3,086,977
14
2010-06-21 17:36:25
26,428
2011-10-28 11:13:31
https://stackoverflow.com/q/3086781
https://stackoverflow.com/a/3086977
<p>Add this to your <code>~/.inputrc</code> file:</p> <pre><code>"\e[5~": history-search-backward "\e[6~": history-search-forward </code></pre> <p>This will make <kbd>PageUp</kbd> act like tcsh's <kbd>Esc</kbd>+<kbd>p</kbd> and <kbd>PageDown</kbd> will go forward through the list.</p> <p>You can bind <code>\ep</code...
<p>Add this to your <code>~/.inputrc</code> file:</p> <pre><code>"\e[5~": history-search-backward "\e[6~": history-search-forward </code></pre> <p>This will make <kbd>PageUp</kbd> act like tcsh's <kbd>Esc</kbd>+<kbd>p</kbd> and <kbd>PageDown</kbd> will go forward through the list.</p> <p>You can bind <code>\ep</code...
387, 390, 4198, 8599
bash, keyboard-shortcuts, shell, tcsh
<h1>Bash's equivalent of Tcsh's ESC-p to jump to command starting with what you typed so far</h1> <p>I recently made the insanely long overdue switch from tcsh to bash. The only thing I miss is tcsh's <kbd>ESC</kbd>+<kbd>p</kbd> feature: Start typing a command and then hit <kbd>ESC</kbd>+<kbd>p</kbd> (I actually found ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,623
bash
# Bash's equivalent of Tcsh's ESC-p to jump to command starting with what you typed so far I recently made the insanely long overdue switch from tcsh to bash. The only thing I miss is tcsh's `ESC`+`p` feature: Start typing a command and then hit `ESC`+`p` (I actually found the equivalent ctrl-[p easier to type) and it...
Add this to your `~/.inputrc` file: ``` "\e[5~": history-search-backward "\e[6~": history-search-forward ``` This will make `PageUp` act like tcsh's `Esc`+`p` and `PageDown` will go forward through the list. You can bind `\ep` instead. If you use `PageUp` / `PageDown`, you may need to see what character sequence you...
2501056
Can't get expand_aliases to take effect
14
2010-03-23 15:17:28
<p>I can't get expand_aliases to take effect in bash. I've tried a lot of different things, and nothing works.</p> <p>Here's the simple test case:</p> <pre><code>/bin/bash -c 'shopt -s expand_aliases; alias cdtmp="cd /tmp"; alias; cdtmp; pwd;' </code></pre> <p>And the output:</p> <pre><code>$ /bin/bash -c 'shopt -...
7,728
300,028
2020-12-23 08:58:51
2,502,451
14
2010-03-23 18:11:50
26,428
2015-09-23 20:02:23
https://stackoverflow.com/q/2501056
https://stackoverflow.com/a/2502451
<p>Aliases aren't available on the same line or in the same function where they are defined.</p> <p>From the Bash man page:</p> <pre> The rules concerning the definition and use of aliases are somewhat confusing. Bash always reads at least one complete line of input before executing an...
<p>Aliases aren't available on the same line or in the same function where they are defined.</p> <p>From the Bash man page:</p> <pre> The rules concerning the definition and use of aliases are somewhat confusing. Bash always reads at least one complete line of input before executing an...
387, 1448, 135295
alias, bash, shopt
<h1>Can't get expand_aliases to take effect</h1> <p>I can't get expand_aliases to take effect in bash. I've tried a lot of different things, and nothing works.</p> <p>Here's the simple test case:</p> <pre><code>/bin/bash -c 'shopt -s expand_aliases; alias cdtmp="cd /tmp"; alias; cdtmp; pwd;' </code></pre> <p>And th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,624
bash
# Can't get expand_aliases to take effect I can't get expand_aliases to take effect in bash. I've tried a lot of different things, and nothing works. Here's the simple test case: ``` /bin/bash -c 'shopt -s expand_aliases; alias cdtmp="cd /tmp"; alias; cdtmp; pwd;' ``` And the output: ``` $ /bin/bash -c 'shopt -s e...
Aliases aren't available on the same line or in the same function where they are defined. From the Bash man page: ``` The rules concerning the definition and use of aliases are somewhat confusing. Bash always reads at least one complete line of input before executing any of the comm...
2278876
Powershell scripting: recommended way to implement ShouldProcess when function calls are nested?
14
2010-02-17 07:01:31
<p>Test script:</p> <pre><code>function outer { [cmdletbinding(supportsshouldprocess=$true)] param($s) process { $pscmdlet.shouldprocess("outer $s", "ShouldProcess") | out-null "" | out-file "outer $s" inner ImplicitPassthru inner VerbosePassthru -Verbose:$Verb...
8,568
74,439
2017-01-21 23:45:18
2,314,145
14
2010-02-22 21:00:15
153,982
2010-02-23 01:59:30
https://stackoverflow.com/q/2278876
https://stackoverflow.com/a/2314145
<p>You can't really refer to $WhatIf or $Verbose since these are synthesized for you i.e. these variables don't exist in your function. If the user specifies them then you can get at them via $PSBoundParameters but if the user didn't specify then obviously they won't be in this hashtable. </p> <p>When you pass a val...
<p>You can't really refer to $WhatIf or $Verbose since these are synthesized for you i.e. these variables don't exist in your function. If the user specifies them then you can get at them via $PSBoundParameters but if the user didn't specify then obviously they won't be in this hashtable. </p> <p>When you pass a val...
379, 526, 2433, 153947
design-patterns, error-handling, powershell, powershell-cmdlet
<h1>Powershell scripting: recommended way to implement ShouldProcess when function calls are nested?</h1> <p>Test script:</p> <pre><code>function outer { [cmdletbinding(supportsshouldprocess=$true)] param($s) process { $pscmdlet.shouldprocess("outer $s", "ShouldProcess") | out-null ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,625
bash
# Powershell scripting: recommended way to implement ShouldProcess when function calls are nested? Test script: ``` function outer { [cmdletbinding(supportsshouldprocess=$true)] param($s) process { $pscmdlet.shouldprocess("outer $s", "ShouldProcess") | out-null "" | out-file "...
You can't really refer to $WhatIf or $Verbose since these are synthesized for you i.e. these variables don't exist in your function. If the user specifies them then you can get at them via $PSBoundParameters but if the user didn't specify then obviously they won't be in this hashtable. When you pass a value to a switc...
67275008
In Git-Bash-Windows `openssl pkcs12` does not prompt for password
13
2021-04-26 23:29:06
<p>The SSL certificate authority sent me the signed certificate in <code>.pfx</code> format and it was password-protected; so I need to convert it to <code>.crt</code> file.</p> <p>The first attempt was to call <code>openssl pkcs12 -in server.pfx -out server.crt -nokeys -clcerts</code>, simply in Git-Bash Windows; but ...
22,917
7,903,749
2022-11-06 14:26:25
67,278,566
14
2021-04-27 07:19:42
6,309
2021-04-27 07:19:42
https://stackoverflow.com/q/67275008
https://stackoverflow.com/a/67278566
<p>First, on Windows 10, you could switch to any Linus distro of your choice through WSL2.</p> <p>Second, on Windows, I always had to include the password in the command line:</p> <pre><code>openssl pkcs12 -password pass:aPassword -in server.keystore.pfx -nokeys -clcerts -out server.cert # or openssl pkcs12 -passin pas...
<p>First, on Windows 10, you could switch to any Linus distro of your choice through WSL2.</p> <p>Second, on Windows, I always had to include the password in the command line:</p> <pre><code>openssl pkcs12 -password pass:aPassword -in server.keystore.pfx -nokeys -clcerts -out server.cert # or openssl pkcs12 -passin pas...
64, 1999, 24574, 61874
git-bash, openssl, pkcs#12, windows
<h1>In Git-Bash-Windows `openssl pkcs12` does not prompt for password</h1> <p>The SSL certificate authority sent me the signed certificate in <code>.pfx</code> format and it was password-protected; so I need to convert it to <code>.crt</code> file.</p> <p>The first attempt was to call <code>openssl pkcs12 -in server.pf...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,626
bash
# In Git-Bash-Windows `openssl pkcs12` does not prompt for password The SSL certificate authority sent me the signed certificate in `.pfx` format and it was password-protected; so I need to convert it to `.crt` file. The first attempt was to call `openssl pkcs12 -in server.pfx -out server.crt -nokeys -clcerts`, simpl...
First, on Windows 10, you could switch to any Linus distro of your choice through WSL2. Second, on Windows, I always had to include the password in the command line: ``` openssl pkcs12 -password pass:aPassword -in server.keystore.pfx -nokeys -clcerts -out server.cert # or openssl pkcs12 -passin pass:aPassword -in ser...
44982499
Read from a 'named pipe' / fifo with Node.js
13
2017-07-08 04:30:39
<p>I have this:</p> <pre><code> const p = path.resolve(projectRoot + '/NAMEDPIPEIN'); const fd = fs.openSync(p, 'r+'); fs.createReadStream(null, {fd}).on('data', function (d) { if (String(d).trim() === '[stdin end]') { return process.nextTick(cb); } process.argv.push(String(d).trim()); }); </...
9,195
1,223,975
2025-01-26 09:23:38
52,622,889
14
2018-10-03 08:32:08
1,843,507
2019-12-23 19:09:18
https://stackoverflow.com/q/44982499
https://stackoverflow.com/a/52622889
<p>The other solution, from <a href="https://stackoverflow.com/a/46965930/1843507">@richardpringle</a> should work, but is limited in functionality.</p> <p>If you try to open multiple FIFOs that way (more than the number of threads in the thread-pool), the first ones you opened won't be streaming data anymore. This is...
<p>The other solution, from <a href="https://stackoverflow.com/a/46965930/1843507">@richardpringle</a> should work, but is limited in functionality.</p> <p>If you try to open multiple FIFOs that way (more than the number of threads in the thread-pool), the first ones you opened won't be streaming data anymore. This is...
58, 369, 387, 11366, 46426
bash, linux, macos, named-pipes, node.js
<h1>Read from a 'named pipe' / fifo with Node.js</h1> <p>I have this:</p> <pre><code> const p = path.resolve(projectRoot + '/NAMEDPIPEIN'); const fd = fs.openSync(p, 'r+'); fs.createReadStream(null, {fd}).on('data', function (d) { if (String(d).trim() === '[stdin end]') { return process.nextTick(cb); ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,627
bash
# Read from a 'named pipe' / fifo with Node.js I have this: ``` const p = path.resolve(projectRoot + '/NAMEDPIPEIN'); const fd = fs.openSync(p, 'r+'); fs.createReadStream(null, {fd}).on('data', function (d) { if (String(d).trim() === '[stdin end]') { return process.nextTick(cb); } process.arg...
The other solution, from [@richardpringle](https://stackoverflow.com/a/46965930/1843507) should work, but is limited in functionality. If you try to open multiple FIFOs that way (more than the number of threads in the thread-pool), the first ones you opened won't be streaming data anymore. This is because the `fs` mod...
46696156
Git autocomplete for custom bash functions
13
2017-10-11 19:33:45
<p>In my <code>.bash_profile</code>, I have a lot of functional shortcuts for git. For example:</p> <pre><code>function gitpull() { branch="$1" if [[ -z $branch ]]; then current_branch=`git symbolic-ref -q --short HEAD` git pull origin $current_branch; elif [[ -n $branch &amp;&amp; $branch...
2,062
2,094,116
2021-01-17 03:47:34
46,696,505
14
2017-10-11 19:57:15
404,556
2017-10-12 14:00:41
https://stackoverflow.com/q/46696156
https://stackoverflow.com/a/46696505
<p>Manually-crafted bash completion is as simple as this:</p> <pre><code># our handler that returns choices by populating Bash array COMPREPLY # (filtered by the currently entered word ($2) via compgen builtin) _gitpull_complete() { branches=$(git branch -l | cut -c3-) COMPREPLY=($(compgen -W "$branches" -- "$...
<p>Manually-crafted bash completion is as simple as this:</p> <pre><code># our handler that returns choices by populating Bash array COMPREPLY # (filtered by the currently entered word ($2) via compgen builtin) _gitpull_complete() { branches=$(git branch -l | cut -c3-) COMPREPLY=($(compgen -W "$branches" -- "$...
119, 387, 59778
bash, bash-completion, git
<h1>Git autocomplete for custom bash functions</h1> <p>In my <code>.bash_profile</code>, I have a lot of functional shortcuts for git. For example:</p> <pre><code>function gitpull() { branch="$1" if [[ -z $branch ]]; then current_branch=`git symbolic-ref -q --short HEAD` git pull origin $curre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,628
bash
# Git autocomplete for custom bash functions In my `.bash_profile`, I have a lot of functional shortcuts for git. For example: ``` function gitpull() { branch="$1" if [[ -z $branch ]]; then current_branch=`git symbolic-ref -q --short HEAD` git pull origin $current_branch; elif [[ -n $bran...
Manually-crafted bash completion is as simple as this: ``` # our handler that returns choices by populating Bash array COMPREPLY # (filtered by the currently entered word ($2) via compgen builtin) _gitpull_complete() { branches=$(git branch -l | cut -c3-) COMPREPLY=($(compgen -W "$branches" -- "$2")) } # we n...
40458246
How do I run an extensionless (maybe ELF) file on Ubuntu?
13
2016-11-07 05:14:25
<p>I was given a "binary" file on linux and a seperate file for windows for a particular task. The programs is an exe on windows. A linux version of the file has the same function on linux as it had windows, too.</p> <p>However, I've failed to be able to execute this. I tried (on the terminal) to execute it by just th...
98,132
4,640,489
2022-12-12 01:25:58
40,458,487
14
2016-11-07 05:39:16
229,602
2016-11-07 05:39:16
https://stackoverflow.com/q/40458246
https://stackoverflow.com/a/40458487
<p>My guess is that this is 32 bit compile on a 64 bit system. I cross compiled a small c file into a binary using the <code>-m32</code> option on gcc. This also needed a few extra packages. The resulting <code>a.out</code> looks like this.</p> <pre><code>% file a.out a.out: ELF 32-bit LSB executable, Intel 80386, ver...
<p>My guess is that this is 32 bit compile on a 64 bit system. I cross compiled a small c file into a binary using the <code>-m32</code> option on gcc. This also needed a few extra packages. The resulting <code>a.out</code> looks like this.</p> <pre><code>% file a.out a.out: ELF 32-bit LSB executable, Intel 80386, ver...
58, 387, 390
bash, linux, shell
<h1>How do I run an extensionless (maybe ELF) file on Ubuntu?</h1> <p>I was given a "binary" file on linux and a seperate file for windows for a particular task. The programs is an exe on windows. A linux version of the file has the same function on linux as it had windows, too.</p> <p>However, I've failed to be able ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,629
bash
# How do I run an extensionless (maybe ELF) file on Ubuntu? I was given a "binary" file on linux and a seperate file for windows for a particular task. The programs is an exe on windows. A linux version of the file has the same function on linux as it had windows, too. However, I've failed to be able to execute this....
My guess is that this is 32 bit compile on a 64 bit system. I cross compiled a small c file into a binary using the `-m32` option on gcc. This also needed a few extra packages. The resulting `a.out` looks like this. ``` % file a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, i...
38996051
Reading python variables during a running job
13
2016-08-17 12:00:26
<p>I have launched a python script that takes a long time to finish, and silly me I forgot to print out the values of important variables every now and then in my script, to for example estimate the progress of the computation I'm doing. So now, I was wondering if there's a way to access the current values of certain ...
5,544
null
2016-08-17 13:33:30
38,996,231
14
2016-08-17 12:08:14
1,702,990
2016-08-17 13:33:30
https://stackoverflow.com/q/38996051
https://stackoverflow.com/a/38996231
<p>Without editing your program, you're going to have a bad time. What you are looking for is some form of remote debugger, but anything that gives you python specific things will probably have to be at least somehow given a hook into your program. That being said, if you feel like fiddling around in a stack, you can a...
<p>Without editing your program, you're going to have a bad time. What you are looking for is some form of remote debugger, but anything that gives you python specific things will probably have to be at least somehow given a hook into your program. That being said, if you feel like fiddling around in a stack, you can a...
16, 390
python, shell
<h1>Reading python variables during a running job</h1> <p>I have launched a python script that takes a long time to finish, and silly me I forgot to print out the values of important variables every now and then in my script, to for example estimate the progress of the computation I'm doing. So now, I was wondering if...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,630
bash
# Reading python variables during a running job I have launched a python script that takes a long time to finish, and silly me I forgot to print out the values of important variables every now and then in my script, to for example estimate the progress of the computation I'm doing. So now, I was wondering if there's a...
Without editing your program, you're going to have a bad time. What you are looking for is some form of remote debugger, but anything that gives you python specific things will probably have to be at least somehow given a hook into your program. That being said, if you feel like fiddling around in a stack, you can atta...
37356444
Sed error "command a expects \ followed by text"
13
2016-05-20 21:56:35
<p>Here is my script:</p> <pre><code>openscad $1 -D generate=1 -o $1.csg 2&gt;&amp;1 &gt;/dev/null | sed 's/ECHO: \"\[LC\] //' | sed 's/"$//' | sed '$a;' &gt;./2d_$1 </code></pre> <p>That output:</p> <pre><code>sed: 1: "$a;": command a expects \ followed by text </code></pre>
15,547
null
2023-05-23 08:56:06
37,356,878
14
2016-05-20 22:41:41
15,168
2016-05-20 22:41:41
https://stackoverflow.com/q/37356444
https://stackoverflow.com/a/37356878
<p>Your version of <code>sed</code> is not GNU <code>sed</code> which allows what you use. You need to write:</p> <pre><code>openscad $1 -D generate=1 -o $1.csg 2&gt;&amp;1 &gt;/dev/null | sed 's/ECHO: \"\[LC\] //' | sed 's/"$//' | sed '$a\ ;' &gt;./2d_$1 </code></pre> <p>Also, three copies of <code>sed</code> is a ...
<p>Your version of <code>sed</code> is not GNU <code>sed</code> which allows what you use. You need to write:</p> <pre><code>openscad $1 -D generate=1 -o $1.csg 2&gt;&amp;1 &gt;/dev/null | sed 's/ECHO: \"\[LC\] //' | sed 's/"$//' | sed '$a\ ;' &gt;./2d_$1 </code></pre> <p>Also, three copies of <code>sed</code> is a ...
387, 5282, 93134
bash, openscad, sed
<h1>Sed error "command a expects \ followed by text"</h1> <p>Here is my script:</p> <pre><code>openscad $1 -D generate=1 -o $1.csg 2&gt;&amp;1 &gt;/dev/null | sed 's/ECHO: \"\[LC\] //' | sed 's/"$//' | sed '$a;' &gt;./2d_$1 </code></pre> <p>That output:</p> <pre><code>sed: 1: "$a;": command a expects \ followed by t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,631
bash
# Sed error "command a expects \ followed by text" Here is my script: ``` openscad $1 -D generate=1 -o $1.csg 2>&1 >/dev/null | sed 's/ECHO: \"\[LC\] //' | sed 's/"$//' | sed '$a;' >./2d_$1 ``` That output: ``` sed: 1: "$a;": command a expects \ followed by text ```
Your version of `sed` is not GNU `sed` which allows what you use. You need to write: ``` openscad $1 -D generate=1 -o $1.csg 2>&1 >/dev/null | sed 's/ECHO: \"\[LC\] //' | sed 's/"$//' | sed '$a\ ;' >./2d_$1 ``` Also, three copies of `sed` is a little excessive (to be polite); one suffices: ``` openscad $1 -D generat...
37275033
Running 'export' command with Pythons 'subprocess' does not work
13
2016-05-17 11:37:41
<pre><code>subprocess.run('export FOO=BAR', shell=True) </code></pre> <p>This simply doesn't work, and I have no idea why.</p> <p>All I am trying to do I set an environment variable from my python (3.5.1) script, and when I run the above line, nothing happens. No errors are raised, and when I check the environment va...
6,984
6,018,304
2016-05-17 12:17:30
37,275,214
14
2016-05-17 11:45:53
1,126,841
2016-05-17 12:17:30
https://stackoverflow.com/q/37275033
https://stackoverflow.com/a/37275214
<p>It works fine; however, the variable setting only exists in the subprocess. You cannot affect the environment of the local process from a child.</p> <p><code>os.environ</code> is the correct solution, as it changes the environment of the local process, and those changes will be inherited by any process started with...
<p>It works fine; however, the variable setting only exists in the subprocess. You cannot affect the environment of the local process from a child.</p> <p><code>os.environ</code> is the correct solution, as it changes the environment of the local process, and those changes will be inherited by any process started with...
16, 387, 390, 1796, 2348
bash, command, python, shell, subprocess
<h1>Running 'export' command with Pythons 'subprocess' does not work</h1> <pre><code>subprocess.run('export FOO=BAR', shell=True) </code></pre> <p>This simply doesn't work, and I have no idea why.</p> <p>All I am trying to do I set an environment variable from my python (3.5.1) script, and when I run the above line, ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,632
bash
# Running 'export' command with Pythons 'subprocess' does not work ``` subprocess.run('export FOO=BAR', shell=True) ``` This simply doesn't work, and I have no idea why. All I am trying to do I set an environment variable from my python (3.5.1) script, and when I run the above line, nothing happens. No errors are ra...
It works fine; however, the variable setting only exists in the subprocess. You cannot affect the environment of the local process from a child. `os.environ` is the correct solution, as it changes the environment of the local process, and those changes will be inherited by any process started with `subprocess.run`. Y...
32007152
Insert multiple lines of text before specific line using Bash
13
2015-08-14 09:48:32
<p>I am trying to insert a few lines of text before a specific line, but keep getting sed errors when I try to add a new line character. My command looks like:</p> <pre><code>sed -r -i '/Line to insert after/ i Line one to insert \\ second new line to insert \\ third new line to insert' /etc/directory/somefil...
25,913
575,596
2019-05-28 23:05:26
32,007,388
14
2015-08-14 10:00:24
548,225
2015-08-14 10:00:24
https://stackoverflow.com/q/32007152
https://stackoverflow.com/a/32007388
<p>This should work:</p> <pre><code>sed -i '/Line to insert after/ i Line one to insert \ second new line to insert \ third new line to insert' file </code></pre>
<p>This should work:</p> <pre><code>sed -i '/Line to insert after/ i Line one to insert \ second new line to insert \ third new line to insert' file </code></pre>
34, 387, 5282, 30640
bash, sed, text-manipulation, unix
<h1>Insert multiple lines of text before specific line using Bash</h1> <p>I am trying to insert a few lines of text before a specific line, but keep getting sed errors when I try to add a new line character. My command looks like:</p> <pre><code>sed -r -i '/Line to insert after/ i Line one to insert \\ second new...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,633
bash
# Insert multiple lines of text before specific line using Bash I am trying to insert a few lines of text before a specific line, but keep getting sed errors when I try to add a new line character. My command looks like: ``` sed -r -i '/Line to insert after/ i Line one to insert \\ second new line to insert \\ ...
This should work: ``` sed -i '/Line to insert after/ i Line one to insert \ second new line to insert \ third new line to insert' file ```
27652458
What's the best way to embed a Unicode character in a POSIX shell script?
13
2014-12-26 03:08:06
<p>There's several shell-specific ways to include a ‘unicode literal’ in a string. For instance, in Bash, the quoted string-expanding mechanism, <code>$''</code>, allows us to directly embed an invisible character: <code>$'\u2620'</code>.</p> <p>However, if you're trying to write universally cross-platform shell-scrip...
6,522
31,897
2016-11-27 22:20:28
27,658,989
14
2014-12-26 15:37:41
1,566,221
2015-06-26 17:47:44
https://stackoverflow.com/q/27652458
https://stackoverflow.com/a/27658989
<p>If you have Gnu <code>printf</code> installed (it's in debian package <code>coreutils</code>, for example), then you can use it independent of which shell you are using by avoiding the shell's builtin:</p> <pre><code>env printf '\u2388\n' </code></pre> <p>Here I am using the Posix-standard <code>env</code> command...
<p>If you have Gnu <code>printf</code> installed (it's in debian package <code>coreutils</code>, for example), then you can use it independent of which shell you are using by avoiding the shell's builtin:</p> <pre><code>env printf '\u2388\n' </code></pre> <p>Here I am using the Posix-standard <code>env</code> command...
279, 387, 390, 1993, 137448
bash, dash-shell, posix, shell, unicode
<h1>What's the best way to embed a Unicode character in a POSIX shell script?</h1> <p>There's several shell-specific ways to include a ‘unicode literal’ in a string. For instance, in Bash, the quoted string-expanding mechanism, <code>$''</code>, allows us to directly embed an invisible character: <code>$'\u2620'</code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,634
bash
# What's the best way to embed a Unicode character in a POSIX shell script? There's several shell-specific ways to include a ‘unicode literal’ in a string. For instance, in Bash, the quoted string-expanding mechanism, `$''`, allows us to directly embed an invisible character: `$'\u2620'`. However, if you're trying to...
If you have Gnu `printf` installed (it's in debian package `coreutils`, for example), then you can use it independent of which shell you are using by avoiding the shell's builtin: ``` env printf '\u2388\n' ``` Here I am using the Posix-standard `env` command to avoid the use of the `printf` builtin, but if you happen...
24701227
coloring in heredocs, bash
13
2014-07-11 15:23:38
<p>If I have previously defined color variable like this:</p> <pre><code>txtred='\e[1;31m' </code></pre> <p>How would I use it in <strong>heredoc</strong>:</p> <pre><code> cat &lt;&lt; EOM [colorcode here] USAGE: EOM </code></pre> <p>I mean what should I write in place of <code>[colorcode here]</code> to r...
5,222
2,434,479
2025-12-15 07:00:02
24,701,349
14
2014-07-11 15:29:20
258,523
2018-03-03 03:15:55
https://stackoverflow.com/q/24701227
https://stackoverflow.com/a/24701349
<p>You need something to interpret the escape sequence which <code>cat</code> won't do. This is why you need <code>echo -e</code> instead of just <code>echo</code> to make it work normally.</p> <pre><code>cat &lt;&lt; EOM $(echo -e "${txtred} USAGE:") EOM </code></pre> <p>works</p> <p>but you could also not use esca...
<p>You need something to interpret the escape sequence which <code>cat</code> won't do. This is why you need <code>echo -e</code> instead of just <code>echo</code> to make it work normally.</p> <pre><code>cat &lt;&lt; EOM $(echo -e "${txtred} USAGE:") EOM </code></pre> <p>works</p> <p>but you could also not use esca...
387, 6439, 7449
bash, colors, heredoc
<h1>coloring in heredocs, bash</h1> <p>If I have previously defined color variable like this:</p> <pre><code>txtred='\e[1;31m' </code></pre> <p>How would I use it in <strong>heredoc</strong>:</p> <pre><code> cat &lt;&lt; EOM [colorcode here] USAGE: EOM </code></pre> <p>I mean what should I write in place o...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,635
bash
# coloring in heredocs, bash If I have previously defined color variable like this: ``` txtred='\e[1;31m' ``` How would I use it in **heredoc**: ``` cat << EOM [colorcode here] USAGE: EOM ``` I mean what should I write in place of `[colorcode here]` to render that USAGE text red? `${txtred}` won't work, ...
You need something to interpret the escape sequence which `cat` won't do. This is why you need `echo -e` instead of just `echo` to make it work normally. ``` cat << EOM $(echo -e "${txtred} USAGE:") EOM ``` works but you could also not use escape sequences by using `textred=$(tput setaf 1)` and then just use the var...
24525791
PowerShell Write-Output inside "if" does not output anything
13
2014-07-02 07:55:57
<p>I am learning PowerShell recently, and found a behavior that I cannot understand. Let me explain in code below:</p> <pre><code>function func1() { Write-Output "output from func1()" func2 return $true } function func2() { Write-Output "output from func2()" func3 } function func3() { Write-O...
9,301
3,104,257
2024-02-27 10:26:08
24,526,547
14
2014-07-02 08:38:00
3,796,417
2019-04-04 09:22:56
https://stackoverflow.com/q/24525791
https://stackoverflow.com/a/24526547
<p>PowerShell functions are not like their traditional language counterparts: they can output multiple things. When you're using <code>Write-Output</code>, you are sending things down the pipeline, so <code>func1()</code> will return both a String and a Boolean. If you try this:</p> <pre><code>$return_values = func1; ...
<p>PowerShell functions are not like their traditional language counterparts: they can output multiple things. When you're using <code>Write-Output</code>, you are sending things down the pipeline, so <code>func1()</code> will return both a String and a Boolean. If you try this:</p> <pre><code>$return_values = func1; ...
526
powershell
<h1>PowerShell Write-Output inside "if" does not output anything</h1> <p>I am learning PowerShell recently, and found a behavior that I cannot understand. Let me explain in code below:</p> <pre><code>function func1() { Write-Output "output from func1()" func2 return $true } function func2() { Write-Ou...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,636
bash
# PowerShell Write-Output inside "if" does not output anything I am learning PowerShell recently, and found a behavior that I cannot understand. Let me explain in code below: ``` function func1() { Write-Output "output from func1()" func2 return $true } function func2() { Write-Output "output from fu...
PowerShell functions are not like their traditional language counterparts: they can output multiple things. When you're using `Write-Output`, you are sending things down the pipeline, so `func1()` will return both a String and a Boolean. If you try this: ``` $return_values = func1; $return_values | Get-Member ``` You...
24004302
Using PowerShell to import data properly into an array
13
2014-06-02 22:28:32
<p>I am trying to put together a PowerShell script that will read data from a CSV (it is actually tab separated and not CSV but for SO, we'll use commas) and import that data into a PowerShell multidimensional array. My CSV has the following data:</p> <pre><code>EmpID,Name,Dept 12345,John,Service 56789,Sarah,Sales 98...
151,933
2,846,397
2016-03-16 23:00:30
24,004,453
14
2014-06-02 22:42:24
3,661,652
2014-06-02 22:42:24
https://stackoverflow.com/q/24004302
https://stackoverflow.com/a/24004453
<p>You're working too hard. Import-CSV will work with comma separation by default, and you could handle tab delimited using -Delimiter. From there you can reference the columns by name.</p> <pre><code>Import-CSV "temp.csv" | Write-Host "EmpID=" + $_.EmpID </code></pre>
<p>You're working too hard. Import-CSV will work with comma separation by default, and you could handle tab delimited using -Delimiter. From there you can reference the columns by name.</p> <pre><code>Import-CSV "temp.csv" | Write-Host "EmpID=" + $_.EmpID </code></pre>
526
powershell
<h1>Using PowerShell to import data properly into an array</h1> <p>I am trying to put together a PowerShell script that will read data from a CSV (it is actually tab separated and not CSV but for SO, we'll use commas) and import that data into a PowerShell multidimensional array. My CSV has the following data:</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,637
bash
# Using PowerShell to import data properly into an array I am trying to put together a PowerShell script that will read data from a CSV (it is actually tab separated and not CSV but for SO, we'll use commas) and import that data into a PowerShell multidimensional array. My CSV has the following data: ``` EmpID,Name,D...
You're working too hard. Import-CSV will work with comma separation by default, and you could handle tab delimited using -Delimiter. From there you can reference the columns by name. ``` Import-CSV "temp.csv" | Write-Host "EmpID=" + $_.EmpID ```
21944643
powershell select-string not working correctly
13
2014-02-21 20:35:49
<p>I'm a beginner to powershell and having I suspect what will be a simple problem. I'm trying to do the following command, but it returns nothing as a result and I don't understand why.</p> <p>I'm trying to get the description of the current section of bcdedit. If I do:</p> <pre class="lang-powershell prettyprint-ov...
16,221
2,443,973
2017-06-08 08:39:21
21,945,017
14
2014-02-21 20:57:24
1,630,171
2017-06-08 08:39:21
https://stackoverflow.com/q/21944643
https://stackoverflow.com/a/21945017
<p>You don't get the result you expect, because <code>Select-String</code> doesn't output strings, but <a href="http://msdn.microsoft.com/en-us/library/microsoft.powershell.commands.matchinfo_members%28v=vs.85%29.aspx" rel="noreferrer"><code>MatchInfo</code></a> objects. If you pipe the output of your first <code>Selec...
<p>You don't get the result you expect, because <code>Select-String</code> doesn't output strings, but <a href="http://msdn.microsoft.com/en-us/library/microsoft.powershell.commands.matchinfo_members%28v=vs.85%29.aspx" rel="noreferrer"><code>MatchInfo</code></a> objects. If you pipe the output of your first <code>Selec...
526, 92879
powershell, select-string
<h1>powershell select-string not working correctly</h1> <p>I'm a beginner to powershell and having I suspect what will be a simple problem. I'm trying to do the following command, but it returns nothing as a result and I don't understand why.</p> <p>I'm trying to get the description of the current section of bcdedit. ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,638
bash
# powershell select-string not working correctly I'm a beginner to powershell and having I suspect what will be a simple problem. I'm trying to do the following command, but it returns nothing as a result and I don't understand why. I'm trying to get the description of the current section of bcdedit. If I do: ``` bc...
You don't get the result you expect, because `Select-String` doesn't output strings, but [`MatchInfo`](http://msdn.microsoft.com/en-us/library/microsoft.powershell.commands.matchinfo_members%28v=vs.85%29.aspx) objects. If you pipe the output of your first `Select-String` into the `Get-Member` or `Format-List` cmdlet, y...
16673570
Bash case statement
13
2013-05-21 15:18:43
<p>I'm trying to learn case as I was to write a fully functional script.</p> <p>I'm starting off with the below</p> <pre><code>#!/bin/sh case $@ in -h|--help) echo "You have selected Help" ;; -B|-b) echo "You have selected B" ;; -C|-c) echo "You...
29,739
1,978,420
2016-06-23 17:54:52
16,682,308
14
2013-05-22 01:59:59
2,378,898
2013-05-22 01:59:59
https://stackoverflow.com/q/16673570
https://stackoverflow.com/a/16682308
<p>Try this</p> <pre><code>#!/bin/sh usage() { echo `basename $0`: ERROR: $* 1&gt;&amp;2 echo usage: `basename $0` '[-a] [-b] [-c] [file ...]' 1&gt;&amp;2 exit 1 } while : do case "$1" in -a|-A) echo you picked A;; -b|-B) echo you picked B;; -c|-C) echo you picked C;; -*) us...
<p>Try this</p> <pre><code>#!/bin/sh usage() { echo `basename $0`: ERROR: $* 1&gt;&amp;2 echo usage: `basename $0` '[-a] [-b] [-c] [file ...]' 1&gt;&amp;2 exit 1 } while : do case "$1" in -a|-A) echo you picked A;; -b|-B) echo you picked B;; -c|-C) echo you picked C;; -*) us...
387, 390, 6107
bash, case, shell
<h1>Bash case statement</h1> <p>I'm trying to learn case as I was to write a fully functional script.</p> <p>I'm starting off with the below</p> <pre><code>#!/bin/sh case $@ in -h|--help) echo "You have selected Help" ;; -B|-b) echo "You have selected B" ;; ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,639
bash
# Bash case statement I'm trying to learn case as I was to write a fully functional script. I'm starting off with the below ``` #!/bin/sh case $@ in -h|--help) echo "You have selected Help" ;; -B|-b) echo "You have selected B" ;; -C|-c) echo "Y...
Try this ``` #!/bin/sh usage() { echo `basename $0`: ERROR: $* 1>&2 echo usage: `basename $0` '[-a] [-b] [-c] [file ...]' 1>&2 exit 1 } while : do case "$1" in -a|-A) echo you picked A;; -b|-B) echo you picked B;; -c|-C) echo you picked C;; -*) usage "bad argument $1";; ...
16654866
Invoke-Sqlcmd, InputFile, and Variable
13
2013-05-20 17:25:34
<p>I need to exec a powershell script that exec a SQL script to create a database. Based on my knowledge I exec the powershell command in this way:</p> <p><strong>Init.ps1</strong></p> <pre><code>$DATABASEFILENAME = "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008INSTANCE\MSSQL\DATA\myDB.mdf" $DATABASELOGNAM...
19,287
250,003
2022-08-23 15:19:41
16,656,788
14
2013-05-20 19:21:03
135,965
2017-02-08 15:27:13
https://stackoverflow.com/q/16654866
https://stackoverflow.com/a/16656788
<p>The <code>Variable</code> parameter for the <code>Invoke-Sqlcmd</code> cmdlet is picky. Do not include spaces before or after the variable assignment.</p> <pre><code>$sqlVariable = "DATABASEFILENAME='$DATABASEFILENAME'", "DATABASELOGNAME='$DATABASELOGNAME'", "DBUSEROWNER='$DBUSEROWNER'" </code></pre> <p>Also you n...
<p>The <code>Variable</code> parameter for the <code>Invoke-Sqlcmd</code> cmdlet is picky. Do not include spaces before or after the variable assignment.</p> <pre><code>$sqlVariable = "DATABASEFILENAME='$DATABASEFILENAME'", "DATABASELOGNAME='$DATABASELOGNAME'", "DBUSEROWNER='$DBUSEROWNER'" </code></pre> <p>Also you n...
72, 526
powershell, sql-server
<h1>Invoke-Sqlcmd, InputFile, and Variable</h1> <p>I need to exec a powershell script that exec a SQL script to create a database. Based on my knowledge I exec the powershell command in this way:</p> <p><strong>Init.ps1</strong></p> <pre><code>$DATABASEFILENAME = "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,640
bash
# Invoke-Sqlcmd, InputFile, and Variable I need to exec a powershell script that exec a SQL script to create a database. Based on my knowledge I exec the powershell command in this way: **Init.ps1** ``` $DATABASEFILENAME = "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008INSTANCE\MSSQL\DATA\myDB.mdf" $DATABA...
The `Variable` parameter for the `Invoke-Sqlcmd` cmdlet is picky. Do not include spaces before or after the variable assignment. ``` $sqlVariable = "DATABASEFILENAME='$DATABASEFILENAME'", "DATABASELOGNAME='$DATABASELOGNAME'", "DBUSEROWNER='$DBUSEROWNER'" ``` Also you need remove single quotes from variables: ``` $sq...
16019389
Passing An Array From One Bash Script to Another
13
2013-04-15 15:45:45
<p>I am new to writing Shell Scripts and am having some difficulties.</p> <p><strong>What I Want To Achieve</strong></p> <p>I have an array of strings in <code>scriptOne.sh</code> that I want to pass to <code>scriptTwo.sh</code></p> <p><strong>What I Have Done So Far</strong></p> <p>I can execute the second script ...
8,522
507,313
2024-02-02 11:39:38
16,019,520
14
2013-04-15 15:51:51
1,030,675
2013-04-15 15:51:51
https://stackoverflow.com/q/16019389
https://stackoverflow.com/a/16019520
<p>Your way of passing the array is correct</p> <pre><code>./scriptTwo.sh "${array[@]}" </code></pre> <p>The problem is probably in the way how you receive it. In <code>scriptTwo.sh</code>, use</p> <pre><code>array=("$@") </code></pre>
<p>Your way of passing the array is correct</p> <pre><code>./scriptTwo.sh "${array[@]}" </code></pre> <p>The problem is probably in the way how you receive it. In <code>scriptTwo.sh</code>, use</p> <pre><code>array=("$@") </code></pre>
114, 387, 390, 10355
arrays, bash, parameter-passing, shell
<h1>Passing An Array From One Bash Script to Another</h1> <p>I am new to writing Shell Scripts and am having some difficulties.</p> <p><strong>What I Want To Achieve</strong></p> <p>I have an array of strings in <code>scriptOne.sh</code> that I want to pass to <code>scriptTwo.sh</code></p> <p><strong>What I Have Don...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,641
bash
# Passing An Array From One Bash Script to Another I am new to writing Shell Scripts and am having some difficulties. **What I Want To Achieve** I have an array of strings in `scriptOne.sh` that I want to pass to `scriptTwo.sh` **What I Have Done So Far** I can execute the second script from inside the first using...
Your way of passing the array is correct ``` ./scriptTwo.sh "${array[@]}" ``` The problem is probably in the way how you receive it. In `scriptTwo.sh`, use ``` array=("$@") ```
13971808
Execute command multiple times with curly brackets arguments list
13
2012-12-20 12:03:12
<p>When I needed to run a command multiple times with a different argument I used this approach (without understanding it fully):</p> <pre><code>touch {a,b,c} </code></pre> <p>Which is equivalent of:</p> <pre><code>touch a touch b touch c </code></pre> <p>I think the same could be accomplished with the following lo...
8,498
679,227
2015-03-06 18:22:35
13,972,093
14
2012-12-20 12:19:28
115,845
2012-12-20 12:19:28
https://stackoverflow.com/q/13971808
https://stackoverflow.com/a/13972093
<p>That's called <a href="http://wiki.bash-hackers.org/syntax/expansion/brace">Brace Expansion</a>, which expands to a space-separated list of the given strings. </p> <p>So <code>touch {a,b,c}</code> would be equivalent to</p> <pre><code>touch a b c </code></pre> <p>While <code>touch {a,b,c}x</code> would be equival...
<p>That's called <a href="http://wiki.bash-hackers.org/syntax/expansion/brace">Brace Expansion</a>, which expands to a space-separated list of the given strings. </p> <p>So <code>touch {a,b,c}</code> would be equivalent to</p> <pre><code>touch a b c </code></pre> <p>While <code>touch {a,b,c}x</code> would be equival...
387, 390, 1231, 31134, 41340
bash, brace-expansion, command-line, command-line-arguments, shell
<h1>Execute command multiple times with curly brackets arguments list</h1> <p>When I needed to run a command multiple times with a different argument I used this approach (without understanding it fully):</p> <pre><code>touch {a,b,c} </code></pre> <p>Which is equivalent of:</p> <pre><code>touch a touch b touch c </c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,642
bash
# Execute command multiple times with curly brackets arguments list When I needed to run a command multiple times with a different argument I used this approach (without understanding it fully): ``` touch {a,b,c} ``` Which is equivalent of: ``` touch a touch b touch c ``` I think the same could be accomplished wit...
That's called [Brace Expansion](http://wiki.bash-hackers.org/syntax/expansion/brace), which expands to a space-separated list of the given strings. So `touch {a,b,c}` would be equivalent to ``` touch a b c ``` While `touch {a,b,c}x` would be equivalent to: ``` touch ax bx cx ``` You `pear` command would essentiall...
9268836
zsh change prompt input color
13
2012-02-13 22:12:58
<p>I want to change the color of the input text in zsh (the text that I type for each command). Example: in <code>user@host&gt; ls ~/</code> I would want <code>ls ~/</code> <strong>to be yellow to stand out from standard output.</strong> </p> <p>I know I can accomplish this in <strong>bash</strong> using </p> <pre><c...
12,105
1,164,573
2012-11-30 17:10:41
13,635,653
14
2012-11-29 22:08:22
719,547
2012-11-30 17:10:41
https://stackoverflow.com/q/9268836
https://stackoverflow.com/a/13635653
<p>Try this:</p> <pre><code>PROMPT="%F{green}%n@%m %# %F{yellow}" preexec () { echo -ne "\e[0m" } </code></pre> <p>I tried using <code>trap</code>, but it looks like <code>DEBUG</code> doesn't happen until after the command runs/before the next prompt, so the command ends up executing in yellow. The <code>preexec()<...
<p>Try this:</p> <pre><code>PROMPT="%F{green}%n@%m %# %F{yellow}" preexec () { echo -ne "\e[0m" } </code></pre> <p>I tried using <code>trap</code>, but it looks like <code>DEBUG</code> doesn't happen until after the command runs/before the next prompt, so the command ends up executing in yellow. The <code>preexec()<...
387, 391, 3791, 28566
bash, terminal, zsh, zshrc
<h1>zsh change prompt input color</h1> <p>I want to change the color of the input text in zsh (the text that I type for each command). Example: in <code>user@host&gt; ls ~/</code> I would want <code>ls ~/</code> <strong>to be yellow to stand out from standard output.</strong> </p> <p>I know I can accomplish this in <s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,643
bash
# zsh change prompt input color I want to change the color of the input text in zsh (the text that I type for each command). Example: in `user@host> ls ~/` I would want `ls ~/` **to be yellow to stand out from standard output.** I know I can accomplish this in **bash** using ``` export PS1=" $BIGreen \u@\h \w \$ $IY...
Try this: ``` PROMPT="%F{green}%n@%m %# %F{yellow}" preexec () { echo -ne "\e[0m" } ``` I tried using `trap`, but it looks like `DEBUG` doesn't happen until after the command runs/before the next prompt, so the command ends up executing in yellow. The `preexec()` function gets called before the command executes, so y...
13609701
How to ignore return value different then 0 when I have set -e?
13
2012-11-28 16:24:05
<p>I often add <code>set -e</code> in my bash scripts. However this time I have to call a command that returns some meaningless number instead of 0 on success. How can I tell bash to ignore the return value of this command only.</p> <p>Changing the command, or changing it's code to conform to the standard is not an op...
1,442
1,047,870
2018-11-21 02:28:22
13,609,745
14
2012-11-28 16:26:12
462,117
2012-11-28 16:26:12
https://stackoverflow.com/q/13609701
https://stackoverflow.com/a/13609745
<p><code>true</code> always returns a zero exit code. So you can do</p> <pre><code>command-with-meaningless-return-value || true </code></pre>
<p><code>true</code> always returns a zero exit code. So you can do</p> <pre><code>command-with-meaningless-return-value || true </code></pre>
387
bash
<h1>How to ignore return value different then 0 when I have set -e?</h1> <p>I often add <code>set -e</code> in my bash scripts. However this time I have to call a command that returns some meaningless number instead of 0 on success. How can I tell bash to ignore the return value of this command only.</p> <p>Changing t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,644
bash
# How to ignore return value different then 0 when I have set -e? I often add `set -e` in my bash scripts. However this time I have to call a command that returns some meaningless number instead of 0 on success. How can I tell bash to ignore the return value of this command only. Changing the command, or changing it'...
`true` always returns a zero exit code. So you can do ``` command-with-meaningless-return-value || true ```
13258123
Shell Scripting unwanted '?' character at the end of file name
13
2012-11-06 19:37:35
<p>I get an unwanted '?' at the end of my file name while doing this: </p> <pre><code>emplid=$(grep -a "Student ID" "$i".txt | sed 's/(Student ID: //g' | sed 's/)Tj//g' ) #gets emplid by doing a grep from some text file echo "$emplid" #prints employee id correctly cp "$i" "$emplid".pdf #getting an extra '?' ch...
16,022
1,380,255
2014-01-30 21:31:12
13,258,251
14
2012-11-06 19:45:41
89,817
2012-11-07 01:47:51
https://stackoverflow.com/q/13258123
https://stackoverflow.com/a/13258251
<p>It sounds like your script file has DOS-style line endings (\r\n) instead of unix-style (just \n) -- when a script in this format, the \r gets treated as part of the commands. In this instance, it's getting included in $emplid and therefore in the filename.</p> <p>Many platforms support the <code>dos2unix</code> co...
<p>It sounds like your script file has DOS-style line endings (\r\n) instead of unix-style (just \n) -- when a script in this format, the \r gets treated as part of the commands. In this instance, it's getting included in $emplid and therefore in the filename.</p> <p>Many platforms support the <code>dos2unix</code> co...
387, 390, 25299
bash, cp, shell
<h1>Shell Scripting unwanted '?' character at the end of file name</h1> <p>I get an unwanted '?' at the end of my file name while doing this: </p> <pre><code>emplid=$(grep -a "Student ID" "$i".txt | sed 's/(Student ID: //g' | sed 's/)Tj//g' ) #gets emplid by doing a grep from some text file echo "$emplid" #print...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,645
bash
# Shell Scripting unwanted '?' character at the end of file name I get an unwanted '?' at the end of my file name while doing this: ``` emplid=$(grep -a "Student ID" "$i".txt | sed 's/(Student ID: //g' | sed 's/)Tj//g' ) #gets emplid by doing a grep from some text file echo "$emplid" #prints employee id correct...
It sounds like your script file has DOS-style line endings (\r\n) instead of unix-style (just \n) -- when a script in this format, the \r gets treated as part of the commands. In this instance, it's getting included in $emplid and therefore in the filename. Many platforms support the `dos2unix` command to convert the ...
10224921
How to create a temporary file with portable shell in a secure way?
13
2012-04-19 09:08:02
<p>I want to create a temporary file in POSIX shell (<code>/bin/sh</code>). </p> <p>I found out that <code>mktemp(1)</code> doens't exist on my AIX box, and according to <a href="https://stackoverflow.com/questions/2792675/how-portable-is-mktemp1">How portable is mktemp(1)?</a>, it isn't that portable and/or secure an...
4,090
24,760
2025-01-19 14:32:10
10,235,393
14
2012-04-19 19:30:22
1,296,116
2012-04-23 12:04:12
https://stackoverflow.com/q/10224921
https://stackoverflow.com/a/10235393
<p>Why not use <code>/dev/random</code>? </p> <p>It could be neater with perl but od and awk will do, something like:</p> <pre><code>tempfile=XXX-$(od -N4 -tu /dev/random | awk 'NR==1 {print $2} {}') </code></pre>
<p>Why not use <code>/dev/random</code>? </p> <p>It could be neater with perl but od and awk will do, something like:</p> <pre><code>tempfile=XXX-$(od -N4 -tu /dev/random | awk 'NR==1 {print $2} {}') </code></pre>
390, 1407, 1993, 17512, 63811
portability, posix, secure-coding, shell, temporary-files
<h1>How to create a temporary file with portable shell in a secure way?</h1> <p>I want to create a temporary file in POSIX shell (<code>/bin/sh</code>). </p> <p>I found out that <code>mktemp(1)</code> doens't exist on my AIX box, and according to <a href="https://stackoverflow.com/questions/2792675/how-portable-is-mkt...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,646
bash
# How to create a temporary file with portable shell in a secure way? I want to create a temporary file in POSIX shell (`/bin/sh`). I found out that `mktemp(1)` doens't exist on my AIX box, and according to [How portable is mktemp(1)?](https://stackoverflow.com/questions/2792675/how-portable-is-mktemp1), it isn't tha...
Why not use `/dev/random`? It could be neater with perl but od and awk will do, something like: ``` tempfile=XXX-$(od -N4 -tu /dev/random | awk 'NR==1 {print $2} {}') ```
8100334
Best Icon size for displaying in the tray
13
2011-11-11 21:41:20
<p>I am working on a Delphi program which will display an icon on the "tray". I am doing it "the hard way" (using the Shell_NotifyIcon api, etc and not a component, for reasons outside the point here). It's working fine but sometimes it seems like the icon is a little "blurry" in some systems. Now, I have experimented ...
24,224
218,587
2017-11-17 20:30:46
8,100,520
14
2011-11-11 22:02:11
505,088
2011-11-12 13:48:33
https://stackoverflow.com/q/8100334
https://stackoverflow.com/a/8100520
<p>You should be using 32bpp icons with partial transparency for best effect.</p> <p>The icon uses the small system size. Get this by calling <code>GetSystemMetrics</code> passing <code>SM_CXSMICON</code>. If you use font scaling this can be, for example, 20px rather than the more common 16px. I've never found MS docu...
<p>You should be using 32bpp icons with partial transparency for best effect.</p> <p>The icon uses the small system size. Get this by calling <code>GetSystemMetrics</code> passing <code>SM_CXSMICON</code>. If you use font scaling this can be, for example, 20px rather than the more common 16px. I've never found MS docu...
118, 390, 889, 5692
delphi, shell, system-tray, winapi
<h1>Best Icon size for displaying in the tray</h1> <p>I am working on a Delphi program which will display an icon on the "tray". I am doing it "the hard way" (using the Shell_NotifyIcon api, etc and not a component, for reasons outside the point here). It's working fine but sometimes it seems like the icon is a little ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,647
bash
# Best Icon size for displaying in the tray I am working on a Delphi program which will display an icon on the "tray". I am doing it "the hard way" (using the Shell_NotifyIcon api, etc and not a component, for reasons outside the point here). It's working fine but sometimes it seems like the icon is a little "blurry" ...
You should be using 32bpp icons with partial transparency for best effect. The icon uses the small system size. Get this by calling `GetSystemMetrics` passing `SM_CXSMICON`. If you use font scaling this can be, for example, 20px rather than the more common 16px. I've never found MS documentation for this fact but you ...
5230886
Please explain set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) line of Powershell Script
13
2011-03-08 09:59:54
<p>After investigating how to create a zip file with Powershell I found the following very helpful <a href="http://blogs.msdn.com/b/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget.aspx" rel="noreferrer">link</a> which describes how to create a zip file using ...
4,006
336,426
2014-10-06 19:59:54
5,231,292
14
2011-03-08 10:36:24
236,131
2014-10-06 19:59:54
https://stackoverflow.com/q/5230886
https://stackoverflow.com/a/5231292
<p>By using <code>("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))</code> as the value to <code>set-Content</code>, we are simply adding the file header and creating a 0 byte <code>.zip</code> file.</p> <p>To understand this, you may want to read under the section file headers:</p> <ul> <li><a href="http://en.wikiped...
<p>By using <code>("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))</code> as the value to <code>set-Content</code>, we are simply adding the file header and creating a 0 byte <code>.zip</code> file.</p> <p>To understand this, you may want to read under the section file headers:</p> <ul> <li><a href="http://en.wikiped...
526, 881
powershell, zip
<h1>Please explain set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) line of Powershell Script</h1> <p>After investigating how to create a zip file with Powershell I found the following very helpful <a href="http://blogs.msdn.com/b/daiken/archive/2007/02/12/compress-files-with-windows-powershell...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,648
bash
# Please explain set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) line of Powershell Script After investigating how to create a zip file with Powershell I found the following very helpful [link](http://blogs.msdn.com/b/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-packa...
By using `("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))` as the value to `set-Content`, we are simply adding the file header and creating a 0 byte `.zip` file. To understand this, you may want to read under the section file headers: - [Magic number (programming)](http://en.wikipedia.org/wiki/Magic_number_(programm...
2352380
How to get extension of a file in shell script
13
2010-02-28 19:45:26
<p>I am trying to get file extension for a file in shell script. But without any luck.</p> <p>The command I am using is </p> <pre><code>file_ext=${filename##*.} </code></pre> <p>and</p> <pre><code>file_ext = $filename |awk -F . '{if (NF&gt;1) {print $NF}}' </code></pre> <p>But both of the commands failed to put va...
33,130
197,125
2022-06-16 17:40:09
2,352,397
14
2010-02-28 19:50:38
258,267
2022-06-16 17:40:09
https://stackoverflow.com/q/2352380
https://stackoverflow.com/a/2352397
<p>Spaces hurt.</p> <p>Anyway you should do:</p> <pre><code>file_ext=$(echo $filename | awk -F . '{if (NF&gt;1) {print $NF}}') </code></pre> <p>[Edit] Better suggestion by Martin:</p> <pre><code>file_ext=$(printf '%s' &quot;$filename&quot; | awk -F . '{if (NF&gt;1) {print $NF}}') </code></pre> <p>That will store in <co...
<p>Spaces hurt.</p> <p>Anyway you should do:</p> <pre><code>file_ext=$(echo $filename | awk -F . '{if (NF&gt;1) {print $NF}}') </code></pre> <p>[Edit] Better suggestion by Martin:</p> <pre><code>file_ext=$(printf '%s' &quot;$filename&quot; | awk -F . '{if (NF&gt;1) {print $NF}}') </code></pre> <p>That will store in <co...
58, 390
linux, shell
<h1>How to get extension of a file in shell script</h1> <p>I am trying to get file extension for a file in shell script. But without any luck.</p> <p>The command I am using is </p> <pre><code>file_ext=${filename##*.} </code></pre> <p>and</p> <pre><code>file_ext = $filename |awk -F . '{if (NF&gt;1) {print $NF}}' </c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,649
bash
# How to get extension of a file in shell script I am trying to get file extension for a file in shell script. But without any luck. The command I am using is ``` file_ext=${filename##*.} ``` and ``` file_ext = $filename |awk -F . '{if (NF>1) {print $NF}}' ``` But both of the commands failed to put value in varia...
Spaces hurt. Anyway you should do: ``` file_ext=$(echo $filename | awk -F . '{if (NF>1) {print $NF}}') ``` [Edit] Better suggestion by Martin: ``` file_ext=$(printf '%s' "$filename" | awk -F . '{if (NF>1) {print $NF}}') ``` That will store in `$file_ext` the output of the command.
1846416
Using .NET library from PowerShell
13
2009-12-04 11:34:15
<p>I have a PowerShell snap-in for manipulating a database. The snap-in itself is just a wrapper for the main library implemented in a separate .NET DLL all written in c#.</p> <p>I have registered both the snap-in and the implementation DLLs with the GAC using installutil.exe</p> <p>Whilst the snap-in works fine in P...
15,546
42,109
2009-12-05 05:13:12
1,846,434
14
2009-12-04 11:37:44
63,627
2009-12-04 11:37:44
https://stackoverflow.com/q/1846416
https://stackoverflow.com/a/1846434
<pre><code>Add-Type -AssemblyName "Your.Assembly.Name" </code></pre> <p>Kindness,</p> <p>Dan</p>
<pre><code>Add-Type -AssemblyName "Your.Assembly.Name" </code></pre> <p>Kindness,</p> <p>Dan</p>
526
powershell
<h1>Using .NET library from PowerShell</h1> <p>I have a PowerShell snap-in for manipulating a database. The snap-in itself is just a wrapper for the main library implemented in a separate .NET DLL all written in c#.</p> <p>I have registered both the snap-in and the implementation DLLs with the GAC using installutil.ex...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,650
bash
# Using .NET library from PowerShell I have a PowerShell snap-in for manipulating a database. The snap-in itself is just a wrapper for the main library implemented in a separate .NET DLL all written in c#. I have registered both the snap-in and the implementation DLLs with the GAC using installutil.exe Whilst the sn...
``` Add-Type -AssemblyName "Your.Assembly.Name" ``` Kindness, Dan
683776
How to use "xargs" properly when argument list is too long
13
2009-03-25 22:28:25
<p>Can someone please give me an example of using xargs on the below operation?</p> <pre><code>tar c $dir/temp/*.parse\ | lzma -9 &gt; $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma </code></pre> <p>I get the error from bash "<b>/bin/tar: Argument list too long</b>"</p> <p>Particularily I am trying to do LZMA ...
22,324
82,856
2009-03-25 23:15:36
683,808
14
2009-03-25 22:38:52
40,342
2009-03-25 22:38:52
https://stackoverflow.com/q/683776
https://stackoverflow.com/a/683808
<p>Expanding on CristopheDs answer and assuming you're using bash:</p> <pre><code>tar c --files-from &lt;(find $dir/temp -maxdepth 1 -name "*.parse") | lzma -9 &gt; $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma </code></pre> <p>The reason <code>xargs</code> doesn't help you here is that it will do multiple invocat...
<p>Expanding on CristopheDs answer and assuming you're using bash:</p> <pre><code>tar c --files-from &lt;(find $dir/temp -maxdepth 1 -name "*.parse") | lzma -9 &gt; $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma </code></pre> <p>The reason <code>xargs</code> doesn't help you here is that it will do multiple invocat...
34, 58, 387
bash, linux, unix
<h1>How to use "xargs" properly when argument list is too long</h1> <p>Can someone please give me an example of using xargs on the below operation?</p> <pre><code>tar c $dir/temp/*.parse\ | lzma -9 &gt; $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma </code></pre> <p>I get the error from bash "<b>/bin/tar: Argum...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,651
bash
# How to use "xargs" properly when argument list is too long Can someone please give me an example of using xargs on the below operation? ``` tar c $dir/temp/*.parse\ | lzma -9 > $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma ``` I get the error from bash "**/bin/tar: Argument list too long**" Particularily I...
Expanding on CristopheDs answer and assuming you're using bash: ``` tar c --files-from <(find $dir/temp -maxdepth 1 -name "*.parse") | lzma -9 > $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma ``` The reason `xargs` doesn't help you here is that it will do multiple invocations until all arguments have been used. Thi...
53823386
Programmatically get number of stashes in git
12
2018-12-17 21:42:15
<p>My "oldest" stash in a project is something I need to re-apply from time to time. (Yes, there's a reason for this, and yes, it's terrible, but fixing the underlying issue would be more time-consuming than just using <code>git stash</code> for now.)</p> <p>However, the oldest stash has the highest number in the list...
2,544
1,858,225
2024-10-22 15:42:49
53,823,705
14
2018-12-17 22:09:56
947,357
2024-10-22 15:42:49
https://stackoverflow.com/q/53823386
https://stackoverflow.com/a/53823705
<p>Given a small sample repository with this stashes:</p> <pre><code>&gt; git stash list stash@{0}: WIP on foo/master: d9184b5 ... stash@{1}: WIP on foo/master: d9184b5 ... </code></pre> <p>this gives you the <em>number</em> of stash entries:</p> <pre><code>&gt; git rev-list --walk-reflogs --ignore-missing --count refs...
<p>Given a small sample repository with this stashes:</p> <pre><code>&gt; git stash list stash@{0}: WIP on foo/master: d9184b5 ... stash@{1}: WIP on foo/master: d9184b5 ... </code></pre> <p>this gives you the <em>number</em> of stash entries:</p> <pre><code>&gt; git rev-list --walk-reflogs --ignore-missing --count refs...
119, 390, 13091
git, git-stash, shell
<h1>Programmatically get number of stashes in git</h1> <p>My "oldest" stash in a project is something I need to re-apply from time to time. (Yes, there's a reason for this, and yes, it's terrible, but fixing the underlying issue would be more time-consuming than just using <code>git stash</code> for now.)</p> <p>Howev...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,652
bash
# Programmatically get number of stashes in git My "oldest" stash in a project is something I need to re-apply from time to time. (Yes, there's a reason for this, and yes, it's terrible, but fixing the underlying issue would be more time-consuming than just using `git stash` for now.) However, the oldest stash has th...
Given a small sample repository with this stashes: ``` > git stash list stash@{0}: WIP on foo/master: d9184b5 ... stash@{1}: WIP on foo/master: d9184b5 ... ``` this gives you the *number* of stash entries: ``` > git rev-list --walk-reflogs --ignore-missing --count refs/stash 2 ``` But you have to substract `1` to g...
51522337
Putting an array value into a string in powershell
12
2018-07-25 15:11:32
<p>I was having difficulty understanding how String values work with arrays in powershell. I wanted to know the correct syntax for placing an array into a string. Currently, this is what I am trying. The square brackets seem to be registered as part of the string rather than the variable.</p> <pre><code>$array = @(2,3,...
10,662
10,105,735
2023-12-09 22:16:02
51,522,395
14
2018-07-25 15:14:40
1,847,883
2018-07-25 19:45:52
https://stackoverflow.com/q/51522337
https://stackoverflow.com/a/51522395
<p>The <code>[2]</code> is being read as a string. Use <code>$($array[2])</code> in order to run that part as powershell.</p> <pre><code>$array = @(2,3,5) "I have $($array[2]) apples" </code></pre> <p>This outputs <code>I have 5 apples</code>.</p> <p>In the comments you asked how to do a for loop for this.</p> <p>...
<p>The <code>[2]</code> is being read as a string. Use <code>$($array[2])</code> in order to run that part as powershell.</p> <pre><code>$array = @(2,3,5) "I have $($array[2]) apples" </code></pre> <p>This outputs <code>I have 5 apples</code>.</p> <p>In the comments you asked how to do a for loop for this.</p> <p>...
114, 139, 526
arrays, powershell, string
<h1>Putting an array value into a string in powershell</h1> <p>I was having difficulty understanding how String values work with arrays in powershell. I wanted to know the correct syntax for placing an array into a string. Currently, this is what I am trying. The square brackets seem to be registered as part of the str...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,653
bash
# Putting an array value into a string in powershell I was having difficulty understanding how String values work with arrays in powershell. I wanted to know the correct syntax for placing an array into a string. Currently, this is what I am trying. The square brackets seem to be registered as part of the string rathe...
The `[2]` is being read as a string. Use `$($array[2])` in order to run that part as powershell. ``` $array = @(2,3,5) "I have $($array[2]) apples" ``` This outputs `I have 5 apples`. In the comments you asked how to do a for loop for this. In powershell you should pipe whenever you can, the pipe command is `|` `...
50391334
How to include dashes in the format string of bash printf?
12
2018-05-17 12:20:13
<p>I'm trying to concatenate strings in bash using <code>printf</code> by following <a href="https://linuxconfig.org/bash-printf-syntax-basics-with-examples" rel="noreferrer">the examples here</a>:</p> <pre><code>$ printf "%s " "hello printf" "in" "bash script" </code></pre> <p>The above works. But when I try to add ...
4,747
4,196,578
2018-05-17 12:47:30
50,391,361
14
2018-05-17 12:21:43
5,291,015
2018-05-17 12:47:30
https://stackoverflow.com/q/50391334
https://stackoverflow.com/a/50391361
<p>Always specify end of command line flags when using strings involving <code>--</code>. In general the shell commands need to know where their positional argument start at. So by forcing <code>--</code> after <code>printf</code> we let it know that the subsequent arguments are to be interpreted as its arguments. At t...
<p>Always specify end of command line flags when using strings involving <code>--</code>. In general the shell commands need to know where their positional argument start at. So by forcing <code>--</code> after <code>printf</code> we let it know that the subsequent arguments are to be interpreted as its arguments. At t...
387, 1156
bash, printf
<h1>How to include dashes in the format string of bash printf?</h1> <p>I'm trying to concatenate strings in bash using <code>printf</code> by following <a href="https://linuxconfig.org/bash-printf-syntax-basics-with-examples" rel="noreferrer">the examples here</a>:</p> <pre><code>$ printf "%s " "hello printf" "in" "ba...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,654
bash
# How to include dashes in the format string of bash printf? I'm trying to concatenate strings in bash using `printf` by following [the examples here](https://linuxconfig.org/bash-printf-syntax-basics-with-examples): ``` $ printf "%s " "hello printf" "in" "bash script" ``` The above works. But when I try to add to t...
Always specify end of command line flags when using strings involving `--`. In general the shell commands need to know where their positional argument start at. So by forcing `--` after `printf` we let it know that the subsequent arguments are to be interpreted as its arguments. At this point, afterwards using `--` wil...
49540457
sed gives error with unterminated substitute in regular expression
12
2018-03-28 17:11:14
<p>I trying to substitute string "x.x.x.x" in a file and output the results to another file. It is giving me error unterminated substitute in regular expression</p> <p>here is the code</p> <pre><code>sed 's/x.x.x.x/'$bigip_management_ip'/g' temp.tt &gt;&gt; variables.tf sed: 1: "s/x.x.x.x/": unterminated substitute i...
51,297
7,119,673
2021-03-30 04:15:56
49,540,617
14
2018-03-28 17:21:08
1,899,640
2018-03-28 17:21:08
https://stackoverflow.com/q/49540457
https://stackoverflow.com/a/49540617
<p>Here's a MCVE for your problem:</p> <pre><code>bigip_management_ip=" 54.83.174.153" sed 's/x.x.x.x/'$bigip_management_ip'/g' </code></pre> <p>When executed on macOS, you get:</p> <pre><code>sed: 1: "s/x.x.x.x/": unterminated substitute in regular expression </code></pre> <p>The problem is the leading space in th...
<p>Here's a MCVE for your problem:</p> <pre><code>bigip_management_ip=" 54.83.174.153" sed 's/x.x.x.x/'$bigip_management_ip'/g' </code></pre> <p>When executed on macOS, you get:</p> <pre><code>sed: 1: "s/x.x.x.x/": unterminated substitute in regular expression </code></pre> <p>The problem is the leading space in th...
390, 990, 5282
awk, sed, shell
<h1>sed gives error with unterminated substitute in regular expression</h1> <p>I trying to substitute string "x.x.x.x" in a file and output the results to another file. It is giving me error unterminated substitute in regular expression</p> <p>here is the code</p> <pre><code>sed 's/x.x.x.x/'$bigip_management_ip'/g' t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,655
bash
# sed gives error with unterminated substitute in regular expression I trying to substitute string "x.x.x.x" in a file and output the results to another file. It is giving me error unterminated substitute in regular expression here is the code ``` sed 's/x.x.x.x/'$bigip_management_ip'/g' temp.tt >> variables.tf sed:...
Here's a MCVE for your problem: ``` bigip_management_ip=" 54.83.174.153" sed 's/x.x.x.x/'$bigip_management_ip'/g' ``` When executed on macOS, you get: ``` sed: 1: "s/x.x.x.x/": unterminated substitute in regular expression ``` The problem is the leading space in the variable causing word splitting due to a lack of ...
47702490
ShellCheck warning: "Iterating over ls output is fragile. Use globs. [SC2045]"
12
2017-12-07 19:34:14
<p>I am getting a ShellCheck warning [SC2045] for the second line in the code below. Is it fine to ignore it as I am making sure the directory is not empty before I try the last <code>ls</code>?</p> <pre><code> if [ "$(ls -A "$retryDir")" ] ; then for thisRetryFile in $(ls "$retryDir"/*.tar.gz) ; do scp -...
10,367
472,427
2018-01-04 22:27:53
47,702,732
14
2017-12-07 19:50:31
641,955
2017-12-07 20:40:05
https://stackoverflow.com/q/47702490
https://stackoverflow.com/a/47702732
<p>Use the loop with a glob, and also set <code>nullglob</code> to avoid executing <code>scp</code> in case the pattern doesn't match anything. And you don't need the outer <code>if</code> condition either, since the <code>for</code> with <code>nullglob</code> effectively takes care of that:</p> <pre><code>shopt -s nu...
<p>Use the loop with a glob, and also set <code>nullglob</code> to avoid executing <code>scp</code> in case the pattern doesn't match anything. And you don't need the outer <code>if</code> condition either, since the <code>for</code> with <code>nullglob</code> effectively takes care of that:</p> <pre><code>shopt -s nu...
387, 3589, 117067
bash, ls, shellcheck
<h1>ShellCheck warning: "Iterating over ls output is fragile. Use globs. [SC2045]"</h1> <p>I am getting a ShellCheck warning [SC2045] for the second line in the code below. Is it fine to ignore it as I am making sure the directory is not empty before I try the last <code>ls</code>?</p> <pre><code> if [ "$(ls -A "$retr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,656
bash
# ShellCheck warning: "Iterating over ls output is fragile. Use globs. [SC2045]" I am getting a ShellCheck warning [SC2045] for the second line in the code below. Is it fine to ignore it as I am making sure the directory is not empty before I try the last `ls`? ``` if [ "$(ls -A "$retryDir")" ] ; then for thisR...
Use the loop with a glob, and also set `nullglob` to avoid executing `scp` in case the pattern doesn't match anything. And you don't need the outer `if` condition either, since the `for` with `nullglob` effectively takes care of that: ``` shopt -s nullglob for thisRetryFile in "$retryDir"/*.tar.gz; do scp -o Conn...
44004052
Generate Self-signed certificate with Root CA Signer
12
2017-05-16 14:18:29
<p>Scenario: I am using PowerShell on <em>Windows Server 2012r2</em> to generate a Root certificate and want to use that to sign a newly created Intermediate and Web certificate in dynamic generated (and destroyed) dev/test environments. The scripts are deployed remotely, and the intent is to keep it pure PowerShell if...
29,849
1,010,036
2021-09-05 08:53:27
44,057,365
14
2017-05-18 20:39:27
1,010,036
2017-11-28 06:28:56
https://stackoverflow.com/q/44004052
https://stackoverflow.com/a/44057365
<p>The ultimate solution in my case, avoiding makecert and openssl was to use Powershell and BouncyCastle. I forked the PSBouncyCastle repo from <a href="https://github.com/rlipscombe/PSBouncyCastle" rel="noreferrer">PSBouncyCastle</a> by RLipscombe and pushed 1.8.1 Bouncy Castle in. My forked version is the one I've u...
<p>The ultimate solution in my case, avoiding makecert and openssl was to use Powershell and BouncyCastle. I forked the PSBouncyCastle repo from <a href="https://github.com/rlipscombe/PSBouncyCastle" rel="noreferrer">PSBouncyCastle</a> by RLipscombe and pushed 1.8.1 Bouncy Castle in. My forked version is the one I've u...
526, 74269, 96533
powershell, sql-server-2012, windows-server-2012-r2
<h1>Generate Self-signed certificate with Root CA Signer</h1> <p>Scenario: I am using PowerShell on <em>Windows Server 2012r2</em> to generate a Root certificate and want to use that to sign a newly created Intermediate and Web certificate in dynamic generated (and destroyed) dev/test environments. The scripts are depl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,657
bash
# Generate Self-signed certificate with Root CA Signer Scenario: I am using PowerShell on *Windows Server 2012r2* to generate a Root certificate and want to use that to sign a newly created Intermediate and Web certificate in dynamic generated (and destroyed) dev/test environments. The scripts are deployed remotely, a...
The ultimate solution in my case, avoiding makecert and openssl was to use Powershell and BouncyCastle. I forked the PSBouncyCastle repo from [PSBouncyCastle](https://github.com/rlipscombe/PSBouncyCastle) by RLipscombe and pushed 1.8.1 Bouncy Castle in. My forked version is the one I've used for the script, the fork re...
39913481
Powershell: naming convention for bool functions
12
2016-10-07 09:05:11
<p>I am having problem with finding any appropriate naming convention in PowerShell (verb-noun) that would reflect programming:</p> <pre><code>IsApple() { return Fruit.Type == Fruits.Apple } </code></pre> <p><strong>Is there such a convention in PS?</strong></p> <p>I did not find any cmdlets having 'is' or 'has'...
3,269
4,744,069
2019-11-25 20:44:45
39,913,953
14
2016-10-07 09:29:58
978,511
2019-11-25 20:44:45
https://stackoverflow.com/q/39913481
https://stackoverflow.com/a/39913953
<p>In PowerShell, there're approved verbs for a function. They are different from version to version, but you can get yours using the <code>Get-Verb</code> cmdlet.</p> <p>As for your case, I could think of <code>Assert-IsApple</code> or <code>Test-IsApple</code></p> <p>For reference, here is the <a href="https://lear...
<p>In PowerShell, there're approved verbs for a function. They are different from version to version, but you can get yours using the <code>Get-Verb</code> cmdlet.</p> <p>As for your case, I could think of <code>Assert-IsApple</code> or <code>Test-IsApple</code></p> <p>For reference, here is the <a href="https://lear...
526, 2848, 7028
boolean, naming-conventions, powershell
<h1>Powershell: naming convention for bool functions</h1> <p>I am having problem with finding any appropriate naming convention in PowerShell (verb-noun) that would reflect programming:</p> <pre><code>IsApple() { return Fruit.Type == Fruits.Apple } </code></pre> <p><strong>Is there such a convention in PS?</stron...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,658
bash
# Powershell: naming convention for bool functions I am having problem with finding any appropriate naming convention in PowerShell (verb-noun) that would reflect programming: ``` IsApple() { return Fruit.Type == Fruits.Apple } ``` **Is there such a convention in PS?** I did not find any cmdlets having 'is' or ...
In PowerShell, there're approved verbs for a function. They are different from version to version, but you can get yours using the `Get-Verb` cmdlet. As for your case, I could think of `Assert-IsApple` or `Test-IsApple` For reference, here is the [link to the official list of verbs for PowerShell](https://learn.micro...
35022078
How do I output ASCII Art to console?
12
2016-01-26 19:20:27
<p>I would like to spice up my scripts with some ASCII art to be displayed on completion of a process.</p> <p>I have 2 thoughts on how to output ASCII art to console. Hopefully someone who knows more than I do can direct us to what the command is and what method is 'Better'.</p> <ol> <li><p>Output a multi-line <code...
31,871
5,022,269
2018-05-10 13:10:52
35,022,366
14
2016-01-26 19:35:11
3,829,407
2018-05-10 13:10:52
https://stackoverflow.com/q/35022078
https://stackoverflow.com/a/35022366
<p>Just use a newline delimited string, here-string or <code>Get-Content -Raw</code> if you have a source file. Both will give you a single multiline string without fuss. One thing the here-string is good for is not having to worry about the quotes you use (which could be a distinct possibility with ASCII art). An exam...
<p>Just use a newline delimited string, here-string or <code>Get-Content -Raw</code> if you have a source file. Both will give you a single multiline string without fuss. One thing the here-string is good for is not having to worry about the quotes you use (which could be a distinct possibility with ASCII art). An exam...
488, 526, 1843
ascii, console, powershell
<h1>How do I output ASCII Art to console?</h1> <p>I would like to spice up my scripts with some ASCII art to be displayed on completion of a process.</p> <p>I have 2 thoughts on how to output ASCII art to console. Hopefully someone who knows more than I do can direct us to what the command is and what method is 'Bett...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,659
bash
# How do I output ASCII Art to console? I would like to spice up my scripts with some ASCII art to be displayed on completion of a process. I have 2 thoughts on how to output ASCII art to console. Hopefully someone who knows more than I do can direct us to what the command is and what method is 'Better'. 1. Output a...
Just use a newline delimited string, here-string or `Get-Content -Raw` if you have a source file. Both will give you a single multiline string without fuss. One thing the here-string is good for is not having to worry about the quotes you use (which could be a distinct possibility with ASCII art). An example using a he...
32878146
Too many open files error while running awk command
12
2015-10-01 01:35:29
<p>I am trying to split a big file based on a pattern. I am using awk command for this. After creating certain number of files it gives error: Too many open files. </p> <p>Command is:</p> <pre><code>awk '/pattern here/{i++}{print &gt; "file"i}' /input file </code></pre> <p>Can someone tell me how to close these file...
6,968
4,695,617
2021-04-08 14:35:25
32,878,168
14
2015-10-01 01:39:07
3,030,305
2021-04-08 14:35:25
https://stackoverflow.com/q/32878146
https://stackoverflow.com/a/32878168
<p>Before starting on the next file, close the previous one:</p> <pre class="lang-sh prettyprint-override"><code> awk '/pattern here/{close(&quot;file&quot;i); i++}{print &gt; &quot;file&quot;i}' InputFile </code></pre>
<p>Before starting on the next file, close the previous one:</p> <pre class="lang-sh prettyprint-override"><code> awk '/pattern here/{close(&quot;file&quot;i); i++}{print &gt; &quot;file&quot;i}' InputFile </code></pre>
58, 390, 990
awk, linux, shell
<h1>Too many open files error while running awk command</h1> <p>I am trying to split a big file based on a pattern. I am using awk command for this. After creating certain number of files it gives error: Too many open files. </p> <p>Command is:</p> <pre><code>awk '/pattern here/{i++}{print &gt; "file"i}' /input file ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,660
bash
# Too many open files error while running awk command I am trying to split a big file based on a pattern. I am using awk command for this. After creating certain number of files it gives error: Too many open files. Command is: ``` awk '/pattern here/{i++}{print > "file"i}' /input file ``` Can someone tell me how to...
Before starting on the next file, close the previous one: ``` awk '/pattern here/{close("file"i); i++}{print > "file"i}' InputFile ```
30642883
How to properly close Internet Explorer when launched from PowerShell?
12
2015-06-04 11:39:25
<p>There was a set of recently asked questions about doing something with Internet Explorer via PowerShell. All of them contain codes to launch IE from PowerShell as an object, via <code>$ie=new-object -comobject InternetExplorer.Application</code>. The problem is, the proper way of <strong>closing</strong> IE that con...
31,826
1,627,055
2021-05-23 09:59:49
30,643,155
14
2015-06-04 11:53:30
1,630,171
2017-07-12 08:00:11
https://stackoverflow.com/q/30642883
https://stackoverflow.com/a/30643155
<p>Simply calling the <code>Quit()</code> method should normally suffice for gracefully terminating Internet Explorer processes, regardless of whether they were created by running <code>iexplore.exe</code> or by instantiating a COM object in PowerShell.</p> <p>Demonstration:</p> <pre> PS C:\> <b>$env:PROCESSOR_ARCHIT...
<p>Simply calling the <code>Quit()</code> method should normally suffice for gracefully terminating Internet Explorer processes, regardless of whether they were created by running <code>iexplore.exe</code> or by instantiating a COM object in PowerShell.</p> <p>Demonstration:</p> <pre> PS C:\> <b>$env:PROCESSOR_ARCHIT...
162, 526, 1189
com, internet-explorer, powershell
<h1>How to properly close Internet Explorer when launched from PowerShell?</h1> <p>There was a set of recently asked questions about doing something with Internet Explorer via PowerShell. All of them contain codes to launch IE from PowerShell as an object, via <code>$ie=new-object -comobject InternetExplorer.Applicatio...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,661
bash
# How to properly close Internet Explorer when launched from PowerShell? There was a set of recently asked questions about doing something with Internet Explorer via PowerShell. All of them contain codes to launch IE from PowerShell as an object, via `$ie=new-object -comobject InternetExplorer.Application`. The proble...
Simply calling the `Quit()` method should normally suffice for gracefully terminating Internet Explorer processes, regardless of whether they were created by running `iexplore.exe` or by instantiating a COM object in PowerShell. Demonstration: ``` PS C:\> $env:PROCESSOR_ARCHITECTURE AMD64 PS C:\> (Get-WmiObject -Clas...
29783092
regexp to match java package name
12
2015-04-21 21:05:02
<p>I want to check if arguments passed in stdin to see if they conform to a valid java package name. The regex I have is not working properly. With the following code passing in com.example.package I receive the error message. I'm not sure what is wrong with my regex?</p> <pre><code> regex="/^[a-z][a-z0-9_]*(\.[a-z0-9...
10,418
2,827,885
2022-06-22 16:00:57
29,783,266
14
2015-04-21 21:16:12
1,404,992
2015-04-21 21:22:30
https://stackoverflow.com/q/29783092
https://stackoverflow.com/a/29783266
<p>You are pretty close to the correct solution. Just tweak the regex a bit (also consider @fede's simpler regex) and set the <code>nocasematch</code> option for case insensitive matching. For example:</p> <pre><code>regex='^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$' shopt -s nocasematch if ! [[ $1 =~ $regex ]]; then ...
<p>You are pretty close to the correct solution. Just tweak the regex a bit (also consider @fede's simpler regex) and set the <code>nocasematch</code> option for case insensitive matching. For example:</p> <pre><code>regex='^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$' shopt -s nocasematch if ! [[ $1 =~ $regex ]]; then ...
18, 387
bash, regex
<h1>regexp to match java package name</h1> <p>I want to check if arguments passed in stdin to see if they conform to a valid java package name. The regex I have is not working properly. With the following code passing in com.example.package I receive the error message. I'm not sure what is wrong with my regex?</p> <pr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,662
bash
# regexp to match java package name I want to check if arguments passed in stdin to see if they conform to a valid java package name. The regex I have is not working properly. With the following code passing in com.example.package I receive the error message. I'm not sure what is wrong with my regex? ``` regex="/^[a...
You are pretty close to the correct solution. Just tweak the regex a bit (also consider @fede's simpler regex) and set the `nocasematch` option for case insensitive matching. For example: ``` regex='^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$' shopt -s nocasematch if ! [[ $1 =~ $regex ]]; then exit 2 fi shopt -u noca...
29081531
Shell script print line number when it errors out
12
2015-03-16 16:06:16
<p>I have been looking for a way to print the line number inside the shell script when it errors out. </p> <p>I came across '-x' option, which prints the line when running the shell script, but this is not exactly what I want. Maybe I could do $LINENO before every exit code? Is there a cleaner way to do it?</p> <p>I...
5,312
2,441,441
2015-03-16 16:15:38
29,081,598
14
2015-03-16 16:08:52
14,122
2015-03-16 16:15:38
https://stackoverflow.com/q/29081531
https://stackoverflow.com/a/29081598
<p>Using</p> <pre><code>PS4=':$LINENO+' </code></pre> <p>will add line number to the output of <code>set -x</code>.</p> <hr> <p>If you <em>only</em> want to print that on errors, there's some risk of running into bugs in recent interpreters. However, you can try the following (first given in <A HREF="http://stackov...
<p>Using</p> <pre><code>PS4=':$LINENO+' </code></pre> <p>will add line number to the output of <code>set -x</code>.</p> <hr> <p>If you <em>only</em> want to print that on errors, there's some risk of running into bugs in recent interpreters. However, you can try the following (first given in <A HREF="http://stackov...
387, 390, 531
bash, scripting, shell
<h1>Shell script print line number when it errors out</h1> <p>I have been looking for a way to print the line number inside the shell script when it errors out. </p> <p>I came across '-x' option, which prints the line when running the shell script, but this is not exactly what I want. Maybe I could do $LINENO before ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,663
bash
# Shell script print line number when it errors out I have been looking for a way to print the line number inside the shell script when it errors out. I came across '-x' option, which prints the line when running the shell script, but this is not exactly what I want. Maybe I could do $LINENO before every exit code? I...
Using ``` PS4=':$LINENO+' ``` will add line number to the output of `set -x`. --- If you *only* want to print that on errors, there's some risk of running into bugs in recent interpreters. However, you can try the following (first given in [this previous answer](http://stackoverflow.com/questions/64786/error-handli...
28290635
PowerShell passing two arrays by reference to a function
12
2015-02-03 03:00:24
<p>At the moment I am trying to pass in two array items by reference to a function I have written which loads data into those arrays. However, once this function loses scope the arrays appear as blank.</p> <p>If I use the ref keyword to pass them into the function the first array loads up correctly. However, the secon...
11,536
1,367,229
2018-12-28 19:39:20
28,291,054
14
2015-02-03 03:49:56
284,111
2018-12-28 19:39:20
https://stackoverflow.com/q/28290635
https://stackoverflow.com/a/28291054
<p>I modified your example to work:</p> <pre><code>$logConfigPath = "C:\Testing\Configuration\config.xml" #### VARIABLES RELATING TO THE LOG FILE # Contains the log path and log file mask $logPaths = @() $logFileMasks = @() function LoadLogTailerConfig($logConfigPath, [ref]$logPaths, [ref]$logFileMasks) { Writ...
<p>I modified your example to work:</p> <pre><code>$logConfigPath = "C:\Testing\Configuration\config.xml" #### VARIABLES RELATING TO THE LOG FILE # Contains the log path and log file mask $logPaths = @() $logFileMasks = @() function LoadLogTailerConfig($logConfigPath, [ref]$logPaths, [ref]$logFileMasks) { Writ...
114, 526, 11658
arrays, pass-by-reference, powershell
<h1>PowerShell passing two arrays by reference to a function</h1> <p>At the moment I am trying to pass in two array items by reference to a function I have written which loads data into those arrays. However, once this function loses scope the arrays appear as blank.</p> <p>If I use the ref keyword to pass them into t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,664
bash
# PowerShell passing two arrays by reference to a function At the moment I am trying to pass in two array items by reference to a function I have written which loads data into those arrays. However, once this function loses scope the arrays appear as blank. If I use the ref keyword to pass them into the function the ...
I modified your example to work: ``` $logConfigPath = "C:\Testing\Configuration\config.xml" #### VARIABLES RELATING TO THE LOG FILE # Contains the log path and log file mask $logPaths = @() $logFileMasks = @() function LoadLogTailerConfig($logConfigPath, [ref]$logPaths, [ref]$logFileMasks) { Write-Debug "Loadi...
25273403
Windows Powershell: Shortcut for change directory
12
2014-08-12 20:21:27
<p>I just started using Windows Powershell and one major problem I've run into is when I start it, it starts me off in this directory:</p> <pre><code>C:\Users\Username </code></pre> <p>However, the directory I usually need to navigate to is in something like:</p> <pre><code>C:\Users\Username\Dropbox\Websites\2014\Pr...
28,361
1,219,562
2024-11-26 19:38:48
25,274,911
14
2014-08-12 22:08:33
3,905,079
2014-08-12 22:08:33
https://stackoverflow.com/q/25273403
https://stackoverflow.com/a/25274911
<p>Run this in powershell:</p> <pre class="lang-powershell prettyprint-override"><code>start notepad $profile </code></pre> <p>That will open up your profile in notepad (notepad will prompt you to create it if it doesn't exist).</p> <p>Any code you write in this <code>.ps1</code> file will be executed when powershel...
<p>Run this in powershell:</p> <pre class="lang-powershell prettyprint-override"><code>start notepad $profile </code></pre> <p>That will open up your profile in notepad (notepad will prompt you to create it if it doesn't exist).</p> <p>Any code you write in this <code>.ps1</code> file will be executed when powershel...
390, 526, 1231, 11225
command-line, command-line-interface, powershell, shell
<h1>Windows Powershell: Shortcut for change directory</h1> <p>I just started using Windows Powershell and one major problem I've run into is when I start it, it starts me off in this directory:</p> <pre><code>C:\Users\Username </code></pre> <p>However, the directory I usually need to navigate to is in something like:...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,665
bash
# Windows Powershell: Shortcut for change directory I just started using Windows Powershell and one major problem I've run into is when I start it, it starts me off in this directory: ``` C:\Users\Username ``` However, the directory I usually need to navigate to is in something like: ``` C:\Users\Username\Dropbox\W...
Run this in powershell: ``` start notepad $profile ``` That will open up your profile in notepad (notepad will prompt you to create it if it doesn't exist). Any code you write in this `.ps1` file will be executed when powershell starts. You can also set a system environment variable, like if you were to set `MYPSPA...