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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
58991123 | Pipeline doesn't seem to have any effect in Bash | 6 | 2019-11-22 09:24:47 | <p>Anyone can explain me why this</p>
<pre><code>python -V | awk '{print $2}'
</code></pre>
<p>returns this</p>
<pre><code>Python 2.7.5
</code></pre>
<p>instead of </p>
<pre><code>2.7.5
</code></pre>
<p>What to do to return only the version number without "Python " ?</p>
| 231 | 1,806,799 | 2021-06-29 19:00:26 | 58,991,211 | 11 | 2019-11-22 09:29:33 | 4,177,009 | 2019-11-22 09:29:33 | https://stackoverflow.com/q/58991123 | https://stackoverflow.com/a/58991211 | <p>If you run</p>
<pre><code>python -V >/dev/null
</code></pre>
<p>you will notice that you still get output! Apparently, <code>python -V</code> prints its output to stderr, not to stdout.</p>
<p>In a bourne-like shell, this should work:</p>
<pre><code>python -V 2>&1 | awk '{print $2}'
</code></pre>
| <p>If you run</p> <pre><code>python -V >/dev/null </code></pre> <p>you will notice that you still get output! Apparently, <code>python -V</code> prints its output to stderr, not to stdout.</p> <p>In a bourne-like shell, this should work:</p> <pre><code>python -V 2>&1 | awk '{print $2}' </code></pre> | 16, 387 | bash, python | <h1>Pipeline doesn't seem to have any effect in Bash</h1>
<p>Anyone can explain me why this</p>
<pre><code>python -V | awk '{print $2}'
</code></pre>
<p>returns this</p>
<pre><code>Python 2.7.5
</code></pre>
<p>instead of </p>
<pre><code>2.7.5
</code></pre>
<p>What to do to return onl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,676 | bash | # Pipeline doesn't seem to have any effect in Bash
Anyone can explain me why this
```
python -V | awk '{print $2}'
```
returns this
```
Python 2.7.5
```
instead of
```
2.7.5
```
What to do to return only the version number without "Python " ? | If you run
```
python -V >/dev/null
```
you will notice that you still get output! Apparently, `python -V` prints its output to stderr, not to stdout.
In a bourne-like shell, this should work:
```
python -V 2>&1 | awk '{print $2}'
``` |
58268287 | How to lowercase Azure DevOps pipeline variables names | 6 | 2019-10-07 11:02:57 | <p>May you please suggest how to lowercase the environment name in Azure DevOps pipelines.</p>
<p><a href="https://i.sstatic.net/8fwJN.png" rel="noreferrer"><img src="https://i.sstatic.net/8fwJN.png" alt="enter image description here"></a></p>
<p>When environment name is "Test" I want account name to be <code>myprefi... | 15,105 | 2,586,213 | 2021-06-09 14:54:15 | 58,269,043 | 11 | 2019-10-07 11:53:03 | 7,409,220 | 2019-10-07 11:53:03 | https://stackoverflow.com/q/58268287 | https://stackoverflow.com/a/58269043 | <p>I don't think there is an option to do to lower when you use the task (like in your Azure CLI task), but you can add a small PowerShell script that does it before the Azure CLI task:</p>
<pre><code>$envName = "$(Release.EnvironmentName)"
$lower = $envName.ToLower()
Write-Host "##vso[task.setvariable variable=Releas... | <p>I don't think there is an option to do to lower when you use the task (like in your Azure CLI task), but you can add a small PowerShell script that does it before the Azure CLI task:</p> <pre><code>$envName = "$(Release.EnvironmentName)" $lower = $envName.ToLower() Write-Host "##vso[task.setvariable variable=Releas... | 390, 14158, 116537, 119596 | azure, azure-devops, azure-pipelines, shell | <h1>How to lowercase Azure DevOps pipeline variables names</h1>
<p>May you please suggest how to lowercase the environment name in Azure DevOps pipelines.</p>
<p><a href="https://i.sstatic.net/8fwJN.png" rel="noreferrer"><img src="https://i.sstatic.net/8fwJN.png" alt="enter image description here"></a></p>
<p>When en... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,678 | bash | # How to lowercase Azure DevOps pipeline variables names
May you please suggest how to lowercase the environment name in Azure DevOps pipelines.
[](https://i.sstatic.net/8fwJN.png)
When environment name is "Test" I want account name to be `myprefixtest`... | I don't think there is an option to do to lower when you use the task (like in your Azure CLI task), but you can add a small PowerShell script that does it before the Azure CLI task:
```
$envName = "$(Release.EnvironmentName)"
$lower = $envName.ToLower()
Write-Host "##vso[task.setvariable variable=Release.EnvironmentN... |
56442941 | Compare the software version number in PowerShell | 6 | 2019-06-04 11:26:33 | <p>I use PowerShell to install software, I need to compare the version number. Some software version numbers are divided into multiple sections, how to compare? Here's an example:</p>
<pre><code>$Old_ver=18.05
$New_ver=19.00
if ($New_ver -gt $Old_ver) {
Write-Output "You need to install a new version"
} elseif ($... | 4,053 | 9,080,922 | 2023-05-23 16:38:29 | 56,443,064 | 11 | 2019-06-04 11:34:56 | 1,630,171 | 2019-06-04 11:34:56 | https://stackoverflow.com/q/56442941 | https://stackoverflow.com/a/56443064 | <p>Define your version numbers as strings and cast them to <code>[version]</code> objects.</p>
<pre><code>[version]$Old_ver = '18.05'
[version]$New_ver = '19.00'
</code></pre>
| <p>Define your version numbers as strings and cast them to <code>[version]</code> objects.</p> <pre><code>[version]$Old_ver = '18.05' [version]$New_ver = '19.00' </code></pre> | 526 | powershell | <h1>Compare the software version number in PowerShell</h1>
<p>I use PowerShell to install software, I need to compare the version number. Some software version numbers are divided into multiple sections, how to compare? Here's an example:</p>
<pre><code>$Old_ver=18.05
$New_ver=19.00
if ($New_ver -gt $Old_ver) {
W... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,679 | bash | # Compare the software version number in PowerShell
I use PowerShell to install software, I need to compare the version number. Some software version numbers are divided into multiple sections, how to compare? Here's an example:
```
$Old_ver=18.05
$New_ver=19.00
if ($New_ver -gt $Old_ver) {
Write-Output "You nee... | Define your version numbers as strings and cast them to `[version]` objects.
```
[version]$Old_ver = '18.05'
[version]$New_ver = '19.00'
``` |
56402407 | How to Check if a SYSTEM environment variable exists? | 6 | 2019-05-31 22:37:20 | <p>There is USER Environment Variables, and SYSTEM environment variables. </p>
<p>How can i make this condition check ONLY for SYSTEM env variable if it exists?</p>
<pre><code>if (-not Test-Path 'env:VariableX ') {
"doesnt exist!"
}
</code></pre>
<p>this would not return anything if VariableX is defined as a ... | 9,478 | 8,397,835 | 2019-05-31 23:01:47 | 56,402,560 | 11 | 2019-05-31 23:01:47 | null | 2019-05-31 23:01:47 | https://stackoverflow.com/q/56402407 | https://stackoverflow.com/a/56402560 | <p>This would work:</p>
<pre class="lang-bsh prettyprint-override"><code>if (-not [Environment]::GetEnvironmentVariable('VariableX', 'Machine'))
{
"doesnt exist!"
}
</code></pre>
| <p>This would work:</p> <pre class="lang-bsh prettyprint-override"><code>if (-not [Environment]::GetEnvironmentVariable('VariableX', 'Machine')) { "doesnt exist!" } </code></pre> | 526 | powershell | <h1>How to Check if a SYSTEM environment variable exists?</h1>
<p>There is USER Environment Variables, and SYSTEM environment variables. </p>
<p>How can i make this condition check ONLY for SYSTEM env variable if it exists?</p>
<pre><code>if (-not Test-Path 'env:VariableX ') {
"doesnt exist!"
}
</code></pre>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,680 | bash | # How to Check if a SYSTEM environment variable exists?
There is USER Environment Variables, and SYSTEM environment variables.
How can i make this condition check ONLY for SYSTEM env variable if it exists?
```
if (-not Test-Path 'env:VariableX ') {
"doesnt exist!"
}
```
this would not return anything if Varia... | This would work:
```
if (-not [Environment]::GetEnvironmentVariable('VariableX', 'Machine'))
{
"doesnt exist!"
}
``` |
56199624 | windows core run command with elevated privileges | 6 | 2019-05-18 13:56:21 | <p>There are a few options for standard user to run as Administrator (or any another user), however, even when logged as Administrator, some functions requires to run 'elevated'. </p>
<p>On a windows gui, just right click a <code>.exe</code> and select <code>run as Administrator</code> or even elevate 'cmd' or 'powers... | 12,607 | 4,449,516 | 2024-01-06 23:48:14 | 56,199,970 | 11 | 2019-05-18 14:40:15 | 45,375 | 2024-01-06 23:48:14 | https://stackoverflow.com/q/56199624 | https://stackoverflow.com/a/56199970 | <p>Generally, to programmatically invoke an executable with elevation (Run as Administrator) on Windows, use the <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process" rel="nofollow noreferrer"><code>Start-Process</code></a> cmdlet with <code>-Verb RunAs</code>.</p>... | <p>Generally, to programmatically invoke an executable with elevation (Run as Administrator) on Windows, use the <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process" rel="nofollow noreferrer"><code>Start-Process</code></a> cmdlet with <code>-Verb RunAs</code>.</p>... | 64, 526, 2631, 5623, 130616 | administrator, cmd, powershell, powershell-core, windows | <h1>windows core run command with elevated privileges</h1>
<p>There are a few options for standard user to run as Administrator (or any another user), however, even when logged as Administrator, some functions requires to run 'elevated'. </p>
<p>On a windows gui, just right click a <code>.exe</code> and select <code>r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,681 | bash | # windows core run command with elevated privileges
There are a few options for standard user to run as Administrator (or any another user), however, even when logged as Administrator, some functions requires to run 'elevated'.
On a windows gui, just right click a `.exe` and select `run as Administrator` or even elev... | Generally, to programmatically invoke an executable with elevation (Run as Administrator) on Windows, use the [`Start-Process`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process) cmdlet with `-Verb RunAs`.
This applies equally to `pwsh.exe`, the PowerShell *Core* executa... |
54611960 | bash: no need to call popd after pushd at the end of a script? | 6 | 2019-02-09 23:41:58 | <p>I was going through some trouble to do some proper "pushd/popd cleanup" in my bash script. That is: if I did <code>pushd</code> a few times, I wanted to make sure to do the same number of <code>popd</code> before <code>exit</code>.</p>
<p>However, I noticed that the pushd/popd stack doesn't seem to be global.</p>
... | 5,102 | 3,914,111 | 2022-07-27 04:38:22 | 54,611,994 | 11 | 2019-02-09 23:46:02 | 9,288,200 | 2019-02-09 23:55:47 | https://stackoverflow.com/q/54611960 | https://stackoverflow.com/a/54611994 | <p>Directory stack is gone when the shell (interpreter of you script) exits. This is the same behavior you would get if you ran <code>/bin/bash</code> from your interactive shell. Did <code>pushd /tmp</code>. And then typed <code>exit</code>. The shell you are returning to is not affected by what happened inside that o... | <p>Directory stack is gone when the shell (interpreter of you script) exits. This is the same behavior you would get if you ran <code>/bin/bash</code> from your interactive shell. Did <code>pushd /tmp</code>. And then typed <code>exit</code>. The shell you are returning to is not affected by what happened inside that o... | 387, 390, 531, 1090, 117509 | bash, pushd, scripting, shell, stack | <h1>bash: no need to call popd after pushd at the end of a script?</h1>
<p>I was going through some trouble to do some proper "pushd/popd cleanup" in my bash script. That is: if I did <code>pushd</code> a few times, I wanted to make sure to do the same number of <code>popd</code> before <code>exit</code>.</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 | 11,682 | bash | # bash: no need to call popd after pushd at the end of a script?
I was going through some trouble to do some proper "pushd/popd cleanup" in my bash script. That is: if I did `pushd` a few times, I wanted to make sure to do the same number of `popd` before `exit`.
However, I noticed that the pushd/popd stack doesn't s... | Directory stack is gone when the shell (interpreter of you script) exits. This is the same behavior you would get if you ran `/bin/bash` from your interactive shell. Did `pushd /tmp`. And then typed `exit`. The shell you are returning to is not affected by what happened inside that other `bash` process.
However, in a ... |
54358297 | Named argument for fish function with argparse | 6 | 2019-01-25 02:43:48 | <p>The fish <code>function</code> builtin has the option <code>-a/--argument-names</code> which allows binding an argument to a name.</p>
<p>Is it still possible to do this while also using the <code>argparse</code> builtin? If so, how?</p>
| 3,479 | 4,063,725 | 2019-01-25 20:38:38 | 54,372,435 | 11 | 2019-01-25 20:38:38 | 4,276,647 | 2019-01-25 20:38:38 | https://stackoverflow.com/q/54358297 | https://stackoverflow.com/a/54372435 | <p>I designed and implemented <code>argparse</code>. Yes, technically you can use the <code>--argument</code> flag and <code>argparse</code> in the same function but doing so makes no sense. The <code>--argument</code> option operates completely independently of <code>argparse</code> and has no knowledge of flags. Crea... | <p>I designed and implemented <code>argparse</code>. Yes, technically you can use the <code>--argument</code> flag and <code>argparse</code> in the same function but doing so makes no sense. The <code>--argument</code> option operates completely independently of <code>argparse</code> and has no knowledge of flags. Crea... | 390, 1357, 2313, 55824 | arguments, fish, parsing, shell | <h1>Named argument for fish function with argparse</h1>
<p>The fish <code>function</code> builtin has the option <code>-a/--argument-names</code> which allows binding an argument to a name.</p>
<p>Is it still possible to do this while also using the <code>argparse</code> builtin? If so, how?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,683 | bash | # Named argument for fish function with argparse
The fish `function` builtin has the option `-a/--argument-names` which allows binding an argument to a name.
Is it still possible to do this while also using the `argparse` builtin? If so, how? | I designed and implemented `argparse`. Yes, technically you can use the `--argument` flag and `argparse` in the same function but doing so makes no sense. The `--argument` option operates completely independently of `argparse` and has no knowledge of flags. Create the following function:
```
function x -a arg1 -a arg2... |
54205087 | How can I create a file with null bytes in the filename? | 6 | 2019-01-15 18:45:47 | <p>For a security test, I need to pass a file that contains null characters in its content and its filename. </p>
<p>For the body content, it's easy to use <code>printf</code>:</p>
<pre><code>$ printf "Hello\00, Null!" > containsnull.txt
$ xxd contains.null
0000000: 4865 6c6c 6f00 2c20 4e75 6c6c 21 Hello.,... | 12,727 | 2,027,146 | 2021-07-12 01:54:49 | 54,206,019 | 11 | 2019-01-15 19:59:06 | 387,076 | 2019-01-15 19:59:06 | https://stackoverflow.com/q/54205087 | https://stackoverflow.com/a/54206019 | <p>It's impossible to create a file name containing a null byte through POSIX or Windows APIs. On all the Unix systems that I'm aware of, it's impossible to create a file name containing a null byte, even with an ill-behaved application that bypasses the normal API, because the kernel itself treats all of its file name... | <p>It's impossible to create a file name containing a null byte through POSIX or Windows APIs. On all the Unix systems that I'm aware of, it's impossible to create a file name containing a null byte, even with an ill-behaved application that bypasses the normal API, because the kernel itself treats all of its file name... | 387, 694, 1062 | bash, filenames, null | <h1>How can I create a file with null bytes in the filename?</h1>
<p>For a security test, I need to pass a file that contains null characters in its content and its filename. </p>
<p>For the body content, it's easy to use <code>printf</code>:</p>
<pre><code>$ printf "Hello\00, Null!" > containsnull.txt
$ xxd conta... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,684 | bash | # How can I create a file with null bytes in the filename?
For a security test, I need to pass a file that contains null characters in its content and its filename.
For the body content, it's easy to use `printf`:
```
$ printf "Hello\00, Null!" > containsnull.txt
$ xxd contains.null
0000000: 4865 6c6c 6f00 2c20 4e75... | It's impossible to create a file name containing a null byte through POSIX or Windows APIs. On all the Unix systems that I'm aware of, it's impossible to create a file name containing a null byte, even with an ill-behaved application that bypasses the normal API, because the kernel itself treats all of its file name in... |
52245838 | Reading User Input in a Makefile Script | 6 | 2018-09-09 15:13:57 | <p>I have a very simple Makefile (that just recursively calls another subdirectory make):</p>
<pre><code>all:
cd addons/godot-haskell-plugin && make && cd -
run:
cd addons/godot-haskell-plugin && make run && cd -
</code></pre>
<p>What I'd like to do is</p>
<ol>
<li>Check if sh... | 17,567 | 1,770,201 | 2023-05-02 23:29:44 | 52,248,926 | 11 | 2018-09-09 21:52:33 | 128,940 | 2020-03-05 15:03:22 | https://stackoverflow.com/q/52245838 | https://stackoverflow.com/a/52248926 | <p>Make isn't really intended to be interactive, but you can kludge it.</p>
<p>There's more than one way to do it, but since you seem to want this behavior to be specific to some targets (<code>all</code> and <code>run</code>), I'd add a PHONY target that interacts with the user and perhaps aborts Make:</p>
<pre><cod... | <p>Make isn't really intended to be interactive, but you can kludge it.</p> <p>There's more than one way to do it, but since you seem to want this behavior to be specific to some targets (<code>all</code> and <code>run</code>), I'd add a PHONY target that interacts with the user and perhaps aborts Make:</p> <pre><cod... | 390, 4301 | makefile, shell | <h1>Reading User Input in a Makefile Script</h1>
<p>I have a very simple Makefile (that just recursively calls another subdirectory make):</p>
<pre><code>all:
cd addons/godot-haskell-plugin && make && cd -
run:
cd addons/godot-haskell-plugin && make run && cd -
</code></pre>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,685 | bash | # Reading User Input in a Makefile Script
I have a very simple Makefile (that just recursively calls another subdirectory make):
```
all:
cd addons/godot-haskell-plugin && make && cd -
run:
cd addons/godot-haskell-plugin && make run && cd -
```
What I'd like to do is
1. Check if shell variable `ENV_VAR` is ... | Make isn't really intended to be interactive, but you can kludge it.
There's more than one way to do it, but since you seem to want this behavior to be specific to some targets (`all` and `run`), I'd add a PHONY target that interacts with the user and perhaps aborts Make:
```
all run: check
.PHONY: check
check:
ifnd... |
50843357 | Returning ArrayList from Function/Script | 6 | 2018-06-13 17:50:46 | <p>Given the following script:</p>
<pre><code>function f {
[CmdletBinding()]Param()
Write-Verbose 'f: Start'
$t = New-Object 'System.Collections.ArrayList'
Write-Verbose $t.GetType().Name
return $t
}
$things = New-Object 'System.Collections.ArrayList'
$things.GetType().Name
$things = f -verbose
$t... | 6,540 | 8,803,234 | 2023-06-13 03:50:45 | 50,843,688 | 11 | 2018-06-13 18:12:55 | 45,375 | 2023-06-13 03:50:45 | https://stackoverflow.com/q/50843357 | https://stackoverflow.com/a/50843688 |
<p><strong>Outputting collections (not just arrays) causes PowerShell to <em>enumerate</em> them by default</strong> - i.e., the collection's elements are sent <em>one by one</em> to the success output stream.</p>
<ul>
<li>If you collect these elements by capturing the output in a variable, you always get a regular Po... | <p><strong>Outputting collections (not just arrays) causes PowerShell to <em>enumerate</em> them by default</strong> - i.e., the collection's elements are sent <em>one by one</em> to the success output stream.</p> <ul> <li>If you collect these elements by capturing the output in a variable, you always get a regular Po... | 526 | powershell | <h1>Returning ArrayList from Function/Script</h1>
<p>Given the following script:</p>
<pre><code>function f {
[CmdletBinding()]Param()
Write-Verbose 'f: Start'
$t = New-Object 'System.Collections.ArrayList'
Write-Verbose $t.GetType().Name
return $t
}
$things = New-Object 'System.Collections.ArrayLi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,686 | bash | # Returning ArrayList from Function/Script
Given the following script:
```
function f {
[CmdletBinding()]Param()
Write-Verbose 'f: Start'
$t = New-Object 'System.Collections.ArrayList'
Write-Verbose $t.GetType().Name
return $t
}
$things = New-Object 'System.Collections.ArrayList'
$things.GetType(... | **Outputting collections (not just arrays) causes PowerShell to *enumerate* them by default** - i.e., the collection's elements are sent *one by one* to the success output stream.
- If you collect these elements by capturing the output in a variable, you always get a regular PowerShell array (`[object[]]`), except if ... |
48922918 | What's the difference between "$pwd" and "./"? | 6 | 2018-02-22 08:41:36 | <p>As far as I can see using <code>$pwd</code> and using <code>./</code> in PowerShell gives the same result.</p>
<p>Are they the same or is there a difference?</p>
| 5,722 | 8,532,902 | 2018-02-22 10:24:29 | 48,922,983 | 11 | 2018-02-22 08:46:13 | 2,796,058 | 2018-02-22 09:39:05 | https://stackoverflow.com/q/48922918 | https://stackoverflow.com/a/48922983 | <p><code>$pwd</code> is an automatic variable. Its name stands for "present working directory" and it should always contain the current working path.</p>
<p>You can use just "." or ".\" as a path parameter to represent the current location, but you can't set a variable to .\ and have it then contain the current path, ... | <p><code>$pwd</code> is an automatic variable. Its name stands for "present working directory" and it should always contain the current working path.</p> <p>You can use just "." or ".\" as a path parameter to represent the current location, but you can't set a variable to .\ and have it then contain the current path, ... | 526, 8877, 28564 | powershell, pwd, relative-path | <h1>What's the difference between "$pwd" and "./"?</h1>
<p>As far as I can see using <code>$pwd</code> and using <code>./</code> in PowerShell gives the same result.</p>
<p>Are they the same or is there a difference?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,687 | bash | # What's the difference between "$pwd" and "./"?
As far as I can see using `$pwd` and using `./` in PowerShell gives the same result.
Are they the same or is there a difference? | `$pwd` is an automatic variable. Its name stands for "present working directory" and it should always contain the current working path.
You can use just "." or ".\" as a path parameter to represent the current location, but you can't set a variable to .\ and have it then contain the current path, so in this regard the... |
48108577 | import .sql file into mysql from mac command line. tried mysql -u root -p db_name > path/to/dbfile.sql | 6 | 2018-01-05 06:50:38 | <p>I have tried doing it from the command line </p>
<pre><code>mysql -u root -p db_name > ~/Documents/db_name.sql
</code></pre>
<p>I have tried doing it from mysqlimport</p>
<pre><code>mysqlimport -u root -p db_name ~/Documents/db_name.sql
</code></pre>
<p>I have tried both while being in the correct directory... | 29,829 | 7,542,831 | 2018-01-05 12:52:54 | 48,110,584 | 11 | 2018-01-05 09:23:55 | 3,278,362 | 2018-01-05 09:23:55 | https://stackoverflow.com/q/48108577 | https://stackoverflow.com/a/48110584 | <p>You should use the <code>mysql</code> command in order to import a mysqldump sql file:</p>
<p><code>mysql -u root -p db_name < ~/Documents/db_name.sql</code></p>
<p>The <code>mysqlimport</code> utility is used to insert data from textfiles into the database, it is a wrapper around the <code>LOAD DATA INFILE</co... | <p>You should use the <code>mysql</code> command in order to import a mysqldump sql file:</p> <p><code>mysql -u root -p db_name < ~/Documents/db_name.sql</code></p> <p>The <code>mysqlimport</code> utility is used to insert data from textfiles into the database, it is a wrapper around the <code>LOAD DATA INFILE</co... | 21, 387, 3791 | bash, mysql, zsh | <h1>import .sql file into mysql from mac command line. tried mysql -u root -p db_name > path/to/dbfile.sql</h1>
<p>I have tried doing it from the command line </p>
<pre><code>mysql -u root -p db_name > ~/Documents/db_name.sql
</code></pre>
<p>I have tried doing it from mysqlimport</p>
<pre><code>mysqlimport -u r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,688 | bash | # import .sql file into mysql from mac command line. tried mysql -u root -p db_name > path/to/dbfile.sql
I have tried doing it from the command line
```
mysql -u root -p db_name > ~/Documents/db_name.sql
```
I have tried doing it from mysqlimport
```
mysqlimport -u root -p db_name ~/Documents/db_name.sql
```
I hav... | You should use the `mysql` command in order to import a mysqldump sql file:
`mysql -u root -p db_name < ~/Documents/db_name.sql`
The `mysqlimport` utility is used to insert data from textfiles into the database, it is a wrapper around the `LOAD DATA INFILE` sql statement. From [mysqlimport](https://dev.mysql.com/doc/... |
47339559 | Bash script to automate Git pull | 6 | 2017-11-16 21:40:42 | <p>I want to automatically pull from Git. For some reasons it is not possible to automate the password thing in the server I am using. So it needs to be done by a Bash file. Now my Bash coding is not that good. Then it is possible to enter the passphrase for the SSH key. But I have really no clue what to do...</p>
<p>... | 51,757 | 1,806,003 | 2019-09-30 17:37:28 | 47,349,643 | 11 | 2017-11-17 11:29:26 | 7,266,232 | 2019-05-13 17:13:08 | https://stackoverflow.com/q/47339559 | https://stackoverflow.com/a/47349643 | <p>Fortunately and according to the core <a href="https://git-scm.com/docs/git-credential-store" rel="nofollow noreferrer">Git documentation</a>, you can use the following command to save your credentials for later on use - instead of typing it each time when prompted.</p>
<pre><code>git config credential.helper store
... | <p>Fortunately and according to the core <a href="https://git-scm.com/docs/git-credential-store" rel="nofollow noreferrer">Git documentation</a>, you can use the following command to save your credentials for later on use - instead of typing it each time when prompted.</p> <pre><code>git config credential.helper store ... | 119, 387, 61874 | bash, git, git-bash | <h1>Bash script to automate Git pull</h1>
<p>I want to automatically pull from Git. For some reasons it is not possible to automate the password thing in the server I am using. So it needs to be done by a Bash file. Now my Bash coding is not that good. Then it is possible to enter the passphrase for the SSH key. But I ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,689 | bash | # Bash script to automate Git pull
I want to automatically pull from Git. For some reasons it is not possible to automate the password thing in the server I am using. So it needs to be done by a Bash file. Now my Bash coding is not that good. Then it is possible to enter the passphrase for the SSH key. But I have real... | Fortunately and according to the core [Git documentation](https://git-scm.com/docs/git-credential-store), you can use the following command to save your credentials for later on use - instead of typing it each time when prompted.
```
git config credential.helper store
```
> Using this helper will store your passwords... |
45574479 | Powershell determine new URL of a permanently moved (redirected) resource | 6 | 2017-08-08 17:22:47 | <p>I'm using Powershell Core v6-beta.5 using AppImage on Linux. Is there a way to find out the "new" location of a 301 redirect? </p>
<p><code>Invoke-WebRequest -Method HEAD http://SomethingThatThrows301.com/ -MaximumRedirection 0</code> throws an error (<code>Response status code does not indicate success: 301 (Move... | 8,153 | 247,077 | 2024-03-18 15:13:29 | 45,593,554 | 11 | 2017-08-09 14:29:30 | 45,375 | 2024-03-18 15:13:29 | https://stackoverflow.com/q/45574479 | https://stackoverflow.com/a/45593554 | <p><sup>Note: All code below <strong>works in both <em>Windows PowerShell</em> and <a href="https://github.com/PowerShell/PowerShell/blob/master/README.md" rel="nofollow noreferrer"><em>PowerShell (Core) 7+</em></a></strong>, on all supported platforms, with up to 50 redirections by default.</sup></p>
<p>Assuming:</p>
... | <p><sup>Note: All code below <strong>works in both <em>Windows PowerShell</em> and <a href="https://github.com/PowerShell/PowerShell/blob/master/README.md" rel="nofollow noreferrer"><em>PowerShell (Core) 7+</em></a></strong>, on all supported platforms, with up to 50 redirections by default.</sup></p> <p>Assuming:</p> ... | 526, 31901, 56246, 130022 | http-redirect, http-status-code-301, powershell, powershell-v6.0 | <h1>Powershell determine new URL of a permanently moved (redirected) resource</h1>
<p>I'm using Powershell Core v6-beta.5 using AppImage on Linux. Is there a way to find out the "new" location of a 301 redirect? </p>
<p><code>Invoke-WebRequest -Method HEAD http://SomethingThatThrows301.com/ -MaximumRedirection 0</cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,690 | bash | # Powershell determine new URL of a permanently moved (redirected) resource
I'm using Powershell Core v6-beta.5 using AppImage on Linux. Is there a way to find out the "new" location of a 301 redirect?
`Invoke-WebRequest -Method HEAD http://SomethingThatThrows301.com/ -MaximumRedirection 0` throws an error (`Response... | Note: All code below **works in both *Windows PowerShell* and [*PowerShell (Core) 7+*](https://github.com/PowerShell/PowerShell/blob/master/README.md)**, on all supported platforms, with up to 50 redirections by default.
Assuming:
- that you don't care about the *specific* 3xx redirection status code and
- that you o... |
44654809 | Extracing IP addresses as whole words with POSIX BRE/ERE regex | 6 | 2017-06-20 13:43:02 | <p>I am trying to match IP addresses found in the output of <code>traceroute</code> by means of a regex. I'm not trying to validate them because it's safe enough to assume <code>traceroute</code> is valid (i.e. is not outputting something like <code>999.999.999.999</code>. I'm trying the following regex:</p>
<pre><cod... | 18,603 | 5,477,531 | 2021-09-27 09:58:17 | 44,654,954 | 11 | 2017-06-20 13:49:21 | 3,832,970 | 2019-04-03 07:37:22 | https://stackoverflow.com/q/44654809 | https://stackoverflow.com/a/44654954 | <p>You used a POSIX ERE pattern, but did not pass <code>-E</code> option to have <code>grep</code> use the POSIX ERE flavor. Thus, <code>grep</code> used POSIX BRE instead, where you need to escape <code>{n,m}</code> quantifier and <code>(...)</code> to make them be parsed as special regex operators.</p>
<p>Note you ne... | <p>You used a POSIX ERE pattern, but did not pass <code>-E</code> option to have <code>grep</code> use the POSIX ERE flavor. Thus, <code>grep</code> used POSIX BRE instead, where you need to escape <code>{n,m}</code> quantifier and <code>(...)</code> to make them be parsed as special regex operators.</p> <p>Note you ne... | 18, 387 | bash, regex | <h1>Extracing IP addresses as whole words with POSIX BRE/ERE regex</h1>
<p>I am trying to match IP addresses found in the output of <code>traceroute</code> by means of a regex. I'm not trying to validate them because it's safe enough to assume <code>traceroute</code> is valid (i.e. is not outputting something like <cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,691 | bash | # Extracing IP addresses as whole words with POSIX BRE/ERE regex
I am trying to match IP addresses found in the output of `traceroute` by means of a regex. I'm not trying to validate them because it's safe enough to assume `traceroute` is valid (i.e. is not outputting something like `999.999.999.999`. I'm trying the f... | You used a POSIX ERE pattern, but did not pass `-E` option to have `grep` use the POSIX ERE flavor. Thus, `grep` used POSIX BRE instead, where you need to escape `{n,m}` quantifier and `(...)` to make them be parsed as special regex operators.
Note you need to escape a `.` so that it could only match a literal dot.
T... |
43944863 | Azure Powershell Workflow - Input Parameters Not Found | 6 | 2017-05-12 19:03:00 | <h2>Background</h2>
<p>I have a workflow defined using a straightforward template from within Azure.</p>
<pre><code>workflow Use-SqlCommandSample
{
param(
[parameter(Mandatory=$True)]
[string] $SqlServer,
[parameter(Mandatory=$False)]
[int] $SqlServerPort = 1433,
[parameter(Mandatory=$True)]
... | 1,662 | 771,997 | 2017-05-14 08:43:50 | 43,962,003 | 11 | 2017-05-14 08:43:50 | 7,704,101 | 2017-05-14 08:43:50 | https://stackoverflow.com/q/43944863 | https://stackoverflow.com/a/43962003 | <p>Try putting your parameters at the top like this. Works for my runbooks.</p>
<pre><code>param(
[parameter(Mandatory=$True)]
[string] $SqlServer,
[parameter(Mandatory=$False)]
[int] $SqlServerPort = 1433,
[parameter(Mandatory=$True)]
[string] $Database,
[parameter(Mandatory=$True)]
... | <p>Try putting your parameters at the top like this. Works for my runbooks.</p> <pre><code>param( [parameter(Mandatory=$True)] [string] $SqlServer, [parameter(Mandatory=$False)] [int] $SqlServerPort = 1433, [parameter(Mandatory=$True)] [string] $Database, [parameter(Mandatory=$True)] ... | 526, 14158, 81879 | azure, azure-powershell, powershell | <h1>Azure Powershell Workflow - Input Parameters Not Found</h1>
<h2>Background</h2>
<p>I have a workflow defined using a straightforward template from within Azure.</p>
<pre><code>workflow Use-SqlCommandSample
{
param(
[parameter(Mandatory=$True)]
[string] $SqlServer,
[parameter(Mandatory=$False)]
[i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,692 | bash | # Azure Powershell Workflow - Input Parameters Not Found
## Background
I have a workflow defined using a straightforward template from within Azure.
```
workflow Use-SqlCommandSample
{
param(
[parameter(Mandatory=$True)]
[string] $SqlServer,
[parameter(Mandatory=$False)]
[int] $SqlServerPort = 1433,... | Try putting your parameters at the top like this. Works for my runbooks.
```
param(
[parameter(Mandatory=$True)]
[string] $SqlServer,
[parameter(Mandatory=$False)]
[int] $SqlServerPort = 1433,
[parameter(Mandatory=$True)]
[string] $Database,
[parameter(Mandatory=$True)]
[string] $Tab... |
41786904 | Authenticating with user/password *once* for multiple commands? (session multiplexing) | 6 | 2017-01-22 03:07:52 | <p>I got this trick from Solaris documentation, for copying <code>ssh</code> public keys to remote hosts.</p>
<p><em>note: <code>ssh-copy-id</code> isn't available on Solaris</em></p>
<pre><code>$ cat some_data_file | ssh user@host "cat >/tmp/some_data_file; some_shell_cmd"
</code></pre>
<p>I wanted to ada... | 3,784 | 2,079,103 | 2022-08-16 23:25:57 | 41,789,025 | 11 | 2017-01-22 08:51:30 | 2,079,103 | 2022-08-16 23:25:57 | https://stackoverflow.com/q/41786904 | https://stackoverflow.com/a/41789025 | <h2><strong>OpenSSH Session Multiplexing</strong></h2>
<hr />
<p> <em>This solution works even when using earlier versions of OpenSSH where the<br />
<code>ControlPersist</code>option isn't available. (Working bash example at end of this answer)</em></p>
<hr />
<p><sub><i>Note: <a href="https://www.openssh.com/... | <h2><strong>OpenSSH Session Multiplexing</strong></h2> <hr /> <p> <em>This solution works even when using earlier versions of OpenSSH where the<br /> <code>ControlPersist</code>option isn't available. (Working bash example at end of this answer)</em></p> <hr /> <p><sub><i>Note: <a href="https://www.openssh.com/... | 386, 387, 1290, 3149, 3305 | bash, openssh, scp, sftp, ssh | <h1>Authenticating with user/password *once* for multiple commands? (session multiplexing)</h1>
<p>I got this trick from Solaris documentation, for copying <code>ssh</code> public keys to remote hosts.</p>
<p><em>note: <code>ssh-copy-id</code> isn't available on Solaris</em></p>
<pre><code>$ cat some_data_file | ssh us... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,693 | bash | # Authenticating with user/password *once* for multiple commands? (session multiplexing)
I got this trick from Solaris documentation, for copying `ssh` public keys to remote hosts.
*note: `ssh-copy-id` isn't available on Solaris*
```
$ cat some_data_file | ssh user@host "cat >/tmp/some_data_file; some_shell_cmd"
```... | ## **OpenSSH Session Multiplexing**
---
*This solution works even when using earlier versions of OpenSSH where the
`ControlPersist`option isn't available. (Working bash example at end of this answer)*
---
*Note: [OpenSSH 3.9](https://www.openssh.com/txt/release-3.9) introduced Session Multiplexing over a "con... |
41103784 | Test whether a string contains a literal asterisk | 6 | 2016-12-12 15:07:54 | <p>Basically looking for a string that contains an asterisk, looked all around for one that relates to an until loop but to no avail!</p>
<p>e.g. the user would basically keep typing in strings and the program will reject them until one that has an asterisk pops up.</p>
<p>then at this point it will echo a message [c... | 4,439 | 7,106,365 | 2018-04-16 19:42:22 | 41,103,845 | 11 | 2016-12-12 15:11:25 | 45,375 | 2018-04-16 19:42:22 | https://stackoverflow.com/q/41103784 | https://stackoverflow.com/a/41103845 | <p><a href="https://stackoverflow.com/a/41103850/45375">chepner's helpful answer</a> explains the problem with your original approach well.</p>
<p>The following prompts until a literal <code>*</code> is found anywhere in the user input:</p>
<pre><code>until [[ $string == *'*'* ]]; do
echo "just give me a string wit... | <p><a href="https://stackoverflow.com/a/41103850/45375">chepner's helpful answer</a> explains the problem with your original approach well.</p> <p>The following prompts until a literal <code>*</code> is found anywhere in the user input:</p> <pre><code>until [[ $string == *'*'* ]]; do echo "just give me a string wit... | 34, 139, 387, 2314 | bash, loops, string, unix | <h1>Test whether a string contains a literal asterisk</h1>
<p>Basically looking for a string that contains an asterisk, looked all around for one that relates to an until loop but to no avail!</p>
<p>e.g. the user would basically keep typing in strings and the program will reject them until one that has an asterisk po... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,694 | bash | # Test whether a string contains a literal asterisk
Basically looking for a string that contains an asterisk, looked all around for one that relates to an until loop but to no avail!
e.g. the user would basically keep typing in strings and the program will reject them until one that has an asterisk pops up.
then at ... | [chepner's helpful answer](https://stackoverflow.com/a/41103850/45375) explains the problem with your original approach well.
The following prompts until a literal `*` is found anywhere in the user input:
```
until [[ $string == *'*'* ]]; do
echo "just give me a string with an asterisk, for crying out loud"
read ... |
40914195 | Find specific file and delete it if exists | 6 | 2016-12-01 15:16:00 | <p>I am using a couple of variables but normally I use the object returned from the <code>Get-ChildItem</code> cmdlet to find files and use an if statement that is altered. </p>
<p>But how can I find a specific file in directories and if it finds it then delete it? This was the code I made:</p>
<pre><code>$VM_NAME="T... | 18,497 | 7,205,478 | 2016-12-01 20:15:18 | 40,914,233 | 11 | 2016-12-01 15:17:43 | 1,163,423 | 2016-12-01 15:17:43 | https://stackoverflow.com/q/40914195 | https://stackoverflow.com/a/40914233 | <p>Just <em>pipe</em> your <code>Get-ChildItem</code> result to the <code>Remove-Item</code> cmdlet:</p>
<pre><code>Get-ChildItem -Path B:\Virtualservers\Disks\Users\* -include $VM_NAME.vhdx -filter *.vhdx -Recurse |
Remove-Item -Force
</code></pre>
<p>In case there is no file found, this will also work.</p>
| <p>Just <em>pipe</em> your <code>Get-ChildItem</code> result to the <code>Remove-Item</code> cmdlet:</p> <pre><code>Get-ChildItem -Path B:\Virtualservers\Disks\Users\* -include $VM_NAME.vhdx -filter *.vhdx -Recurse | Remove-Item -Force </code></pre> <p>In case there is no file found, this will also work.</p> | 526 | powershell | <h1>Find specific file and delete it if exists</h1>
<p>I am using a couple of variables but normally I use the object returned from the <code>Get-ChildItem</code> cmdlet to find files and use an if statement that is altered. </p>
<p>But how can I find a specific file in directories and if it finds it then delete it? T... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,695 | bash | # Find specific file and delete it if exists
I am using a couple of variables but normally I use the object returned from the `Get-ChildItem` cmdlet to find files and use an if statement that is altered.
But how can I find a specific file in directories and if it finds it then delete it? This was the code I made:
``... | Just *pipe* your `Get-ChildItem` result to the `Remove-Item` cmdlet:
```
Get-ChildItem -Path B:\Virtualservers\Disks\Users\* -include $VM_NAME.vhdx -filter *.vhdx -Recurse |
Remove-Item -Force
```
In case there is no file found, this will also work. |
40748363 | Virtual machine apt-get grub issue | 6 | 2016-11-22 17:44:23 | <p>I've exported a completely done VM image from Virtualbox and am trying to do an unattended setup with a script I created. So, when I get to <code>apt-get upgrade</code> this window eventually pops up which is making my script hang. The user should not have to do interact with the setup at all.</p>
<p>How can I ge... | 2,098 | 688,071 | 2016-11-23 21:46:55 | 40,751,712 | 11 | 2016-11-22 21:12:22 | 7,123,975 | 2016-11-23 21:46:55 | https://stackoverflow.com/q/40748363 | https://stackoverflow.com/a/40751712 | <p>Try this:</p>
<pre><code>apt-get -y upgrade
</code></pre>
<p>and if that does not work, try this:</p>
<pre><code>DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
</code></pre>
<p><strong>Please note</strong>: using the code above would just simply tell the system to choose the default answer for each question (... | <p>Try this:</p> <pre><code>apt-get -y upgrade </code></pre> <p>and if that does not work, try this:</p> <pre><code>DEBIAN_FRONTEND=noninteractive apt-get -y upgrade </code></pre> <p><strong>Please note</strong>: using the code above would just simply tell the system to choose the default answer for each question (... | 58, 387, 549, 103312 | bash, linux, ubuntu, ubuntu-14.04 | <h1>Virtual machine apt-get grub issue</h1>
<p>I've exported a completely done VM image from Virtualbox and am trying to do an unattended setup with a script I created. So, when I get to <code>apt-get upgrade</code> this window eventually pops up which is making my script hang. The user should not have to do interact... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,696 | bash | # Virtual machine apt-get grub issue
I've exported a completely done VM image from Virtualbox and am trying to do an unattended setup with a script I created. So, when I get to `apt-get upgrade` this window eventually pops up which is making my script hang. The user should not have to do interact with the setup at all... | Try this:
```
apt-get -y upgrade
```
and if that does not work, try this:
```
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
```
**Please note**: using the code above would just simply tell the system to choose the default answer for each question (do you always want the default answer? think about that).
**Edi... |
40519902 | How to store value from grep output in variable | 6 | 2016-11-10 04:19:13 | <p>I am working on one bash script, in which I have to use the regular expression to match string and then store the output in a variable to reuse it. </p>
<p>here is my script,</p>
<pre><code>#!/bin/sh
NAME="MET-3-get-code-from-string"
por="$($NAME | grep -P -o -e '(?<=MET-).*?(\d+)')" #this should store 3 in... | 22,514 | 2,178,763 | 2016-11-10 04:29:11 | 40,519,956 | 11 | 2016-11-10 04:25:45 | 2,290,847 | 2016-11-10 04:27:53 | https://stackoverflow.com/q/40519902 | https://stackoverflow.com/a/40519956 | <p>Change </p>
<pre><code>por="$($NAME | grep -P -o -e '(?<=MET-).*?(\d+)')"
</code></pre>
<p>to</p>
<pre><code>por="$(echo "$NAME" | grep -P -o -e '(?<=MET-).*?(\d+)')"
</code></pre>
<p>Also, you are missing a closing double quote (maybe just a typo, should be <code>NAME="MET-3-get-code-from-string"</code>)<... | <p>Change </p> <pre><code>por="$($NAME | grep -P -o -e '(?<=MET-).*?(\d+)')" </code></pre> <p>to</p> <pre><code>por="$(echo "$NAME" | grep -P -o -e '(?<=MET-).*?(\d+)')" </code></pre> <p>Also, you are missing a closing double quote (maybe just a typo, should be <code>NAME="MET-3-get-code-from-string"</code>)<... | 58, 387, 390 | bash, linux, shell | <h1>How to store value from grep output in variable</h1>
<p>I am working on one bash script, in which I have to use the regular expression to match string and then store the output in a variable to reuse it. </p>
<p>here is my script,</p>
<pre><code>#!/bin/sh
NAME="MET-3-get-code-from-string"
por="$($NAME | grep -P ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,697 | bash | # How to store value from grep output in variable
I am working on one bash script, in which I have to use the regular expression to match string and then store the output in a variable to reuse it.
here is my script,
```
#!/bin/sh
NAME="MET-3-get-code-from-string"
por="$($NAME | grep -P -o -e '(?<=MET-).*?(\d+)')" ... | Change
```
por="$($NAME | grep -P -o -e '(?<=MET-).*?(\d+)')"
```
to
```
por="$(echo "$NAME" | grep -P -o -e '(?<=MET-).*?(\d+)')"
```
Also, you are missing a closing double quote (maybe just a typo, should be `NAME="MET-3-get-code-from-string"`) |
40487017 | how to pass string to bash command as a parameter | 6 | 2016-11-08 12:29:49 | <p>I have a string variable which contains a loop. </p>
<pre><code>loopVariable="for i in 1 2 3 4 5 do echo $i done"
</code></pre>
<p>I want to pass this variable to a bash command inside the shell script. But i am always getting an error </p>
<pre><code>bash $loopVariable
</code></pre>
<p>i've tried also </p>
<pr... | 14,128 | 7,131,613 | 2016-11-08 14:37:17 | 40,487,106 | 11 | 2016-11-08 12:33:34 | 828,193 | 2016-11-08 13:14:07 | https://stackoverflow.com/q/40487017 | https://stackoverflow.com/a/40487106 | <p>You can add the <code>-c</code> option to read the command from an argument. The following should work:</p>
<pre><code>$ loopVariable='for i in 1 2 3 4 5; do echo $i; done'
$ bash -c "$loopVariable"
1
2
3
4
5
</code></pre>
<p>from man bash:</p>
<blockquote>
<pre><code> -c If the -c option is present, the... | <p>You can add the <code>-c</code> option to read the command from an argument. The following should work:</p> <pre><code>$ loopVariable='for i in 1 2 3 4 5; do echo $i; done' $ bash -c "$loopVariable" 1 2 3 4 5 </code></pre> <p>from man bash:</p> <blockquote> <pre><code> -c If the -c option is present, the... | 387, 390 | bash, shell | <h1>how to pass string to bash command as a parameter</h1>
<p>I have a string variable which contains a loop. </p>
<pre><code>loopVariable="for i in 1 2 3 4 5 do echo $i done"
</code></pre>
<p>I want to pass this variable to a bash command inside the shell script. But i am always getting an error </p>
<pre><code>bas... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,698 | bash | # how to pass string to bash command as a parameter
I have a string variable which contains a loop.
```
loopVariable="for i in 1 2 3 4 5 do echo $i done"
```
I want to pass this variable to a bash command inside the shell script. But i am always getting an error
```
bash $loopVariable
```
i've tried also
```
bin/... | You can add the `-c` option to read the command from an argument. The following should work:
```
$ loopVariable='for i in 1 2 3 4 5; do echo $i; done'
$ bash -c "$loopVariable"
1
2
3
4
5
```
from man bash:
> ```
> -c If the -c option is present, then commands are read from the
> first non-opt... |
40144064 | How can I tell what versions of MinGW32 and MinGW64 (via Git Bash) I have installed? | 6 | 2016-10-20 01:32:45 | <p>When I originally installed Git for Windows, I (somehow) ended up with two copies of Git Bash - one running MinGW32, one running MinGW64.</p>
<p>Given there's no command like <code>mingw --version</code> I could run, how can I determine what versions of these packages I currently have installed? I've been having so... | 8,892 | 1,982,136 | 2016-10-20 01:47:03 | 40,144,165 | 11 | 2016-10-20 01:47:03 | 6,330,106 | 2016-10-20 01:47:03 | https://stackoverflow.com/q/40144064 | https://stackoverflow.com/a/40144165 | <p><code>uname -a</code></p>
<p>This is a common linux command to show the version info of OS.</p>
| <p><code>uname -a</code></p> <p>This is a common linux command to show the version info of OS.</p> | 119, 387, 4086 | bash, git, mingw | <h1>How can I tell what versions of MinGW32 and MinGW64 (via Git Bash) I have installed?</h1>
<p>When I originally installed Git for Windows, I (somehow) ended up with two copies of Git Bash - one running MinGW32, one running MinGW64.</p>
<p>Given there's no command like <code>mingw --version</code> I could run, how c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,699 | bash | # How can I tell what versions of MinGW32 and MinGW64 (via Git Bash) I have installed?
When I originally installed Git for Windows, I (somehow) ended up with two copies of Git Bash - one running MinGW32, one running MinGW64.
Given there's no command like `mingw --version` I could run, how can I determine what version... | `uname -a`
This is a common linux command to show the version info of OS. |
39672509 | use of flags in bash script | 6 | 2016-09-24 04:30:02 | <p>Scripts in linux start with some declaration like : </p>
<p><code>#!/bin/bash</code></p>
<p>Correct me if I am wrong : this probably says which shell to use. </p>
<p>I have also seen some scripts which say : </p>
<p><code>#!/bin/bash -ex</code></p>
<p>what is the use of the flags -ex </p>
| 25,824 | 6,179,988 | 2016-09-24 17:05:36 | 39,672,540 | 11 | 2016-09-24 04:35:29 | 6,869,585 | 2016-09-24 17:05:36 | https://stackoverflow.com/q/39672509 | https://stackoverflow.com/a/39672540 | <pre><code>#!/bin/bash -ex
<=>
#!/bin/bash
set -e -x
</code></pre>
<p>Man Page (<a href="http://ss64.com/bash/set.html" rel="noreferrer">http://ss64.com/bash/set.html</a>):</p>
<pre><code>-e Exit immediately if a simple command exits with a non-zero status, unless
the command that fails is part of an unti... | <pre><code>#!/bin/bash -ex <=> #!/bin/bash set -e -x </code></pre> <p>Man Page (<a href="http://ss64.com/bash/set.html" rel="noreferrer">http://ss64.com/bash/set.html</a>):</p> <pre><code>-e Exit immediately if a simple command exits with a non-zero status, unless the command that fails is part of an unti... | 58, 387, 390 | bash, linux, shell | <h1>use of flags in bash script</h1>
<p>Scripts in linux start with some declaration like : </p>
<p><code>#!/bin/bash</code></p>
<p>Correct me if I am wrong : this probably says which shell to use. </p>
<p>I have also seen some scripts which say : </p>
<p><code>#!/bin/bash -ex</code></p>
<p>what is the use of the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,700 | bash | # use of flags in bash script
Scripts in linux start with some declaration like :
`#!/bin/bash`
Correct me if I am wrong : this probably says which shell to use.
I have also seen some scripts which say :
`#!/bin/bash -ex`
what is the use of the flags -ex | ```
#!/bin/bash -ex
<=>
#!/bin/bash
set -e -x
```
Man Page (<http://ss64.com/bash/set.html>):
```
-e Exit immediately if a simple command exits with a non-zero status, unless
the command that fails is part of an until or while loop, part of an
if statement, part of a && or || list, or if the command's retur... |
39346453 | How do I make shell scripts work on both Linux and OS X? | 6 | 2016-09-06 10:14:55 | <p>I have a snippet of code to compile a tex document. </p>
<pre><code>#!/usr/bin/env bash
filename="thesis"
pdflatex -shell-escape $filename
makeglossaries $filename
bibtex $filename
pdflatex $filename
pdflatex $filename
# for Ubuntu
#xdg-open $filename.pdf
# for mac
open $filename.pdf
</code></pre>
<p>How do I ... | 2,614 | 3,067,748 | 2016-09-06 10:52:10 | 39,346,837 | 11 | 2016-09-06 10:32:22 | 4,272,464 | 2016-09-06 10:32:22 | https://stackoverflow.com/q/39346453 | https://stackoverflow.com/a/39346837 | <p>The standard way to detect the current platform is to call <a href="http://linux.die.net/man/1/uname" rel="noreferrer"><code>uname</code></a>:</p>
<pre><code>uname=$(uname);
case "$uname" in
(*Linux*) openCmd='xdg-open'; ;;
(*Darwin*) openCmd='open'; ;;
(*CYGWIN*) openCmd='cygstart'; ;;
(*) echo 'er... | <p>The standard way to detect the current platform is to call <a href="http://linux.die.net/man/1/uname" rel="noreferrer"><code>uname</code></a>:</p> <pre><code>uname=$(uname); case "$uname" in (*Linux*) openCmd='xdg-open'; ;; (*Darwin*) openCmd='open'; ;; (*CYGWIN*) openCmd='cygstart'; ;; (*) echo 'er... | 58, 369, 390, 934 | compatibility, linux, macos, shell | <h1>How do I make shell scripts work on both Linux and OS X?</h1>
<p>I have a snippet of code to compile a tex document. </p>
<pre><code>#!/usr/bin/env bash
filename="thesis"
pdflatex -shell-escape $filename
makeglossaries $filename
bibtex $filename
pdflatex $filename
pdflatex $filename
# for Ubuntu
#xdg-open $file... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,701 | bash | # How do I make shell scripts work on both Linux and OS X?
I have a snippet of code to compile a tex document.
```
#!/usr/bin/env bash
filename="thesis"
pdflatex -shell-escape $filename
makeglossaries $filename
bibtex $filename
pdflatex $filename
pdflatex $filename
# for Ubuntu
#xdg-open $filename.pdf
# for mac
o... | The standard way to detect the current platform is to call [`uname`](http://linux.die.net/man/1/uname):
```
uname=$(uname);
case "$uname" in
(*Linux*) openCmd='xdg-open'; ;;
(*Darwin*) openCmd='open'; ;;
(*CYGWIN*) openCmd='cygstart'; ;;
(*) echo 'error: unsupported platform.'; exit 2; ;;
esac;
"$openC... |
39101291 | -replace does not replace string with "()" | 6 | 2016-08-23 12:31:07 | <p>I'm trying to replace a string containing parentheses in PowerShell. However, when I try this to do this it is not working. </p>
<p>Any idea as to where I'm going wrong? What am I suppose to do to replace a string containing <code>()</code> with <code>-replace</code> in PowerShell?</p>
<pre><code>$a='Some Text wit... | 5,635 | 5,567,312 | 2016-08-23 12:34:46 | 39,101,338 | 11 | 2016-08-23 12:33:45 | 1,163,423 | 2016-08-23 12:33:45 | https://stackoverflow.com/q/39101291 | https://stackoverflow.com/a/39101338 | <p><code>-replace</code> useses <em>regular expression</em> so you have to to <em>escape</em> your <code>regex</code>:</p>
<pre><code>$a='Some Text with (round) brackets. This text is long.'
$ch="with (round) brackets."
$b="this text"
$a -replace [regex]::Escape($ch),$b
</code></pre>
<p><strong>Output:</strong></p>
... | <p><code>-replace</code> useses <em>regular expression</em> so you have to to <em>escape</em> your <code>regex</code>:</p> <pre><code>$a='Some Text with (round) brackets. This text is long.' $ch="with (round) brackets." $b="this text" $a -replace [regex]::Escape($ch),$b </code></pre> <p><strong>Output:</strong></p> ... | 526 | powershell | <h1>-replace does not replace string with "()"</h1>
<p>I'm trying to replace a string containing parentheses in PowerShell. However, when I try this to do this it is not working. </p>
<p>Any idea as to where I'm going wrong? What am I suppose to do to replace a string containing <code>()</code> with <code>-replace</co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,702 | bash | # -replace does not replace string with "()"
I'm trying to replace a string containing parentheses in PowerShell. However, when I try this to do this it is not working.
Any idea as to where I'm going wrong? What am I suppose to do to replace a string containing `()` with `-replace` in PowerShell?
```
$a='Some Text w... | `-replace` useses *regular expression* so you have to to *escape* your `regex`:
```
$a='Some Text with (round) brackets. This text is long.'
$ch="with (round) brackets."
$b="this text"
$a -replace [regex]::Escape($ch),$b
```
**Output:**
```
Some Text this text This text is long.
``` |
38703915 | Why is COMPOSER_HOME empty? | 6 | 2016-08-01 16:38:17 | <p>I have a question about the programming tool <a href="https://getcomposer.org/download/" rel="noreferrer">composer</a> which is installed as an executable in <code>/usr/local/bin/composer</code> on 3 different machines that I use between work and home. According to:</p>
<pre class="lang-sh prettyprint-override"><co... | 8,070 | 4,233,593 | 2018-10-13 04:32:33 | 38,746,307 | 11 | 2016-08-03 14:21:44 | 354,577 | 2016-08-03 14:21:44 | https://stackoverflow.com/q/38703915 | https://stackoverflow.com/a/38746307 | <p>The <a href="https://github.com/composer/composer/blob/59596ff012c17d209f6bc2186f766033e461c04e/src/Composer/Factory.php#L52" rel="noreferrer">source code</a> reveals some additional complexity to how Composer's home directory is computed.</p>
<p>If your system uses freedesktop.org standards, which it detects by lo... | <p>The <a href="https://github.com/composer/composer/blob/59596ff012c17d209f6bc2186f766033e461c04e/src/Composer/Factory.php#L52" rel="noreferrer">source code</a> reveals some additional complexity to how Composer's home directory is computed.</p> <p>If your system uses freedesktop.org standards, which it detects by lo... | 5, 387, 78546, 118247 | bash, composer-php, php, ubuntu-16.04 | <h1>Why is COMPOSER_HOME empty?</h1>
<p>I have a question about the programming tool <a href="https://getcomposer.org/download/" rel="noreferrer">composer</a> which is installed as an executable in <code>/usr/local/bin/composer</code> on 3 different machines that I use between work and home. According to:</p>
<pre cla... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,703 | bash | # Why is COMPOSER_HOME empty?
I have a question about the programming tool [composer](https://getcomposer.org/download/) which is installed as an executable in `/usr/local/bin/composer` on 3 different machines that I use between work and home. According to:
```
composer help global
```
> ```
> COMPOSER_HOME is c:\Us... | The [source code](https://github.com/composer/composer/blob/59596ff012c17d209f6bc2186f766033e461c04e/src/Composer/Factory.php#L52) reveals some additional complexity to how Composer's home directory is computed.
If your system uses freedesktop.org standards, which it detects by looking for [environment variables begin... |
37428948 | running Xvfb in background on remote linux | 6 | 2016-05-25 06:03:28 | <p>i am facing issues with Xvfb on remote linux. when i run the command </p>
<pre><code>Xvfb :99 &
</code></pre>
<p>I get this messages on the command line
<code>Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing ... | 11,162 | 5,882,670 | 2016-05-31 06:49:33 | 37,429,660 | 11 | 2016-05-25 06:45:09 | 1,829,500 | 2016-05-31 06:49:33 | https://stackoverflow.com/q/37428948 | https://stackoverflow.com/a/37429660 | <p>instead of & try to use below: <br>
issue ctrl+z command after entering Xvfb :99 <br>
then enter bg to send the process to run in background and following would keep on running in background. <BR>
EDIT: Below should also help:</p>
<pre><code>nohup Xvfb :99 > /dev/null 2>&1 &
</code></pre>
<p>or s... | <p>instead of & try to use below: <br> issue ctrl+z command after entering Xvfb :99 <br> then enter bg to send the process to run in background and following would keep on running in background. <BR> EDIT: Below should also help:</p> <pre><code>nohup Xvfb :99 > /dev/null 2>&1 & </code></pre> <p>or s... | 58, 390, 67591 | linux, shell, xvfb | <h1>running Xvfb in background on remote linux</h1>
<p>i am facing issues with Xvfb on remote linux. when i run the command </p>
<pre><code>Xvfb :99 &
</code></pre>
<p>I get this messages on the command line
<code>Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
I... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,704 | bash | # running Xvfb in background on remote linux
i am facing issues with Xvfb on remote linux. when i run the command
```
Xvfb :99 &
```
I get this messages on the command line
`Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializ... | instead of & try to use below:
issue ctrl+z command after entering Xvfb :99
then enter bg to send the process to run in background and following would keep on running in background.
EDIT: Below should also help:
```
nohup Xvfb :99 > /dev/null 2>&1 &
```
or simply `nohup Xvfb :99 &` |
36068875 | How to find computer object OU from server itself using CMD | 6 | 2016-03-17 18:29:53 | <p>How can I find what OU the computer belongs to using CMD or powershell cmdlet . I have found some long scripts but there has to be a one liner command for it.
The computers dont have AD role installed on them so DSQUERY is out of equation.
CMD or powershell cmdlet would work.</p>
| 39,950 | 2,217,784 | 2016-03-17 18:53:30 | 36,069,316 | 11 | 2016-03-17 18:53:30 | 3,245,749 | 2016-03-17 18:53:30 | https://stackoverflow.com/q/36068875 | https://stackoverflow.com/a/36069316 | <p>A one-liner for PowerShell without AD Role would be:</p>
<pre><code>([adsisearcher]"(&(name=$env:computername)(objectClass=computer))").findall().path
</code></pre>
<p>That would give you a string like:</p>
<pre><code>LDAP://CN=MyComputer,OU=Workstations,OU=Machines,DC=TacoTruck,DC=com
</code></pre>
<p>That ... | <p>A one-liner for PowerShell without AD Role would be:</p> <pre><code>([adsisearcher]"(&(name=$env:computername)(objectClass=computer))").findall().path </code></pre> <p>That would give you a string like:</p> <pre><code>LDAP://CN=MyComputer,OU=Workstations,OU=Machines,DC=TacoTruck,DC=com </code></pre> <p>That ... | 526, 1231, 10401, 46370 | active-directory, command-line, ou, powershell | <h1>How to find computer object OU from server itself using CMD</h1>
<p>How can I find what OU the computer belongs to using CMD or powershell cmdlet . I have found some long scripts but there has to be a one liner command for it.
The computers dont have AD role installed on them so DSQUERY is out of equation.
CMD or p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,705 | bash | # How to find computer object OU from server itself using CMD
How can I find what OU the computer belongs to using CMD or powershell cmdlet . I have found some long scripts but there has to be a one liner command for it.
The computers dont have AD role installed on them so DSQUERY is out of equation.
CMD or powershell... | A one-liner for PowerShell without AD Role would be:
```
([adsisearcher]"(&(name=$env:computername)(objectClass=computer))").findall().path
```
That would give you a string like:
```
LDAP://CN=MyComputer,OU=Workstations,OU=Machines,DC=TacoTruck,DC=com
```
That would work on the local computer. If you want to run ag... |
34725005 | Linux - Sort files by part of name (no delimiters) | 6 | 2016-01-11 15:20:54 | <p>I want to get a sorted list of files. Files have the following naming convention:</p>
<p><code>DATENUMBER.txt</code> (without spaces).</p>
<p>E.g., file <code>3</code> on <code>2015-12-09</code> looks like: <code>201512093.txt</code></p>
<p>The <code>version sort</code> option of <code>ls</code> doesn't help me:<... | 2,238 | 1,566,267 | 2016-01-26 13:35:41 | 34,725,373 | 11 | 2016-01-11 15:37:03 | 1,566,221 | 2016-01-26 13:35:41 | https://stackoverflow.com/q/34725005 | https://stackoverflow.com/a/34725373 | <p>This will do the sort:</p>
<pre><code>sort -k1.1,1.8 -k1.9n
</code></pre>
<p>That defines two keys, the first one being a fixed-length 8-character key (field one, characters 1 through 8), and the secondary key being a numeric key starting at field one character 9 (and extending to the end of the line).</p>
<p>Num... | <p>This will do the sort:</p> <pre><code>sort -k1.1,1.8 -k1.9n </code></pre> <p>That defines two keys, the first one being a fixed-length 8-character key (field one, characters 1 through 8), and the secondary key being a numeric key starting at field one character 9 (and extending to the end of the line).</p> <p>Num... | 58, 134, 387 | bash, linux, sorting | <h1>Linux - Sort files by part of name (no delimiters)</h1>
<p>I want to get a sorted list of files. Files have the following naming convention:</p>
<p><code>DATENUMBER.txt</code> (without spaces).</p>
<p>E.g., file <code>3</code> on <code>2015-12-09</code> looks like: <code>201512093.txt</code></p>
<p>The <code>ver... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,706 | bash | # Linux - Sort files by part of name (no delimiters)
I want to get a sorted list of files. Files have the following naming convention:
`DATENUMBER.txt` (without spaces).
E.g., file `3` on `2015-12-09` looks like: `201512093.txt`
The `version sort` option of `ls` doesn't help me:
```
ls -v:
201512183.txt
201512184.... | This will do the sort:
```
sort -k1.1,1.8 -k1.9n
```
That defines two keys, the first one being a fixed-length 8-character key (field one, characters 1 through 8), and the secondary key being a numeric key starting at field one character 9 (and extending to the end of the line).
Numeric sorting uses whatever number ... |
32211120 | How to stop an OSGI Application from command line | 6 | 2015-08-25 18:10:07 | <p>I do have a running osgi (equinox container) application. It will been started via a bash script. <a href="http://felix.apache.org/documentation/subprojects/apache-felix-remote-shell.html" rel="noreferrer">See felix gogo shell</a></p>
<pre><code>java -jar ... _osgi.jar -console 1234 &
</code></pre>
<p>This all... | 3,948 | 440,827 | 2015-09-02 18:28:18 | 32,216,407 | 11 | 2015-08-26 01:03:28 | 318,921 | 2015-09-02 18:28:18 | https://stackoverflow.com/q/32211120 | https://stackoverflow.com/a/32216407 | <p>Telneting into the Gogo shell seems like an awfully fragile solution. Why not write your application to support standard POSIX signal handling? Then you could simply kill it with <code>kill -s TERM <pid></code>.</p>
<p>For example the following bundle activator installs a shutdown hook that cleanly shuts down... | <p>Telneting into the Gogo shell seems like an awfully fragile solution. Why not write your application to support standard POSIX signal handling? Then you could simply kill it with <code>kill -s TERM <pid></code>.</p> <p>For example the following bundle activator installs a shutdown hook that cleanly shuts down... | 17, 387, 1877, 4921 | bash, java, osgi, shutdown | <h1>How to stop an OSGI Application from command line</h1>
<p>I do have a running osgi (equinox container) application. It will been started via a bash script. <a href="http://felix.apache.org/documentation/subprojects/apache-felix-remote-shell.html" rel="noreferrer">See felix gogo shell</a></p>
<pre><code>java -jar .... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,707 | bash | # How to stop an OSGI Application from command line
I do have a running osgi (equinox container) application. It will been started via a bash script. [See felix gogo shell](http://felix.apache.org/documentation/subprojects/apache-felix-remote-shell.html)
```
java -jar ... _osgi.jar -console 1234 &
```
This all works... | Telneting into the Gogo shell seems like an awfully fragile solution. Why not write your application to support standard POSIX signal handling? Then you could simply kill it with `kill -s TERM <pid>`.
For example the following bundle activator installs a shutdown hook that cleanly shuts down the framework, equivalentl... |
30947873 | Generate random passwords in shell with one special character | 6 | 2015-06-19 21:57:56 | <p>I have the following code:</p>
<pre><code></dev/urandom tr -dc 'A-Za-z0-9@#$%&_+=' | head -c 16
</code></pre>
<p>which is randomly generating passwords perfectly.</p>
<p>I want two changes:</p>
<ol>
<li>It should only contain one special character listed above</li>
<li>It should choose a random length</li... | 15,264 | 3,476,492 | 2023-01-29 20:55:11 | 30,948,155 | 11 | 2015-06-19 22:27:16 | 1,030,675 | 2015-06-19 23:07:02 | https://stackoverflow.com/q/30947873 | https://stackoverflow.com/a/30948155 | <pre><code>#! /bin/bash
chars='@#$%&_+='
{ </dev/urandom LC_ALL=C grep -ao '[A-Za-z0-9]' \
| head -n$((RANDOM % 8 + 9))
echo ${chars:$((RANDOM % ${#chars})):1} # Random special char.
} \
| shuf \
| tr -d '\n'
</code></pre>
<ul>
<li><code>LC_ALL=C</code> prevents characters like ř from appe... | <pre><code>#! /bin/bash chars='@#$%&_+=' { </dev/urandom LC_ALL=C grep -ao '[A-Za-z0-9]' \ | head -n$((RANDOM % 8 + 9)) echo ${chars:$((RANDOM % ${#chars})):1} # Random special char. } \ | shuf \ | tr -d '\n' </code></pre> <ul> <li><code>LC_ALL=C</code> prevents characters like ř from appe... | 34, 197, 220, 387, 390 | bash, passwords, random, shell, unix | <h1>Generate random passwords in shell with one special character</h1>
<p>I have the following code:</p>
<pre><code></dev/urandom tr -dc 'A-Za-z0-9@#$%&_+=' | head -c 16
</code></pre>
<p>which is randomly generating passwords perfectly.</p>
<p>I want two changes:</p>
<ol>
<li>It should only contain one speci... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,708 | bash | # Generate random passwords in shell with one special character
I have the following code:
```
</dev/urandom tr -dc 'A-Za-z0-9@#$%&_+=' | head -c 16
```
which is randomly generating passwords perfectly.
I want two changes:
1. It should only contain one special character listed above
2. It should choose a random le... | ```
#! /bin/bash
chars='@#$%&_+='
{ </dev/urandom LC_ALL=C grep -ao '[A-Za-z0-9]' \
| head -n$((RANDOM % 8 + 9))
echo ${chars:$((RANDOM % ${#chars})):1} # Random special char.
} \
| shuf \
| tr -d '\n'
```
- `LC_ALL=C` prevents characters like ř from appearing.
- `grep -o` outputs just the matchi... |
30744901 | How to run PowerShell command in R? | 6 | 2015-06-09 23:59:35 | <p>For example, this PowerShell command returns the top 5 largest files in the directory:</p>
<pre><code>gci -r |sort Length -desc |select fullname -f 5
</code></pre>
<p>Is it possible to run it in R and assign it to a variable?</p>
<p>I tried this:</p>
<pre><code>system("gci -r|sort Length -desc|select fullname -... | 9,204 | 2,185,472 | 2021-05-26 16:32:04 | 30,744,987 | 11 | 2015-06-10 00:10:22 | 419 | 2015-06-10 01:26:14 | https://stackoverflow.com/q/30744901 | https://stackoverflow.com/a/30744987 | <p>You'll probably need to run it as (assuming PowerShell is in your path):</p>
<pre><code>system("powershell -command \"gci -r|sort Length -desc|select fullname -f 5\"")
</code></pre>
<p>or, if you're not keen on escaping <code>"</code> with <code>\"</code>.</p>
<pre><code>system('powershell -command "gci -r|sort L... | <p>You'll probably need to run it as (assuming PowerShell is in your path):</p> <pre><code>system("powershell -command \"gci -r|sort Length -desc|select fullname -f 5\"") </code></pre> <p>or, if you're not keen on escaping <code>"</code> with <code>\"</code>.</p> <pre><code>system('powershell -command "gci -r|sort L... | 526, 4452 | powershell, r | <h1>How to run PowerShell command in R?</h1>
<p>For example, this PowerShell command returns the top 5 largest files in the directory:</p>
<pre><code>gci -r |sort Length -desc |select fullname -f 5
</code></pre>
<p>Is it possible to run it in R and assign it to a variable?</p>
<p>I tried this:</p>
<pre><code>system(&qu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,709 | bash | # How to run PowerShell command in R?
For example, this PowerShell command returns the top 5 largest files in the directory:
```
gci -r |sort Length -desc |select fullname -f 5
```
Is it possible to run it in R and assign it to a variable?
I tried this:
```
system("gci -r|sort Length -desc|select fullname -f 5")
W... | You'll probably need to run it as (assuming PowerShell is in your path):
```
system("powershell -command \"gci -r|sort Length -desc|select fullname -f 5\"")
```
or, if you're not keen on escaping `"` with `\"`.
```
system('powershell -command "gci -r|sort Length -desc|select fullname -f 5"')
```
I'm also assuming t... |
30357513 | Freeze the top row of a worksheet | 6 | 2015-05-20 18:21:43 | <p>PowerShell code creates Excel.</p>
<p>I am trying to freeze top row:</p>
<pre class="lang-psh prettyprint-override"><code>$excel = New-Object -Com Excel.Application
$excel.Visible = $True
$wb = $Excel.Workbooks.Add()
$ws = $wb.Worksheets.Add()
$ws.Activate()
$ws.Select()
$excel.Rows.Item("1:1").Select()
$excel... | 10,451 | 2,630,486 | 2019-04-02 10:09:49 | 30,357,780 | 11 | 2015-05-20 18:34:54 | 1,630,171 | 2015-05-20 18:34:54 | https://stackoverflow.com/q/30357513 | https://stackoverflow.com/a/30357780 | <p>To freeze the top row you need to select the <em>second</em> row:</p>
<pre class="lang-psh prettyprint-override"><code>$excel.Rows.Item("2:2").Select()
$excel.ActiveWindow.FreezePanes = $true
</code></pre>
| <p>To freeze the top row you need to select the <em>second</em> row:</p> <pre class="lang-psh prettyprint-override"><code>$excel.Rows.Item("2:2").Select() $excel.ActiveWindow.FreezePanes = $true </code></pre> | 522, 526 | excel, powershell | <h1>Freeze the top row of a worksheet</h1>
<p>PowerShell code creates Excel.</p>
<p>I am trying to freeze top row:</p>
<pre class="lang-psh prettyprint-override"><code>$excel = New-Object -Com Excel.Application
$excel.Visible = $True
$wb = $Excel.Workbooks.Add()
$ws = $wb.Worksheets.Add()
$ws.Activate()
$ws.Select... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,710 | bash | # Freeze the top row of a worksheet
PowerShell code creates Excel.
I am trying to freeze top row:
```
$excel = New-Object -Com Excel.Application
$excel.Visible = $True
$wb = $Excel.Workbooks.Add()
$ws = $wb.Worksheets.Add()
$ws.Activate()
$ws.Select()
$excel.Rows.Item("1:1").Select()
$excel.ActiveWindow.FreezePane... | To freeze the top row you need to select the *second* row:
```
$excel.Rows.Item("2:2").Select()
$excel.ActiveWindow.FreezePanes = $true
``` |
30018756 | Bash reading users y/n answer does not work (read command inside while loop reading find output) | 6 | 2015-05-03 20:03:11 | <p>I have a problem here. Seems like my Bash script is ignoring everything that is between <code>do</code> and <code>done</code>. Don't know why, maybe you will see the problem. Thanks in advance.</p>
<pre><code>katalogas=$1
find $katalogas -type f -mtime +3 | while read $failai
do
read -p "Run command $foo? [yn]" ans... | 6,012 | 4,823,395 | 2020-05-15 08:14:42 | 30,018,930 | 11 | 2015-05-03 20:19:44 | 3,776,858 | 2020-05-15 08:14:42 | https://stackoverflow.com/q/30018756 | https://stackoverflow.com/a/30018930 | <p>Try to replace</p>
<pre><code>read -p "Run command $foo? [yn]" answer
</code></pre>
<p>by</p>
<pre><code>read -p "Run command $foo? [yn]" answer </dev/tty
</code></pre>
<p>to avoid reading from stdin.</p>
<p><strong>Update with Will's suggestion:</strong></p>
<pre><code>katalogas="$1"
read -p "Run command $... | <p>Try to replace</p> <pre><code>read -p "Run command $foo? [yn]" answer </code></pre> <p>by</p> <pre><code>read -p "Run command $foo? [yn]" answer </dev/tty </code></pre> <p>to avoid reading from stdin.</p> <p><strong>Update with Will's suggestion:</strong></p> <pre><code>katalogas="$1" read -p "Run command $... | 58, 387 | bash, linux | <h1>Bash reading users y/n answer does not work (read command inside while loop reading find output)</h1>
<p>I have a problem here. Seems like my Bash script is ignoring everything that is between <code>do</code> and <code>done</code>. Don't know why, maybe you will see the problem. Thanks in advance.</p>
<pre><code>k... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,711 | bash | # Bash reading users y/n answer does not work (read command inside while loop reading find output)
I have a problem here. Seems like my Bash script is ignoring everything that is between `do` and `done`. Don't know why, maybe you will see the problem. Thanks in advance.
```
katalogas=$1
find $katalogas -type f -mtime... | Try to replace
```
read -p "Run command $foo? [yn]" answer
```
by
```
read -p "Run command $foo? [yn]" answer </dev/tty
```
to avoid reading from stdin.
**Update with Will's suggestion:**
```
katalogas="$1"
read -p "Run command $foo? [yn]" answer
if [[ $answer = y ]] ; then
find "$katalogas" -type f -mtime +3 |... |
29928540 | powershell script to remove all content items for french version in sitecore | 6 | 2015-04-28 19:46:56 | <p>I wanna use this script to remove all content items for french version and leave the English version in sitecore but wanna make sure it looks good before excuting it :( </p>
<pre class="lang-powershell prettyprint-override"><code>cd 'master:/sitecore/content'
function FilterItemsToProcess($item)
{
Get-Item $i... | 4,229 | 313,949 | 2015-04-28 21:51:14 | 29,930,229 | 11 | 2015-04-28 21:26:23 | 999,195 | 2015-04-28 21:48:52 | https://stackoverflow.com/q/29928540 | https://stackoverflow.com/a/29930229 | <p>Miroo,</p>
<p>One thing you need to know is that <code>Remove-Item</code> always removed the item as a whole. It does not remove just the language even if you pipe a language specific version. This is because sitecore API always returns an item in a specific language and <code>Remove-Item</code> has no way of disre... | <p>Miroo,</p> <p>One thing you need to know is that <code>Remove-Item</code> always removed the item as a whole. It does not remove just the language even if you pipe a language specific version. This is because sitecore API always returns an item in a specific language and <code>Remove-Item</code> has no way of disre... | 526, 7429 | powershell, sitecore | <h1>powershell script to remove all content items for french version in sitecore</h1>
<p>I wanna use this script to remove all content items for french version and leave the English version in sitecore but wanna make sure it looks good before excuting it :( </p>
<pre class="lang-powershell prettyprint-override"><code>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,712 | bash | # powershell script to remove all content items for french version in sitecore
I wanna use this script to remove all content items for french version and leave the English version in sitecore but wanna make sure it looks good before excuting it :(
```
cd 'master:/sitecore/content'
function FilterItemsToProcess($item... | Miroo,
One thing you need to know is that `Remove-Item` always removed the item as a whole. It does not remove just the language even if you pipe a language specific version. This is because sitecore API always returns an item in a specific language and `Remove-Item` has no way of disregarding the intent.
What you ne... |
29485364 | PowerShell - Connecting to Azure Active Directory using Microsoft Account | 6 | 2015-04-07 06:40:55 | <p>I have an Azure subscription where the subscription administrator account is a Microsoft Account. I then added another Microsoft Account as a co-administrator. I'm told that when I add a co-administrator, it gets added to my subscription's default AD as a <code>Guest</code> user. What I really want to accomplish is ... | 9,914 | 188,096 | 2018-04-23 13:31:33 | 29,485,600 | 11 | 2015-04-07 06:54:31 | 325,697 | 2018-04-23 13:31:33 | https://stackoverflow.com/q/29485364 | https://stackoverflow.com/a/29485600 | <p>(Updated 2018-04-23 to clarify how to do this with AzureAD (v2) module.)</p>
<p>The <a href="https://learn.microsoft.com/powershell/azure/active-directory/install-adv2?view=azureadps-2.0" rel="nofollow noreferrer">AzureAD</a> (v2) PowerShell module accepts the <code>‑TenantId</code> parameter in <a href="http... | <p>(Updated 2018-04-23 to clarify how to do this with AzureAD (v2) module.)</p> <p>The <a href="https://learn.microsoft.com/powershell/azure/active-directory/install-adv2?view=azureadps-2.0" rel="nofollow noreferrer">AzureAD</a> (v2) PowerShell module accepts the <code>‑TenantId</code> parameter in <a href="http... | 526, 14158, 93887 | azure, azure-active-directory, powershell | <h1>PowerShell - Connecting to Azure Active Directory using Microsoft Account</h1>
<p>I have an Azure subscription where the subscription administrator account is a Microsoft Account. I then added another Microsoft Account as a co-administrator. I'm told that when I add a co-administrator, it gets added to my subscript... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,713 | bash | # PowerShell - Connecting to Azure Active Directory using Microsoft Account
I have an Azure subscription where the subscription administrator account is a Microsoft Account. I then added another Microsoft Account as a co-administrator. I'm told that when I add a co-administrator, it gets added to my subscription's def... | (Updated 2018-04-23 to clarify how to do this with AzureAD (v2) module.)
The [AzureAD](https://learn.microsoft.com/powershell/azure/active-directory/install-adv2?view=azureadps-2.0) (v2) PowerShell module accepts the `‑TenantId` parameter in [`Connect‑AzureAD`](https://learn.microsoft.com/powershell/module/azuread/con... |
27558740 | Meteor will not run without Sudo? | 6 | 2014-12-19 02:01:43 | <p>On OSX Yosemite and the latest version of meteor (1.0.1), no matter how many times I uninstall and reinstall it, I can't seem to get it running without sudo. My user account is an administrator account. But meteor refuses to run without sudo. The errors I'm getting are all:</p>
<pre><code>-bash: meteor: command not... | 5,863 | 4,375,957 | 2014-12-19 06:26:41 | 27,559,623 | 11 | 2014-12-19 04:14:19 | 641,955 | 2014-12-19 06:26:41 | https://stackoverflow.com/q/27558740 | https://stackoverflow.com/a/27559623 | <p>After we clarified the permissions of the <code>meteor</code> executable and its base directory,
the problem became quite clear: </p>
<ul>
<li>The Meteor binary is located in <code>/usr/local/bin/meteor</code></li>
<li>Your user didn't have permission to the directory <code>/usr/local/bin</code></li>
</ul>
<p>The ... | <p>After we clarified the permissions of the <code>meteor</code> executable and its base directory, the problem became quite clear: </p> <ul> <li>The Meteor binary is located in <code>/usr/local/bin/meteor</code></li> <li>Your user didn't have permission to the directory <code>/usr/local/bin</code></li> </ul> <p>The ... | 359, 387, 391, 1674, 79111 | bash, meteor, permissions, sudo, terminal | <h1>Meteor will not run without Sudo?</h1>
<p>On OSX Yosemite and the latest version of meteor (1.0.1), no matter how many times I uninstall and reinstall it, I can't seem to get it running without sudo. My user account is an administrator account. But meteor refuses to run without sudo. The errors I'm getting are all:... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,714 | bash | # Meteor will not run without Sudo?
On OSX Yosemite and the latest version of meteor (1.0.1), no matter how many times I uninstall and reinstall it, I can't seem to get it running without sudo. My user account is an administrator account. But meteor refuses to run without sudo. The errors I'm getting are all:
```
-ba... | After we clarified the permissions of the `meteor` executable and its base directory,
the problem became quite clear:
- The Meteor binary is located in `/usr/local/bin/meteor`
- Your user didn't have permission to the directory `/usr/local/bin`
The steps to resolve:
1. Add permission on the base directory: `sudo chm... |
25940124 | Do powershell parameters need to be at the front of the script? | 6 | 2014-09-19 18:20:47 | <p>I'm trying to have a script with both executable code and a function, like the following: </p>
<pre><code>function CopyFiles {
Param( ... )
...
}
// Parameter for the script
param ( ... )
// Executable code
</code></pre>
<p>However, I run into the following error: "The assignment expression is not valid. The i... | 18,649 | 3,780,884 | 2014-09-20 03:23:42 | 25,940,356 | 11 | 2014-09-19 18:35:50 | 2,792,096 | 2014-09-19 18:35:50 | https://stackoverflow.com/q/25940124 | https://stackoverflow.com/a/25940356 | <p>The correct order is:</p>
<p>1.Script parameters</p>
<pre><code># Parameter for the script
param([string]$foo)
</code></pre>
<p>2.Function definitons</p>
<pre><code>function CopyFiles {
Param([string]$bar)
...
}
</code></pre>
<p>3.Script code</p>
<pre><code># Executable code
CopyFiles $foo $bar
</code... | <p>The correct order is:</p> <p>1.Script parameters</p> <pre><code># Parameter for the script param([string]$foo) </code></pre> <p>2.Function definitons</p> <pre><code>function CopyFiles { Param([string]$bar) ... } </code></pre> <p>3.Script code</p> <pre><code># Executable code CopyFiles $foo $bar </code... | 526, 5569 | function, powershell | <h1>Do powershell parameters need to be at the front of the script?</h1>
<p>I'm trying to have a script with both executable code and a function, like the following: </p>
<pre><code>function CopyFiles {
Param( ... )
...
}
// Parameter for the script
param ( ... )
// Executable code
</code></pre>
<p>However, I run... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,715 | bash | # Do powershell parameters need to be at the front of the script?
I'm trying to have a script with both executable code and a function, like the following:
```
function CopyFiles {
Param( ... )
...
}
// Parameter for the script
param ( ... )
// Executable code
```
However, I run into the following error: "The as... | The correct order is:
1.Script parameters
```
# Parameter for the script
param([string]$foo)
```
2.Function definitons
```
function CopyFiles {
Param([string]$bar)
...
}
```
3.Script code
```
# Executable code
CopyFiles $foo $bar
```
Why would you want it any other way? |
25702969 | bash argument parsing in function | 6 | 2014-09-06 17:35:05 | <p>Is the a workaround to parsing the bash script arguments in an function</p>
<p>run command:
./script.sh -t -r -e</p>
<p>script:</p>
<pre><code>#!/bin/sh
# parse argument function
parse_args() {
echo "$#" #<-- output: 0
}
# main
echo "$#" #<-- output: 3
# parsing arguments
parse_args
</code></pre>... | 3,171 | 2,596,056 | 2020-02-27 12:34:50 | 25,703,106 | 11 | 2014-09-06 17:50:38 | 2,461,638 | 2020-02-27 12:34:50 | https://stackoverflow.com/q/25702969 | https://stackoverflow.com/a/25703106 | <p><code>$#</code> evaluates to the number of parameters in the current scope. Since each function has its own scope and you don't pass any parameters to <code>parse_args</code>, <code>$#</code> will always be 0 inside of it.</p>
<p>To get the desired result, change the last line to:</p>
<pre><code>parse_args "$@"
</... | <p><code>$#</code> evaluates to the number of parameters in the current scope. Since each function has its own scope and you don't pass any parameters to <code>parse_args</code>, <code>$#</code> will always be 0 inside of it.</p> <p>To get the desired result, change the last line to:</p> <pre><code>parse_args "$@" </... | 387, 2313, 5569 | arguments, bash, function | <h1>bash argument parsing in function</h1>
<p>Is the a workaround to parsing the bash script arguments in an function</p>
<p>run command:
./script.sh -t -r -e</p>
<p>script:</p>
<pre><code>#!/bin/sh
# parse argument function
parse_args() {
echo "$#" #<-- output: 0
}
# main
echo "$#" #<-- output: 3
#... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,716 | bash | # bash argument parsing in function
Is the a workaround to parsing the bash script arguments in an function
run command:
./script.sh -t -r -e
script:
```
#!/bin/sh
# parse argument function
parse_args() {
echo "$#" #<-- output: 0
}
# main
echo "$#" #<-- output: 3
# parsing arguments
parse_args
``` | `$#` evaluates to the number of parameters in the current scope. Since each function has its own scope and you don't pass any parameters to `parse_args`, `$#` will always be 0 inside of it.
To get the desired result, change the last line to:
```
parse_args "$@"
```
[The special variable `"$@"`](https://www.gnu.org/s... |
25469132 | Delete files containing string | 6 | 2014-08-24 06:35:17 | <p>How can I delete all files in a directory that contain a string using powershell?</p>
<p>I've tried something like </p>
<pre><code>$list = get-childitem *.milk | select-string -pattern "fRating=2" | Format-Table Path
$list | foreach { rm $_.Path }
</code></pre>
<p>And that worked for some files but did not remove... | 20,103 | 3,606,799 | 2023-06-16 18:36:22 | 25,471,720 | 11 | 2014-08-24 12:31:39 | 3,829,407 | 2023-06-16 18:36:22 | https://stackoverflow.com/q/25469132 | https://stackoverflow.com/a/25471720 | <p>First we can simplify your code as:</p>
<pre><code>Get-ChildItem "*.milk" | Select-String -Pattern "fRating=2" | Select-Object -ExpandProperty path | Remove-Item -Force -Confirm
</code></pre>
<p>The lack of action and errors might be addressable by one of two things. The <code>Force</code> parame... | <p>First we can simplify your code as:</p> <pre><code>Get-ChildItem "*.milk" | Select-String -Pattern "fRating=2" | Select-Object -ExpandProperty path | Remove-Item -Force -Confirm </code></pre> <p>The lack of action and errors might be addressable by one of two things. The <code>Force</code> parame... | 526 | powershell | <h1>Delete files containing string</h1>
<p>How can I delete all files in a directory that contain a string using powershell?</p>
<p>I've tried something like </p>
<pre><code>$list = get-childitem *.milk | select-string -pattern "fRating=2" | Format-Table Path
$list | foreach { rm $_.Path }
</code></pre>
<p>And that ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,717 | bash | # Delete files containing string
How can I delete all files in a directory that contain a string using powershell?
I've tried something like
```
$list = get-childitem *.milk | select-string -pattern "fRating=2" | Format-Table Path
$list | foreach { rm $_.Path }
```
And that worked for some files but did not remove ... | First we can simplify your code as:
```
Get-ChildItem "*.milk" | Select-String -Pattern "fRating=2" | Select-Object -ExpandProperty path | Remove-Item -Force -Confirm
```
The lack of action and errors might be addressable by one of two things. The `Force` parameter which:
> Allows the cmdlet to remove items that can... |
25178632 | Modify $READLINE_LINE and $READLINE_POINT values inside bash script | 6 | 2014-08-07 09:16:55 | <p>When answering <a href="https://stackoverflow.com/questions/25076611/bash-expand-cd-with-shortcuts-like-zsh/25096279#25096279">this question</a> I used a very messy <code>bind</code> function to modify the current line according to the result of my <code>automplete.sh</code> script.</p>
<p>As I ended up using this ... | 2,707 | 2,057,091 | 2015-02-07 18:50:12 | 25,201,467 | 11 | 2014-08-08 10:32:35 | 2,958,286 | 2014-08-08 10:32:35 | https://stackoverflow.com/q/25178632 | https://stackoverflow.com/a/25201467 | <p>Just by the same reason why this won’t work:</p>
<pre><code>$ export a=1
$ bash -c 'echo $a; let a++'
1
$ echo $a
1
</code></pre>
<p>Environment variables are <em>heritable</em>, not shareable. Since <code>autocomplete.sh</code> is executed as a new child process, it can read all parent’s variables, but can‘t push... | <p>Just by the same reason why this won’t work:</p> <pre><code>$ export a=1 $ bash -c 'echo $a; let a++' 1 $ echo $a 1 </code></pre> <p>Environment variables are <em>heritable</em>, not shareable. Since <code>autocomplete.sh</code> is executed as a new child process, it can read all parent’s variables, but can‘t push... | 387, 4682 | autocomplete, bash | <h1>Modify $READLINE_LINE and $READLINE_POINT values inside bash script</h1>
<p>When answering <a href="https://stackoverflow.com/questions/25076611/bash-expand-cd-with-shortcuts-like-zsh/25096279#25096279">this question</a> I used a very messy <code>bind</code> function to modify the current line according to the resu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,718 | bash | # Modify $READLINE_LINE and $READLINE_POINT values inside bash script
When answering [this question](https://stackoverflow.com/questions/25076611/bash-expand-cd-with-shortcuts-like-zsh/25096279#25096279) I used a very messy `bind` function to modify the current line according to the result of my `automplete.sh` script... | Just by the same reason why this won’t work:
```
$ export a=1
$ bash -c 'echo $a; let a++'
1
$ echo $a
1
```
Environment variables are *heritable*, not shareable. Since `autocomplete.sh` is executed as a new child process, it can read all parent’s variables, but can‘t push new values back.
To modify `READLINE_LINE` ... |
24834784 | run typescript compiler from shell command - permission denied | 6 | 2014-07-18 22:37:28 | <p>I'm using Parallels because I prefer the Mac OS but the work we do is all in Visual Studio. We currently have a build.cmd batch file that builds our typescript files. Because I'd prefer to work on the Mac side when I can, I thought I would rewrite the script in bash and to also get some experience writing a shell ... | 14,443 | 207,524 | 2023-04-13 07:52:09 | 24,835,390 | 11 | 2014-07-19 00:02:31 | 3,829,282 | 2014-07-19 00:02:31 | https://stackoverflow.com/q/24834784 | https://stackoverflow.com/a/24835390 | <p>There are several approaches to try. You can use bash to run the script like this:</p>
<pre><code>bash node_modules/.bin/tsc -v
</code></pre>
<p>Or you can try to change the permissions on the file:</p>
<pre><code>chmod a+x node_modules/.bin/tsc
</code></pre>
<p>This should enable you to run the script like this... | <p>There are several approaches to try. You can use bash to run the script like this:</p> <pre><code>bash node_modules/.bin/tsc -v </code></pre> <p>Or you can try to change the permissions on the file:</p> <pre><code>chmod a+x node_modules/.bin/tsc </code></pre> <p>This should enable you to run the script like this... | 369, 387, 390, 84518 | bash, macos, shell, typescript | <h1>run typescript compiler from shell command - permission denied</h1>
<p>I'm using Parallels because I prefer the Mac OS but the work we do is all in Visual Studio. We currently have a build.cmd batch file that builds our typescript files. Because I'd prefer to work on the Mac side when I can, I thought I would rew... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,719 | bash | # run typescript compiler from shell command - permission denied
I'm using Parallels because I prefer the Mac OS but the work we do is all in Visual Studio. We currently have a build.cmd batch file that builds our typescript files. Because I'd prefer to work on the Mac side when I can, I thought I would rewrite the sc... | There are several approaches to try. You can use bash to run the script like this:
```
bash node_modules/.bin/tsc -v
```
Or you can try to change the permissions on the file:
```
chmod a+x node_modules/.bin/tsc
```
This should enable you to run the script like this:
```
./node_modules/.bin/tsc -v
```
But in that ... |
24488962 | Why can't I use curly brackets in crontab? | 6 | 2014-06-30 11:19:43 | <p>I was recently running a cron job using crontab -e and I found some strange behaviour. The following command doesn't work:</p>
<pre><code> * * * * * cp /home/username/{*txt,*pdf} /home/username/test/
</code></pre>
<p>but the following does</p>
<pre><code> * * * * * cp /home/username/*txt /home/username/test/
</co... | 2,406 | 2,151,564 | 2014-06-30 11:26:17 | 24,489,071 | 11 | 2014-06-30 11:26:17 | 2,623,659 | 2014-06-30 11:26:17 | https://stackoverflow.com/q/24488962 | https://stackoverflow.com/a/24489071 | <p>I suppose <code>cron</code> uses the <code>sh</code> shell to run your commands by default. <code>sh</code> does not support curly-brace wildcards.</p>
<p>IIRC, you can add to your crontab the following line:</p>
<pre><code>SHELL=/bin/bash
</code></pre>
| <p>I suppose <code>cron</code> uses the <code>sh</code> shell to run your commands by default. <code>sh</code> does not support curly-brace wildcards.</p> <p>IIRC, you can add to your crontab the following line:</p> <pre><code>SHELL=/bin/bash </code></pre> | 387, 601 | bash, cron | <h1>Why can't I use curly brackets in crontab?</h1>
<p>I was recently running a cron job using crontab -e and I found some strange behaviour. The following command doesn't work:</p>
<pre><code> * * * * * cp /home/username/{*txt,*pdf} /home/username/test/
</code></pre>
<p>but the following does</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 | 11,720 | bash | # Why can't I use curly brackets in crontab?
I was recently running a cron job using crontab -e and I found some strange behaviour. The following command doesn't work:
```
* * * * * cp /home/username/{*txt,*pdf} /home/username/test/
```
but the following does
```
* * * * * cp /home/username/*txt /home/username/te... | I suppose `cron` uses the `sh` shell to run your commands by default. `sh` does not support curly-brace wildcards.
IIRC, you can add to your crontab the following line:
```
SHELL=/bin/bash
``` |
23608005 | Execute shell commands and get output in a TextView | 6 | 2014-05-12 11:39:09 | <p>I want to execute some <code>shell commands</code> and get the output in a <code>TextView</code>. The command may have a continuous output like ping or <code>logcat</code>. Also, the <code>TextView</code> should scroll automatically as the command output is added in real-time.
In order to do so, I have done this: ... | 20,700 | 2,173,438 | 2022-10-20 16:13:04 | 23,608,939 | 11 | 2014-05-12 12:22:47 | 2,738,565 | 2019-10-20 07:26:28 | https://stackoverflow.com/q/23608005 | https://stackoverflow.com/a/23608939 | <p>You can run command and display command output into text as below : </p>
<pre><code>public class MainActivity extends Activity {
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
... | <p>You can run command and display command output into text as below : </p> <pre><code>public class MainActivity extends Activity { TextView tv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... | 390, 1386, 13784, 17130, 62763 | android, android-logcat, scrollview, shell, su | <h1>Execute shell commands and get output in a TextView</h1>
<p>I want to execute some <code>shell commands</code> and get the output in a <code>TextView</code>. The command may have a continuous output like ping or <code>logcat</code>. Also, the <code>TextView</code> should scroll automatically as the command output i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,721 | bash | # Execute shell commands and get output in a TextView
I want to execute some `shell commands` and get the output in a `TextView`. The command may have a continuous output like ping or `logcat`. Also, the `TextView` should scroll automatically as the command output is added in real-time.
In order to do so, I have done ... | You can run command and display command output into text as below :
```
public class MainActivity extends Activity {
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv=(TextView... |
22511225 | sending hex bytes to serial in bash | 6 | 2014-03-19 15:49:25 | <p>I am able to send hec bytes to a serial port using</p>
<pre><code>stty -F /dev/ttyUSB0 speed 115200 cs8 -cstopb -parenb -echo
echo -en '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > /dev/ttyUSB0
</code></pre>
<p>But when I try to do this in a loop reading te... | 50,464 | 1,072,825 | 2014-03-20 14:49:44 | 22,512,062 | 11 | 2014-03-19 16:21:44 | 1,899,640 | 2014-03-19 16:21:44 | https://stackoverflow.com/q/22511225 | https://stackoverflow.com/a/22512062 | <p>The problem is that <code>read</code> interprets escape sequences by default, effectively removing your backslashes. Make your file contain e.g. <code>\x01\x02\x03</code> and use <code>read -r</code>:</p>
<pre><code>while read -r line
do
echo -en "$line" > /dev/ttyUSB0
done < "$1"
</code></pre>
| <p>The problem is that <code>read</code> interprets escape sequences by default, effectively removing your backslashes. Make your file contain e.g. <code>\x01\x02\x03</code> and use <code>read -r</code>:</p> <pre><code>while read -r line do echo -en "$line" > /dev/ttyUSB0 done < "$1" </code></pre> | 387, 1231, 3716, 10762 | bash, command-line, serial-communication, serial-port | <h1>sending hex bytes to serial in bash</h1>
<p>I am able to send hec bytes to a serial port using</p>
<pre><code>stty -F /dev/ttyUSB0 speed 115200 cs8 -cstopb -parenb -echo
echo -en '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > /dev/ttyUSB0
</code></pre>
<p>B... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,722 | bash | # sending hex bytes to serial in bash
I am able to send hec bytes to a serial port using
```
stty -F /dev/ttyUSB0 speed 115200 cs8 -cstopb -parenb -echo
echo -en '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > /dev/ttyUSB0
```
But when I try to do this in a loop r... | The problem is that `read` interprets escape sequences by default, effectively removing your backslashes. Make your file contain e.g. `\x01\x02\x03` and use `read -r`:
```
while read -r line
do
echo -en "$line" > /dev/ttyUSB0
done < "$1"
``` |
21706127 | Delete all hidden files in folder and subfolders | 6 | 2014-02-11 15:32:51 | <p>I need to delete all hidden files in the current folder and its sub folders. Is there any way to do it with a single line command without creating a script?</p>
| 9,601 | 2,243,490 | 2018-12-15 03:00:34 | 21,706,476 | 11 | 2014-02-11 15:47:52 | 1,126,841 | 2014-02-11 15:47:52 | https://stackoverflow.com/q/21706127 | https://stackoverflow.com/a/21706476 | <p>Use</p>
<pre><code>find "$some_directory" -type f -name '.*' -delete
</code></pre>
<p>If you want to remove hidden directories as well, you'll need to take a little more care to avoid <code>.</code> and <code>..</code>, as mentioned by Ronald.</p>
<pre><code>find "$some_directory" -name '.*' ! -name '.' ! -name '... | <p>Use</p> <pre><code>find "$some_directory" -type f -name '.*' -delete </code></pre> <p>If you want to remove hidden directories as well, you'll need to take a little more care to avoid <code>.</code> and <code>..</code>, as mentioned by Ronald.</p> <pre><code>find "$some_directory" -name '.*' ! -name '.' ! -name '... | 387, 391, 2635 | bash, solaris, terminal | <h1>Delete all hidden files in folder and subfolders</h1>
<p>I need to delete all hidden files in the current folder and its sub folders. Is there any way to do it with a single line command without creating a script?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,723 | bash | # Delete all hidden files in folder and subfolders
I need to delete all hidden files in the current folder and its sub folders. Is there any way to do it with a single line command without creating a script? | Use
```
find "$some_directory" -type f -name '.*' -delete
```
If you want to remove hidden directories as well, you'll need to take a little more care to avoid `.` and `..`, as mentioned by Ronald.
```
find "$some_directory" -name '.*' ! -name '.' ! -name '..' -delete
```
With either command, you should run without... |
21151216 | How would I pass environment into docker using bash? | 6 | 2014-01-16 00:32:24 | <p>The following works fine in docker:</p>
<pre><code>docker run -i -t -rm -e a="hello world" b=world ubuntu /bin/bash
</code></pre>
<p>What it does is passes env var a with value "hello world" and env var b with value "world" into the docker container. </p>
<p>Thing is, I need to generate that from script. </p>
<p... | 4,129 | 17,174 | 2015-08-30 05:37:52 | 21,152,074 | 11 | 2014-01-16 01:59:52 | 27,581 | 2014-10-27 13:45:07 | https://stackoverflow.com/q/21151216 | https://stackoverflow.com/a/21152074 | <p><em>Bash arrays are designed to solve exactly this sort of problem</em></p>
<p>First step is to declare the array:</p>
<pre><code>docker_env=(-e "a=hello world" "b=world")
</code></pre>
<p>Which lets you programmatically populate more environment variables, for example:</p>
<pre><code>docker_env+=("c=foo bar")
<... | <p><em>Bash arrays are designed to solve exactly this sort of problem</em></p> <p>First step is to declare the array:</p> <pre><code>docker_env=(-e "a=hello world" "b=world") </code></pre> <p>Which lets you programmatically populate more environment variables, for example:</p> <pre><code>docker_env+=("c=foo bar") <... | 387, 90304 | bash, docker | <h1>How would I pass environment into docker using bash?</h1>
<p>The following works fine in docker:</p>
<pre><code>docker run -i -t -rm -e a="hello world" b=world ubuntu /bin/bash
</code></pre>
<p>What it does is passes env var a with value "hello world" and env var b with value "world" into the docker container. </... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,724 | bash | # How would I pass environment into docker using bash?
The following works fine in docker:
```
docker run -i -t -rm -e a="hello world" b=world ubuntu /bin/bash
```
What it does is passes env var a with value "hello world" and env var b with value "world" into the docker container.
Thing is, I need to generate that ... | *Bash arrays are designed to solve exactly this sort of problem*
First step is to declare the array:
```
docker_env=(-e "a=hello world" "b=world")
```
Which lets you programmatically populate more environment variables, for example:
```
docker_env+=("c=foo bar")
```
Finally run it:
```
docker run -i -t -rm "${doc... |
20514840 | Incorrect command line arguments number when passing `*` | 6 | 2013-12-11 09:06:03 | <p>I'm writing a C program about Reverse Polish Notation, which takes its operands and operators through the command line arguments. But things go wrong when the multiply operator '*' occurs, and I don't know why.<br>
Here is the little program to debug. </p>
<p><strong>test.c</strong> </p>
<pre><code>int main(... | 2,144 | 1,822,803 | 2013-12-11 11:16:25 | 20,514,888 | 11 | 2013-12-11 09:08:28 | 126,769 | 2013-12-11 09:24:30 | https://stackoverflow.com/q/20514840 | https://stackoverflow.com/a/20514888 | <p>The <code>*</code> does a shell glob. So it'll expand to all the files in your current directory, which will be the arguments to your program, you have 65 files in your directory. You can see what's happening if you run <code>echo *</code></p>
<p>You need to single quote the <code>*</code> as in <code>./test '*'</c... | <p>The <code>*</code> does a shell glob. So it'll expand to all the files in your current directory, which will be the arguments to your program, you have 65 files in your directory. You can see what's happening if you run <code>echo *</code></p> <p>You need to single quote the <code>*</code> as in <code>./test '*'</c... | 8, 390, 31134 | c, command-line-arguments, shell | <h1>Incorrect command line arguments number when passing `*`</h1>
<p>I'm writing a C program about Reverse Polish Notation, which takes its operands and operators through the command line arguments. But things go wrong when the multiply operator '*' occurs, and I don't know why.<br>
Here is the little program to debug.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,725 | bash | # Incorrect command line arguments number when passing `*`
I'm writing a C program about Reverse Polish Notation, which takes its operands and operators through the command line arguments. But things go wrong when the multiply operator '*' occurs, and I don't know why.
Here is the little program to debug.
**test.c*... | The `*` does a shell glob. So it'll expand to all the files in your current directory, which will be the arguments to your program, you have 65 files in your directory. You can see what's happening if you run `echo *`
You need to single quote the `*` as in `./test '*'` (double quotes would work too) , this will preven... |
19944507 | Remove white space from PowerShell output | 6 | 2013-11-13 03:09:27 | <p>I'm returning the mail property of a distribution group within Active Directory using the command below in PowerShell.</p>
<pre><code>Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide
</code></pre>
<p>The output looks like (asterisks used to represent white space):</p>
<pre><code>*
*
mygr... | 23,470 | 559,663 | 2020-09-08 01:43:16 | 19,944,566 | 11 | 2013-11-13 03:15:17 | 574,168 | 2013-11-13 04:42:16 | https://stackoverflow.com/q/19944507 | https://stackoverflow.com/a/19944566 | <p>I think this should work (V2):</p>
<pre><code>(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide | out-string).split("`n") -match '\S'
</code></pre>
<p>Edit: that's way more complicated than it needs to be.</p>
<pre><code>(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | For... | <p>I think this should work (V2):</p> <pre><code>(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide | out-string).split("`n") -match '\S' </code></pre> <p>Edit: that's way more complicated than it needs to be.</p> <pre><code>(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | For... | 526, 10401 | active-directory, powershell | <h1>Remove white space from PowerShell output</h1>
<p>I'm returning the mail property of a distribution group within Active Directory using the command below in PowerShell.</p>
<pre><code>Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide
</code></pre>
<p>The output looks like (asterisks used ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,726 | bash | # Remove white space from PowerShell output
I'm returning the mail property of a distribution group within Active Directory using the command below in PowerShell.
```
Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide
```
The output looks like (asterisks used to represent white space):
```
*... | I think this should work (V2):
```
(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide | out-string).split("`n") -match '\S'
```
Edit: that's way more complicated than it needs to be.
```
(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide | Out-String).trim()
``` |
19479287 | Filter original array based on a property value of an object in an array on the original parent object | 6 | 2013-10-20 15:37:19 | <p>I have an array of PowerShell objects called <code>$releases</code>. A release contains an ID, Name, and an <strong>optional</strong> array of objects for projects associated with the release. Each project has an ID and Name property. An example is shown below.</p>
<pre><code>id : 1
name ... | 15,791 | 19,977 | 2018-05-15 19:41:42 | 19,487,214 | 11 | 2013-10-21 06:00:32 | 2,610,230 | 2013-10-21 06:00:32 | https://stackoverflow.com/q/19479287 | https://stackoverflow.com/a/19487214 | <p>Something like this?</p>
<pre><code>PS> $releases | ?{ $_.associated_projects -ne $null }
Name Value
---- -----
associated_projects {id, name}
name Release 5
id 1
associated_projects {... | <p>Something like this?</p> <pre><code>PS> $releases | ?{ $_.associated_projects -ne $null } Name Value ---- ----- associated_projects {id, name} name Release 5 id 1 associated_projects {... | 73157 | powershell-3.0 | <h1>Filter original array based on a property value of an object in an array on the original parent object</h1>
<p>I have an array of PowerShell objects called <code>$releases</code>. A release contains an ID, Name, and an <strong>optional</strong> array of objects for projects associated with the release. Each project... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,727 | bash | # Filter original array based on a property value of an object in an array on the original parent object
I have an array of PowerShell objects called `$releases`. A release contains an ID, Name, and an **optional** array of objects for projects associated with the release. Each project has an ID and Name property. An ... | Something like this?
```
PS> $releases | ?{ $_.associated_projects -ne $null }
Name Value
---- -----
associated_projects {id, name}
name Release 5
id 1
associated_projects {id, name}
name ... |
18974788 | Bash IF : multiple conditions | 6 | 2013-09-24 06:49:57 | <p>I've been trying to make this thing work for a couple of hours but I can't get it to work :</p>
<p><code>if [ "$P" = "SFTP" -a "$PORT" != "22" ] || [ "$P" = "FTPS" && [ "$PORT" != "990" -a "$PORT" != "21" ] ] ; then</code></p>
<p>Can someone help me ? I know that multiple conditions can be written like thi... | 5,474 | 2,447,053 | 2018-04-05 10:46:34 | 18,974,875 | 11 | 2013-09-24 06:54:18 | 828,193 | 2013-09-24 06:54:18 | https://stackoverflow.com/q/18974788 | https://stackoverflow.com/a/18974875 | <p>You can't nest expressions in single brackets. It should be written like this:</p>
<pre><code>if [ "$P" = "SFTP" -a "$PORT" != "22" ] || [ "$P" = "FTPS" -a "$PORT" != "990" -a "$PORT" != "21" ] ; then
</code></pre>
<p>This can be written as a single expressions as:</p>
<pre><code>if [ \( "$P" = "SFTP" -a "$PORT" ... | <p>You can't nest expressions in single brackets. It should be written like this:</p> <pre><code>if [ "$P" = "SFTP" -a "$PORT" != "22" ] || [ "$P" = "FTPS" -a "$PORT" != "990" -a "$PORT" != "21" ] ; then </code></pre> <p>This can be written as a single expressions as:</p> <pre><code>if [ \( "$P" = "SFTP" -a "$PORT" ... | 387, 2773, 3610, 22774, 39271 | bash, conditional-statements, if-statement, multiple-conditions, nested | <h1>Bash IF : multiple conditions</h1>
<p>I've been trying to make this thing work for a couple of hours but I can't get it to work :</p>
<p><code>if [ "$P" = "SFTP" -a "$PORT" != "22" ] || [ "$P" = "FTPS" && [ "$PORT" != "990" -a "$PORT" != "21" ] ] ; then</code></p>
<p>Can someone help me ? I know that mult... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,728 | bash | # Bash IF : multiple conditions
I've been trying to make this thing work for a couple of hours but I can't get it to work :
`if [ "$P" = "SFTP" -a "$PORT" != "22" ] || [ "$P" = "FTPS" && [ "$PORT" != "990" -a "$PORT" != "21" ] ] ; then`
Can someone help me ? I know that multiple conditions can be written like this :... | You can't nest expressions in single brackets. It should be written like this:
```
if [ "$P" = "SFTP" -a "$PORT" != "22" ] || [ "$P" = "FTPS" -a "$PORT" != "990" -a "$PORT" != "21" ] ; then
```
This can be written as a single expressions as:
```
if [ \( "$P" = "SFTP" -a "$PORT" != "22" \) -o \( "$P" = "FTPS" -a "$PO... |
18957889 | Sed substitution and external command | 6 | 2013-09-23 11:15:32 | <p>I have an input log file in this format</p>
<pre><code>May 23 2012 11:59:56
a;b;c
May 21 2012 16:54:12
d;e;f
May 19 2012 16:22:52
g;h;i
...
</code></pre>
<p>I would want to output it in this format</p>
<pre><code>2012-05-23
a;b;c
2012-05-21
d;e;f
2012-05-19
g;h;i
...
</code></pre>
<p>Using <code>sed</code>, I kn... | 1,417 | 1,360,476 | 2013-09-23 12:36:06 | 18,958,345 | 11 | 2013-09-23 11:41:43 | 164,835 | 2013-09-23 11:41:43 | https://stackoverflow.com/q/18957889 | https://stackoverflow.com/a/18958345 | <p>If you have <strong>GNU Sed</strong> available, you could use the <code>e</code> flag:</p>
<pre><code>sed 's/.*:.*/date -d"&" "+%Y-%m-%d"/ge' file
</code></pre>
<p>will help you for your example, see the test:</p>
<pre><code>kent$ echo "May 23 2012 11:59:56
a;b;c
May 21 2012 16:54:12
d;e;f
May 19 2012 16:22:... | <p>If you have <strong>GNU Sed</strong> available, you could use the <code>e</code> flag:</p> <pre><code>sed 's/.*:.*/date -d"&" "+%Y-%m-%d"/ge' file </code></pre> <p>will help you for your example, see the test:</p> <pre><code>kent$ echo "May 23 2012 11:59:56 a;b;c May 21 2012 16:54:12 d;e;f May 19 2012 16:22:... | 387, 5282 | bash, sed | <h1>Sed substitution and external command</h1>
<p>I have an input log file in this format</p>
<pre><code>May 23 2012 11:59:56
a;b;c
May 21 2012 16:54:12
d;e;f
May 19 2012 16:22:52
g;h;i
...
</code></pre>
<p>I would want to output it in this format</p>
<pre><code>2012-05-23
a;b;c
2012-05-21
d;e;f
2012-05-19
g;h;i
...... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,729 | bash | # Sed substitution and external command
I have an input log file in this format
```
May 23 2012 11:59:56
a;b;c
May 21 2012 16:54:12
d;e;f
May 19 2012 16:22:52
g;h;i
...
```
I would want to output it in this format
```
2012-05-23
a;b;c
2012-05-21
d;e;f
2012-05-19
g;h;i
...
```
Using `sed`, I know how to substitute ... | If you have **GNU Sed** available, you could use the `e` flag:
```
sed 's/.*:.*/date -d"&" "+%Y-%m-%d"/ge' file
```
will help you for your example, see the test:
```
kent$ echo "May 23 2012 11:59:56
a;b;c
May 21 2012 16:54:12
d;e;f
May 19 2012 16:22:52
g;h;i"|sed 's/.*:.*/date -d"&" "+%Y-%m-%d"/ge'
2012-05-23
a;b;c... |
18935109 | How to move files with adb shell? | 6 | 2013-09-21 16:46:51 | <p>How can I move files with adb shell ?
For example I would like to move SystemUI.apk from /system to /system/app</p>
<p>I didn't find any command to move files inside system partition with adb shell.
Do anyone know how to do this?</p>
| 34,740 | 2,758,524 | 2018-06-06 08:35:14 | 18,935,228 | 11 | 2013-09-21 17:00:48 | 445,221 | 2013-09-21 17:00:48 | https://stackoverflow.com/q/18935109 | https://stackoverflow.com/a/18935228 | <p>Does <code>mv</code> not work?</p>
<pre><code>mv /system/SystemUI.apk /system/app/
</code></pre>
<p>Or perhaps you need to be root:</p>
<pre><code>su
mv /system/SystemUI.apk /system/app/
</code></pre>
| <p>Does <code>mv</code> not work?</p> <pre><code>mv /system/SystemUI.apk /system/app/ </code></pre> <p>Or perhaps you need to be root:</p> <pre><code>su mv /system/SystemUI.apk /system/app/ </code></pre> | 390, 2631, 7002, 22975, 30645 | adb, batch-file, batch-processing, cmd, shell | <h1>How to move files with adb shell?</h1>
<p>How can I move files with adb shell ?
For example I would like to move SystemUI.apk from /system to /system/app</p>
<p>I didn't find any command to move files inside system partition with adb shell.
Do anyone know how to do this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,730 | bash | # How to move files with adb shell?
How can I move files with adb shell ?
For example I would like to move SystemUI.apk from /system to /system/app
I didn't find any command to move files inside system partition with adb shell.
Do anyone know how to do this? | Does `mv` not work?
```
mv /system/SystemUI.apk /system/app/
```
Or perhaps you need to be root:
```
su
mv /system/SystemUI.apk /system/app/
``` |
18282929 | How to validate filename in bash script? | 6 | 2013-08-16 22:15:40 | <p><strong>A little bit about my application:</strong></p>
<p>I am writing a small application in bash script. The application must store personal settings to home directory.</p>
<p>My settings are in the form of a key/value pair which will be stored as filename/content:</p>
<pre><code>for example:
~/my-github-app
... | 13,669 | 813,080 | 2021-02-02 22:05:04 | 18,325,295 | 11 | 2013-08-20 00:50:39 | 2,698,019 | 2015-05-16 23:28:19 | https://stackoverflow.com/q/18282929 | https://stackoverflow.com/a/18325295 | <p>The only way to make something secure is to use a whitelist. Which means instead of blacklisting bad characters you allow good ones. The reason why blacklists will always fail is that you can't blacklist all of the weird characted, you'd always forget something. Especially if you're working with unicode strings.</p>... | <p>The only way to make something secure is to use a whitelist. Which means instead of blacklisting bad characters you allow good ones. The reason why blacklists will always fail is that you can't blacklist all of the weird characted, you'd always forget something. Especially if you're working with unicode strings.</p>... | 355, 387, 1062 | bash, filenames, validation | <h1>How to validate filename in bash script?</h1>
<p><strong>A little bit about my application:</strong></p>
<p>I am writing a small application in bash script. The application must store personal settings to home directory.</p>
<p>My settings are in the form of a key/value pair which will be stored as filename/conte... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,731 | bash | # How to validate filename in bash script?
**A little bit about my application:**
I am writing a small application in bash script. The application must store personal settings to home directory.
My settings are in the form of a key/value pair which will be stored as filename/content:
```
for example:
~/my-github-ap... | The only way to make something secure is to use a whitelist. Which means instead of blacklisting bad characters you allow good ones. The reason why blacklists will always fail is that you can't blacklist all of the weird characted, you'd always forget something. Especially if you're working with unicode strings.
Filen... |
18084566 | Write to a file with multiple jobs in PowerShell | 6 | 2013-08-06 15:38:09 | <p>We have an activity that runs the following code: </p>
<pre class="lang-powershell prettyprint-override"><code>$nr = $WorkflowData['_Number']
## Write to text
$nr>>C:\Configuration\nrFile.txt
</code></pre>
<p>Basically it gets a unique number that should be added to a file.
The problem is that this activit... | 4,970 | 2,657,325 | 2013-08-06 18:08:35 | 18,085,728 | 11 | 2013-08-06 16:35:33 | 153,982 | 2013-08-06 16:35:33 | https://stackoverflow.com/q/18084566 | https://stackoverflow.com/a/18085728 | <p>You could synchronize file access using a Mutex e.g.</p>
<pre><code>$mutex = new-object System.Threading.Mutex $false,'SomeUniqueName'
...
nr = $WorkflowData['_Number']
$mutex.WaitOne() > $null
$nr >> C:\Configuration\nrFile.txt
$mutex.ReleaseMutex()
</code></pre>
| <p>You could synchronize file access using a Mutex e.g.</p> <pre><code>$mutex = new-object System.Threading.Mutex $false,'SomeUniqueName' ... nr = $WorkflowData['_Number'] $mutex.WaitOne() > $null $nr >> C:\Configuration\nrFile.txt $mutex.ReleaseMutex() </code></pre> | 64, 353, 526 | parallel-processing, powershell, windows | <h1>Write to a file with multiple jobs in PowerShell</h1>
<p>We have an activity that runs the following code: </p>
<pre class="lang-powershell prettyprint-override"><code>$nr = $WorkflowData['_Number']
## Write to text
$nr>>C:\Configuration\nrFile.txt
</code></pre>
<p>Basically it gets a unique number that sh... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,732 | bash | # Write to a file with multiple jobs in PowerShell
We have an activity that runs the following code:
```
$nr = $WorkflowData['_Number']
## Write to text
$nr>>C:\Configuration\nrFile.txt
```
Basically it gets a unique number that should be added to a file.
The problem is that this activity runs in multiple workflows... | You could synchronize file access using a Mutex e.g.
```
$mutex = new-object System.Threading.Mutex $false,'SomeUniqueName'
...
nr = $WorkflowData['_Number']
$mutex.WaitOne() > $null
$nr >> C:\Configuration\nrFile.txt
$mutex.ReleaseMutex()
``` |
17822771 | Testing Shellcode From C - Bus Error 10 | 6 | 2013-07-23 23:35:19 | <p>Below, I written x64 assembly that prints 'Hello, World!' from a syscall on Mac OS X 10.8. It assembles and runs perfect when executed standalone.</p>
<pre><code>; Assemble and link with:
; nasm -f macho64 -o HelloWorld.o HelloWorld.s
; ld -arch x86_64 -o HelloWorld HelloWorld.o
global start
section .text
start:... | 2,766 | 1,801,491 | 2013-07-24 18:24:41 | 17,822,879 | 11 | 2013-07-23 23:46:45 | 116,908 | 2013-07-24 00:19:06 | https://stackoverflow.com/q/17822771 | https://stackoverflow.com/a/17822879 | <p>Your program tries to execute the shellcode from a memory paged marked "<a href="http://en.wikipedia.org/wiki/NX_bit">execute disable</a>", which is the default for memory in the data section. That's why you see the <code>KERN_PROTECTION_FAILURE</code>. You need to put the shellcode in the text section:</p>
<pre>... | <p>Your program tries to execute the shellcode from a memory paged marked "<a href="http://en.wikipedia.org/wiki/NX_bit">execute disable</a>", which is the default for memory in the data section. That's why you see the <code>KERN_PROTECTION_FAILURE</code>. You need to put the shellcode in the text section:</p> <pre>... | 8, 369, 824, 78469 | assembly, c, macos, shellcode | <h1>Testing Shellcode From C - Bus Error 10</h1>
<p>Below, I written x64 assembly that prints 'Hello, World!' from a syscall on Mac OS X 10.8. It assembles and runs perfect when executed standalone.</p>
<pre><code>; Assemble and link with:
; nasm -f macho64 -o HelloWorld.o HelloWorld.s
; ld -arch x86_64 -o HelloWorld ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,733 | bash | # Testing Shellcode From C - Bus Error 10
Below, I written x64 assembly that prints 'Hello, World!' from a syscall on Mac OS X 10.8. It assembles and runs perfect when executed standalone.
```
; Assemble and link with:
; nasm -f macho64 -o HelloWorld.o HelloWorld.s
; ld -arch x86_64 -o HelloWorld HelloWorld.o
global... | Your program tries to execute the shellcode from a memory paged marked "[execute disable](http://en.wikipedia.org/wiki/NX_bit)", which is the default for memory in the data section. That's why you see the `KERN_PROTECTION_FAILURE`. You need to put the shellcode in the text section:
```
__attribute__((section("__TEXT,_... |
16810723 | How to pass a list of files as parameters to a powershell script | 6 | 2013-05-29 09:51:29 | <p>How does one pass a list of files as parameters to a Powershell script?</p>
<pre><code>param
(
[String[]]$files
)
echo $files
</code></pre>
<p>When I try to run it</p>
<pre><code>PS D:\> & '.\merge outputs.ps1' *.dat
</code></pre>
<p>it prints</p>
<pre><code>*.dat
</code></pre>
<p>but I expected so... | 13,471 | 1,671,066 | 2013-06-27 04:12:48 | 17,334,409 | 11 | 2013-06-27 04:12:48 | 115,690 | 2013-06-27 04:12:48 | https://stackoverflow.com/q/16810723 | https://stackoverflow.com/a/17334409 | <p>The two solutions presented thusfar (even though one is accepted and both have upvotes) do not really provide an adequate solution to the question--they both make you jump through hoops. The question as posed stated that by <em>just putting</em> <code>*.dat</code> on the commmand line, how can one make the underlyin... | <p>The two solutions presented thusfar (even though one is accepted and both have upvotes) do not really provide an adequate solution to the question--they both make you jump through hoops. The question as posed stated that by <em>just putting</em> <code>*.dat</code> on the commmand line, how can one make the underlyin... | 526 | powershell | <h1>How to pass a list of files as parameters to a powershell script</h1>
<p>How does one pass a list of files as parameters to a Powershell script?</p>
<pre><code>param
(
[String[]]$files
)
echo $files
</code></pre>
<p>When I try to run it</p>
<pre><code>PS D:\> & '.\merge outputs.ps1' *.dat
</code></pr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,734 | bash | # How to pass a list of files as parameters to a powershell script
How does one pass a list of files as parameters to a Powershell script?
```
param
(
[String[]]$files
)
echo $files
```
When I try to run it
```
PS D:\> & '.\merge outputs.ps1' *.dat
```
it prints
```
*.dat
```
but I expected something simila... | The two solutions presented thusfar (even though one is accepted and both have upvotes) do not really provide an adequate solution to the question--they both make you jump through hoops. The question as posed stated that by *just putting* `*.dat` on the commmand line, how can one make the underlying code treat it *like... |
17290872 | create a child process by fork() a parent process in shell script | 6 | 2013-06-25 06:49:10 | <p>It seems some answers on the site but those seem not to resolve my question.</p>
<p>Say,</p>
<pre><code>#/bin/sh
fpfunction(){
n=1
while (($n<20))
do
echo "Hello World-- $n times"
sleep 2
echo "Hello World2-- $n times"
n=$(( n+1 ))
done
}
fork(){
count=0
while (($count&... | 36,059 | 1,336,041 | 2013-06-25 07:05:38 | 17,290,890 | 11 | 2013-06-25 06:50:21 | 20,862 | 2013-06-25 06:50:21 | https://stackoverflow.com/q/17290872 | https://stackoverflow.com/a/17290890 | <p>The ampersand (<code>&</code>) after a command will run it in a forked subshell.</p>
<pre><code>fpfunction &
</code></pre>
| <p>The ampersand (<code>&</code>) after a command will run it in a forked subshell.</p> <pre><code>fpfunction & </code></pre> | 58, 387, 390 | bash, linux, shell | <h1>create a child process by fork() a parent process in shell script</h1>
<p>It seems some answers on the site but those seem not to resolve my question.</p>
<p>Say,</p>
<pre><code>#/bin/sh
fpfunction(){
n=1
while (($n<20))
do
echo "Hello World-- $n times"
sleep 2
echo "Hello World2-- $n ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,735 | bash | # create a child process by fork() a parent process in shell script
It seems some answers on the site but those seem not to resolve my question.
Say,
```
#/bin/sh
fpfunction(){
n=1
while (($n<20))
do
echo "Hello World-- $n times"
sleep 2
echo "Hello World2-- $n times"
n=$(( n+1 ))
do... | The ampersand (`&`) after a command will run it in a forked subshell.
```
fpfunction &
``` |
17057087 | Bash script: syntax error: unexpected end of file | 6 | 2013-06-12 03:09:07 | <p>I have the following file and I have chmod a+x on the file.
When I try to run it, I get a line 75: syntax error: unexpected end of file. What is the error with my script? What do I need to do to fix it?</p>
<pre><code>#!/bin/sh
# log directory for ascp transfer
logdirectory=/tmp/log20079
# log for this script
basel... | 18,855 | 535,965 | 2013-06-12 03:32:27 | 17,057,182 | 11 | 2013-06-12 03:20:09 | 14,860 | 2013-06-12 03:32:27 | https://stackoverflow.com/q/17057087 | https://stackoverflow.com/a/17057182 | <p>Heredocs are tricky beasts to get right. If you use <code>'EOF'</code> that's <em>exactly</em> what the closing line needs to be, with no whitespace at the front like you have.</p>
<p>Alternatively, you can use the <code><<-</code> variant which strips off all leading tab characters from the lines in the here... | <p>Heredocs are tricky beasts to get right. If you use <code>'EOF'</code> that's <em>exactly</em> what the closing line needs to be, with no whitespace at the front like you have.</p> <p>Alternatively, you can use the <code><<-</code> variant which strips off all leading tab characters from the lines in the here... | 387 | bash | <h1>Bash script: syntax error: unexpected end of file</h1>
<p>I have the following file and I have chmod a+x on the file.
When I try to run it, I get a line 75: syntax error: unexpected end of file. What is the error with my script? What do I need to do to fix it?</p>
<pre><code>#!/bin/sh
# log directory for ascp tran... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,736 | bash | # Bash script: syntax error: unexpected end of file
I have the following file and I have chmod a+x on the file.
When I try to run it, I get a line 75: syntax error: unexpected end of file. What is the error with my script? What do I need to do to fix it?
```
#!/bin/sh
# log directory for ascp transfer
logdirectory=/t... | Heredocs are tricky beasts to get right. If you use `'EOF'` that's *exactly* what the closing line needs to be, with no whitespace at the front like you have.
Alternatively, you can use the `<<-` variant which strips off all leading tab characters from the lines in the heredoc *and* the closing line as per the followi... |
16966938 | How can I convert a string such as 5.7303333333e+02 to decimal in PowerShell? | 6 | 2013-06-06 16:06:57 | <p>I'm trying to convert strings such as <code>5.7303333333e+02</code> to the <code>decimal</code> type. I've tried using <code>[decimal]::TryParse</code> but the return value is false.</p>
<p>Is there a method similar to <code>[datetime]::parseexact</code>, or any clean way to convert these strings? Or am I going to h... | 21,090 | 1,388,357 | 2023-07-25 01:25:55 | 16,966,978 | 11 | 2013-06-06 16:09:35 | 608,772 | 2013-06-06 16:09:35 | https://stackoverflow.com/q/16966938 | https://stackoverflow.com/a/16966978 | <p>What about :</p>
<pre><code>[int]"5.7303333333e+02"
[decimal]"5.7303333333e+02"
</code></pre>
| <p>What about :</p> <pre><code>[int]"5.7303333333e+02" [decimal]"5.7303333333e+02" </code></pre> | 526, 6250, 10528 | data-conversion, decimal, powershell | <h1>How can I convert a string such as 5.7303333333e+02 to decimal in PowerShell?</h1>
<p>I'm trying to convert strings such as <code>5.7303333333e+02</code> to the <code>decimal</code> type. I've tried using <code>[decimal]::TryParse</code> but the return value is false.</p>
<p>Is there a method similar to <code>[date... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,737 | bash | # How can I convert a string such as 5.7303333333e+02 to decimal in PowerShell?
I'm trying to convert strings such as `5.7303333333e+02` to the `decimal` type. I've tried using `[decimal]::TryParse` but the return value is false.
Is there a method similar to `[datetime]::parseexact`, or any clean way to convert these... | What about :
```
[int]"5.7303333333e+02"
[decimal]"5.7303333333e+02"
``` |
16548116 | How to scroll a ListView until I see a specific string with Calabash-Android | 6 | 2013-05-14 16:18:37 | <p>I have exact same question as the post below, except that I need it to work for Android and the post below is for iOS. I have tried both solutions given in that post, but they don't seem to work for Android. All help is appreciated!</p>
<p><a href="https://stackoverflow.com/questions/16339676/how-do-i-scroll-a-uita... | 8,174 | 2,169,359 | 2016-10-18 18:30:18 | 16,632,780 | 11 | 2013-05-19 08:34:00 | 1,259,379 | 2015-07-22 22:59:03 | https://stackoverflow.com/q/16548116 | https://stackoverflow.com/a/16632780 | <p>you can add this new step definition and it should do the trick for Android:</p>
<pre><code>Then /^I scroll until I see the "([^\"]*)" text$/ do |text|
q = query("TextView text:'#{text}'")
while q.empty?
scroll_down
q = query("TextView text:'#{text}'")
end
end
</code></pre>
<p>It works for me and I ... | <p>you can add this new step definition and it should do the trick for Android:</p> <pre><code>Then /^I scroll until I see the "([^\"]*)" text$/ do |text| q = query("TextView text:'#{text}'") while q.empty? scroll_down q = query("TextView text:'#{text}'") end end </code></pre> <p>It works for me and I ... | 1386, 86876, 105995 | android, calabash, calabash-android | <h1>How to scroll a ListView until I see a specific string with Calabash-Android</h1>
<p>I have exact same question as the post below, except that I need it to work for Android and the post below is for iOS. I have tried both solutions given in that post, but they don't seem to work for Android. All help is appreciated... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,738 | bash | # How to scroll a ListView until I see a specific string with Calabash-Android
I have exact same question as the post below, except that I need it to work for Android and the post below is for iOS. I have tried both solutions given in that post, but they don't seem to work for Android. All help is appreciated!
[How d... | you can add this new step definition and it should do the trick for Android:
```
Then /^I scroll until I see the "([^\"]*)" text$/ do |text|
q = query("TextView text:'#{text}'")
while q.empty?
scroll_down
q = query("TextView text:'#{text}'")
end
end
```
It works for me and I hope it does the same for y... |
16102089 | "for i" without "in [sequence]" ending while using getopt | 6 | 2013-04-19 10:03:11 | <p>I've found this example script for using getopt command in shell.</p>
<pre><code>#!/bin/bash
args=$(getopt ab $*)
set -- $args
for i;
do
case "$i" in
-a)shift; echo "it was a";;
-b)shift; echo "it was b";;
esac;
done
</code></pre>
<p>It works well, but I don't understand whe... | 1,136 | 1,167,502 | 2021-12-29 23:58:51 | 16,102,170 | 11 | 2013-04-19 10:06:57 | 1,091,116 | 2013-04-19 16:52:36 | https://stackoverflow.com/q/16102089 | https://stackoverflow.com/a/16102170 | <p>As shown <a href="http://tldp.org/LDP/abs/html/loops1.html#EX23" rel="noreferrer">here</a>, <code>for</code> defaults to <code>$@</code> if no <code>in seq</code> is given. The <code>for i</code> assigns your <code>$i</code> variable.</p>
| <p>As shown <a href="http://tldp.org/LDP/abs/html/loops1.html#EX23" rel="noreferrer">here</a>, <code>for</code> defaults to <code>$@</code> if no <code>in seq</code> is given. The <code>for i</code> assigns your <code>$i</code> variable.</p> | 387, 390, 10831 | bash, getopt, shell | <h1>"for i" without "in [sequence]" ending while using getopt</h1>
<p>I've found this example script for using getopt command in shell.</p>
<pre><code>#!/bin/bash
args=$(getopt ab $*)
set -- $args
for i;
do
case "$i" in
-a)shift; echo "it was a";;
-b)shift; echo "it was b";;
es... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,739 | bash | # "for i" without "in [sequence]" ending while using getopt
I've found this example script for using getopt command in shell.
```
#!/bin/bash
args=$(getopt ab $*)
set -- $args
for i;
do
case "$i" in
-a)shift; echo "it was a";;
-b)shift; echo "it was b";;
esac;
done
```
It works well, but I don't understa... | As shown [here](http://tldp.org/LDP/abs/html/loops1.html#EX23), `for` defaults to `$@` if no `in seq` is given. The `for i` assigns your `$i` variable. |
13146187 | Git: unable to redirect/parse the output of 'git fetch --dry-run' command | 6 | 2012-10-30 19:19:51 | <p>What is special about the output message of <code>git fetch</code> command that is printed on the console? I'm not able to use <code>grep</code>, <code>xargs</code>, etc. Not able to redirect the output to a file also..</p>
<p>Note: I'm using <code>git fetch --dry-run</code> command</p>
<pre><code>[sangeeth@localh... | 3,568 | 1,056,289 | 2023-05-20 07:36:19 | 13,146,297 | 11 | 2012-10-30 19:29:10 | 27,614 | 2012-10-30 19:29:10 | https://stackoverflow.com/q/13146187 | https://stackoverflow.com/a/13146297 | <p>Some of git's status output goes to <code>STDERR</code>. If you want to grep through it, merge STDERR into STDOUT like so:</p>
<pre><code>git fetch --dry-run 2>&1 | grep ssh
</code></pre>
| <p>Some of git's status output goes to <code>STDERR</code>. If you want to grep through it, merge STDERR into STDOUT like so:</p> <pre><code>git fetch --dry-run 2>&1 | grep ssh </code></pre> | 119, 387, 390, 26698 | bash, git, io-redirection, shell | <h1>Git: unable to redirect/parse the output of 'git fetch --dry-run' command</h1>
<p>What is special about the output message of <code>git fetch</code> command that is printed on the console? I'm not able to use <code>grep</code>, <code>xargs</code>, etc. Not able to redirect the output to a file also..</p>
<p>Note: ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,741 | bash | # Git: unable to redirect/parse the output of 'git fetch --dry-run' command
What is special about the output message of `git fetch` command that is printed on the console? I'm not able to use `grep`, `xargs`, etc. Not able to redirect the output to a file also..
Note: I'm using `git fetch --dry-run` command
```
[san... | Some of git's status output goes to `STDERR`. If you want to grep through it, merge STDERR into STDOUT like so:
```
git fetch --dry-run 2>&1 | grep ssh
``` |
12948456 | Is there any difference between '=' and '==' operators in bash or sh | 6 | 2012-10-18 06:31:44 | <p>I realized that both '=' and '==' operators works in if statement. For example:</p>
<pre><code>var="some string"
if [ "$var" == "some string" ];then
#doing something
fi
if [ "$var" = "some string" ];then
#doing something
fi
</code></pre>
<p>Both if statement... | 8,502 | 702,642 | 2026-01-13 10:07:55 | 12,948,608 | 11 | 2012-10-18 06:42:11 | 1,741,864 | 2012-10-18 06:42:11 | https://stackoverflow.com/q/12948456 | https://stackoverflow.com/a/12948608 | <p>Inside single brackets for condition test (i.e. [ ... ]), single = is supported by all shells, where as == is not supported by some of the older shells.</p>
<p>Inside double brackets for condition test (i.e. [[ ... ]]), there is no difference in old or new shells.</p>
<p>Edit: I should also note that: Always use d... | <p>Inside single brackets for condition test (i.e. [ ... ]), single = is supported by all shells, where as == is not supported by some of the older shells.</p> <p>Inside double brackets for condition test (i.e. [[ ... ]]), there is no difference in old or new shells.</p> <p>Edit: I should also note that: Always use d... | 58, 387, 390, 7992 | bash, linux, operators, shell | <h1>Is there any difference between '=' and '==' operators in bash or sh</h1>
<p>I realized that both '=' and '==' operators works in if statement. For example:</p>
<pre><code>var="some string"
if [ "$var" == "some string" ];then
#doing something
fi
if [ "$var" = "some ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,742 | bash | # Is there any difference between '=' and '==' operators in bash or sh
I realized that both '=' and '==' operators works in if statement. For example:
```
var="some string"
if [ "$var" == "some string" ];then
#doing something
fi
if [ "$var" = "some string" ];then
#doing something
fi
```
Both if statement ab... | Inside single brackets for condition test (i.e. [ ... ]), single = is supported by all shells, where as == is not supported by some of the older shells.
Inside double brackets for condition test (i.e. [[ ... ]]), there is no difference in old or new shells.
Edit: I should also note that: Always use double brackets [[... |
12930762 | How to pass arguments to PowerShell via C# | 6 | 2012-10-17 09:06:51 | <p>I having issues with passing arguments to PowerShell via C#</p>
<p>I am getting the following exception:</p>
<blockquote>
<p>"A command that prompts the user failed because the host program or
the command type does not support user interaction. Try a host program
that supports user interaction, such as the W... | 4,821 | 829,174 | 2012-10-17 10:36:29 | 12,932,309 | 11 | 2012-10-17 10:30:56 | 323,582 | 2012-10-17 10:36:29 | https://stackoverflow.com/q/12930762 | https://stackoverflow.com/a/12932309 | <p>The exception is not about arguments. Either do not use commands that require host UI implemented (<code>Write-Host</code> included) or implement you own custom host (<code>PSHost</code>) and this UI (<code>PSHostUserInterface</code>). Here is the example of a simple host (and there is much more on MSDN about this, ... | <p>The exception is not about arguments. Either do not use commands that require host UI implemented (<code>Write-Host</code> included) or implement you own custom host (<code>PSHost</code>) and this UI (<code>PSHostUserInterface</code>). Here is the example of a simple host (and there is much more on MSDN about this, ... | 9, 526 | c#, powershell | <h1>How to pass arguments to PowerShell via C#</h1>
<p>I having issues with passing arguments to PowerShell via C#</p>
<p>I am getting the following exception:</p>
<blockquote>
<p>"A command that prompts the user failed because the host program or
the command type does not support user interaction. Try a host pro... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,743 | bash | # How to pass arguments to PowerShell via C#
I having issues with passing arguments to PowerShell via C#
I am getting the following exception:
> "A command that prompts the user failed because the host program or
> the command type does not support user interaction. Try a host program
> that supports user interactio... | The exception is not about arguments. Either do not use commands that require host UI implemented (`Write-Host` included) or implement you own custom host (`PSHost`) and this UI (`PSHostUserInterface`). Here is the example of a simple host (and there is much more on MSDN about this, if you choose this way):
<http://msd... |
12748928 | Force a PowerShell script to be run as administrator | 6 | 2012-10-05 15:00:06 | <p>I have written a powershell script that installs and starts some services. It will only work if the script is run as administrator. Is there any way force a script to have those privileges?</p>
| 31,472 | 648,814 | 2013-06-26 23:10:06 | 12,757,026 | 11 | 2012-10-06 05:29:01 | 608,772 | 2012-10-06 05:29:01 | https://stackoverflow.com/q/12748928 | https://stackoverflow.com/a/12757026 | <p>In the case you are using PowerShell V2 You can also do the following :</p>
<pre><code>Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Service"'
</code></pre>
<p>This would run "Get-Service" as administrator, you can replace it with your script.</p>
| <p>In the case you are using PowerShell V2 You can also do the following :</p> <pre><code>Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Service"' </code></pre> <p>This would run "Get-Service" as administrator, you can replace it with your script.</p> | 526 | powershell | <h1>Force a PowerShell script to be run as administrator</h1>
<p>I have written a powershell script that installs and starts some services. It will only work if the script is run as administrator. Is there any way force a script to have those privileges?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,744 | bash | # Force a PowerShell script to be run as administrator
I have written a powershell script that installs and starts some services. It will only work if the script is run as administrator. Is there any way force a script to have those privileges? | In the case you are using PowerShell V2 You can also do the following :
```
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Service"'
```
This would run "Get-Service" as administrator, you can replace it with your script. |
12335356 | How to handle error/exception in shell script? | 6 | 2012-09-08 23:38:25 | <p>Below is my script that I am executing in the bash. And it works fine.</p>
<pre><code>fileexist=0
for i in $( ls /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate#.done); do
mv /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate#.done /data/read-only/clv/daily/archieve-wip/
fileexi... | 25,840 | 663,148 | 2012-09-19 12:13:20 | 12,337,030 | 11 | 2012-09-09 06:30:28 | 1,600,898 | 2012-09-19 12:13:20 | https://stackoverflow.com/q/12335356 | https://stackoverflow.com/a/12337030 | <p>You can check for the exit status of each command, as freetx answered, but this is manual error checking rather than exception handling. The standard way to get the equivalent of exception handling in <code>sh</code> is to start the script with <code>set -e</code>. That tells <code>sh</code> to exit with a non-zero ... | <p>You can check for the exit status of each command, as freetx answered, but this is manual error checking rather than exception handling. The standard way to get the equivalent of exception handling in <code>sh</code> is to start the script with <code>set -e</code>. That tells <code>sh</code> to exit with a non-zero ... | 34, 58, 387, 390 | bash, linux, shell, unix | <h1>How to handle error/exception in shell script?</h1>
<p>Below is my script that I am executing in the bash. And it works fine.</p>
<pre><code>fileexist=0
for i in $( ls /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate#.done); do
mv /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,745 | bash | # How to handle error/exception in shell script?
Below is my script that I am executing in the bash. And it works fine.
```
fileexist=0
for i in $( ls /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate#.done); do
mv /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate#.done /data/read-only/clv/d... | You can check for the exit status of each command, as freetx answered, but this is manual error checking rather than exception handling. The standard way to get the equivalent of exception handling in `sh` is to start the script with `set -e`. That tells `sh` to exit with a non-zero status as soon as any executed comma... |
10698751 | Append to protected file | 6 | 2012-05-22 08:54:33 | <p>I want to do something along the lines of: </p>
<pre><code>echo "Append string" >> protected_file
</code></pre>
<p>However, as this file is write protected I get an error. Running: </p>
<pre><code>sudo echo "Append string" >> protected_file
</code></pre>
<p>seems to run sudo on the echo command, and ... | 1,349 | 169,157 | 2014-10-01 16:12:54 | 10,704,470 | 11 | 2012-05-22 14:50:00 | 26,428 | 2012-05-22 14:50:00 | https://stackoverflow.com/q/10698751 | https://stackoverflow.com/a/10704470 | <pre><code>echo "Append string" | sudo tee -a protected_file >/dev/null
</code></pre>
| <pre><code>echo "Append string" | sudo tee -a protected_file >/dev/null </code></pre> | 34, 369, 387, 390 | bash, macos, shell, unix | <h1>Append to protected file</h1>
<p>I want to do something along the lines of: </p>
<pre><code>echo "Append string" >> protected_file
</code></pre>
<p>However, as this file is write protected I get an error. Running: </p>
<pre><code>sudo echo "Append string" >> protected_file
</code></pre>
<p>seems to ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,746 | bash | # Append to protected file
I want to do something along the lines of:
```
echo "Append string" >> protected_file
```
However, as this file is write protected I get an error. Running:
```
sudo echo "Append string" >> protected_file
```
seems to run sudo on the echo command, and still gives me the permission error, ... | ```
echo "Append string" | sudo tee -a protected_file >/dev/null
``` |
10456228 | Bash PS1 window title? | 6 | 2012-05-04 21:14:34 | <p>Say I have this as my PS1</p>
<pre><code>PS1='\[\e]0;TITLE\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
</code></pre>
<p>it will give me this prompt</p>
<pre><code>Steven@Steven-PC ~
$
</code></pre>
<p>with a window title as <code>TITLE</code></p>
<p>I understand that this part</p>
<pre><code>\e]0;TITLE\a
</code... | 3,721 | 1,002,260 | 2023-10-02 15:22:07 | 10,456,497 | 11 | 2012-05-04 21:41:34 | 20,862 | 2023-10-02 15:22:07 | https://stackoverflow.com/q/10456228 | https://stackoverflow.com/a/10456497 | <p>The terminal emulator looks for output containing that specific code (<code>\e]0;</code>) and uses everything up to the <code>\a</code> as the terminal window title.</p>
| <p>The terminal emulator looks for output containing that specific code (<code>\e]0;</code>) and uses everything up to the <code>\a</code> as the terminal window title.</p> | 387, 53034 | bash, ps1 | <h1>Bash PS1 window title?</h1>
<p>Say I have this as my PS1</p>
<pre><code>PS1='\[\e]0;TITLE\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
</code></pre>
<p>it will give me this prompt</p>
<pre><code>Steven@Steven-PC ~
$
</code></pre>
<p>with a window title as <code>TITLE</code></p>
<p>I understand that this part</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,747 | bash | # Bash PS1 window title?
Say I have this as my PS1
```
PS1='\[\e]0;TITLE\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
```
it will give me this prompt
```
Steven@Steven-PC ~
$
```
with a window title as `TITLE`
I understand that this part
```
\e]0;TITLE\a
```
creates the title, but I don't understand why. It... | The terminal emulator looks for output containing that specific code (`\e]0;`) and uses everything up to the `\a` as the terminal window title. |
9573922 | Grails shell doesn't recompile changed files | 6 | 2012-03-05 21:01:34 | <p>I'm new to grails and came across an issue of grails shell not recompiling my classes even though displaying a message about it. Here is what I'm doing:</p>
<ol>
<li>I have a grails 2.0.0 app that has class with certain static methods</li>
<li>I would like to test some of the functionality from grails shell, so I g... | 1,388 | 190,335 | 2012-03-05 22:03:41 | 9,574,732 | 11 | 2012-03-05 22:03:41 | 160,313 | 2012-03-05 22:03:41 | https://stackoverflow.com/q/9573922 | https://stackoverflow.com/a/9574732 | <p>Only <code>run-app</code> enables reloading by default. Run <code>grails -reloading shell</code> to reload changed files. I'd use the console though - it's way more user-friendly: <code>grails -reloading console</code>.</p>
| <p>Only <code>run-app</code> enables reloading by default. Run <code>grails -reloading shell</code> to reload changed files. I'd use the console though - it's way more user-friendly: <code>grails -reloading console</code>.</p> | 390, 848, 849, 1758, 18272 | grails, groovy, recompile, shell, static-methods | <h1>Grails shell doesn't recompile changed files</h1>
<p>I'm new to grails and came across an issue of grails shell not recompiling my classes even though displaying a message about it. Here is what I'm doing:</p>
<ol>
<li>I have a grails 2.0.0 app that has class with certain static methods</li>
<li>I would like to te... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,748 | bash | # Grails shell doesn't recompile changed files
I'm new to grails and came across an issue of grails shell not recompiling my classes even though displaying a message about it. Here is what I'm doing:
1. I have a grails 2.0.0 app that has class with certain static methods
2. I would like to test some of the functional... | Only `run-app` enables reloading by default. Run `grails -reloading shell` to reload changed files. I'd use the console though - it's way more user-friendly: `grails -reloading console`. |
8950367 | Writing my own shell in C, how do I run Unix executables? | 6 | 2012-01-21 03:16:03 | <p>In one of my courses we're writing our own shell (basically from scratch).</p>
<p>We've already handled writing a lexer and a parser to divide the input into nice "command" structures that are easier to deal with. Likewise, I have a function <code>read_command()</code> that will read one command in at a time and f... | 2,335 | 681,523 | 2012-09-19 01:53:51 | 8,950,391 | 11 | 2012-01-21 03:21:13 | 116,908 | 2012-01-21 03:26:50 | https://stackoverflow.com/q/8950367 | https://stackoverflow.com/a/8950391 | <ol>
<li>Check out <a href="http://linux.die.net/man/3/getenv" rel="noreferrer"><code>getenv(3)</code></a> and its relatives. You probably don't actually need to directly do any operations on directories, but if you do, you can use <a href="http://linux.die.net/man/3/opendir" rel="noreferrer"><code>opendir(3)</code></... | <ol> <li>Check out <a href="http://linux.die.net/man/3/getenv" rel="noreferrer"><code>getenv(3)</code></a> and its relatives. You probably don't actually need to directly do any operations on directories, but if you do, you can use <a href="http://linux.die.net/man/3/opendir" rel="noreferrer"><code>opendir(3)</code></... | 8, 34, 390, 6268 | c, path, shell, unix | <h1>Writing my own shell in C, how do I run Unix executables?</h1>
<p>In one of my courses we're writing our own shell (basically from scratch).</p>
<p>We've already handled writing a lexer and a parser to divide the input into nice "command" structures that are easier to deal with. Likewise, I have a function <code>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,749 | bash | # Writing my own shell in C, how do I run Unix executables?
In one of my courses we're writing our own shell (basically from scratch).
We've already handled writing a lexer and a parser to divide the input into nice "command" structures that are easier to deal with. Likewise, I have a function `read_command()` that w... | 1. Check out [`getenv(3)`](http://linux.die.net/man/3/getenv) and its relatives. You probably don't actually need to directly do any operations on directories, but if you do, you can use [`opendir(3)`](http://linux.die.net/man/3/opendir), [`readdir(3)`](http://linux.die.net/man/3/readdir), [`closedir(3)`](http://linux.... |
8314219 | How to get the percent of packets received from Ping in bash? | 6 | 2011-11-29 16:28:46 | <p>When pinging a host I want my output just to show the percentage of packets (5 sent) received. I assume I need to use <code>grep</code> somehow but I can't figure out how (I'm new to bash programming). Here is where I am: <code>ping -c 5 -q $host | grep ?</code>. What should go in grep? I think I will have to do som... | 18,625 | 993,805 | 2014-08-20 22:58:53 | 8,314,416 | 11 | 2011-11-29 16:44:05 | 119,159 | 2011-11-29 16:44:05 | https://stackoverflow.com/q/8314219 | https://stackoverflow.com/a/8314416 | <p>As always, there are many different ways to do this., but here's one option:</p>
<p>This expression will capture the percent digits from "X% packet loss"</p>
<pre><code>ping -c 5 -q $host | grep -oP '\d+(?=% packet loss)'
</code></pre>
<p>You can then subtract the "loss" percentage from 100 to get the "success" p... | <p>As always, there are many different ways to do this., but here's one option:</p> <p>This expression will capture the percent digits from "X% packet loss"</p> <pre><code>ping -c 5 -q $host | grep -oP '\d+(?=% packet loss)' </code></pre> <p>You can then subtract the "loss" percentage from 100 to get the "success" p... | 58, 387, 5649 | bash, linux, ping | <h1>How to get the percent of packets received from Ping in bash?</h1>
<p>When pinging a host I want my output just to show the percentage of packets (5 sent) received. I assume I need to use <code>grep</code> somehow but I can't figure out how (I'm new to bash programming). Here is where I am: <code>ping -c 5 -q $host... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,750 | bash | # How to get the percent of packets received from Ping in bash?
When pinging a host I want my output just to show the percentage of packets (5 sent) received. I assume I need to use `grep` somehow but I can't figure out how (I'm new to bash programming). Here is where I am: `ping -c 5 -q $host | grep ?`. What should g... | As always, there are many different ways to do this., but here's one option:
This expression will capture the percent digits from "X% packet loss"
```
ping -c 5 -q $host | grep -oP '\d+(?=% packet loss)'
```
You can then subtract the "loss" percentage from 100 to get the "success" percentage:
```
packet_loss=$(ping... |
7787633 | linux: most recent file in a directory, excluding directories and . files | 6 | 2011-10-16 21:59:17 | <p>I would like to find the most recently changed file in a directory, excluding hidden files (the ones that start with .) and also excluding directories.</p>
<p>This question is headed in the right direction, but not exactly what I need:</p>
<p><a href="https://stackoverflow.com/questions/1015678/linux-most-recent-f... | 4,761 | 288,032 | 2011-10-17 11:10:31 | 7,787,660 | 11 | 2011-10-16 22:03:12 | 328,764 | 2011-10-16 22:48:18 | https://stackoverflow.com/q/7787633 | https://stackoverflow.com/a/7787660 | <p>Like the answer there except without -A</p>
<pre><code>ls -rt | tail -n 1
</code></pre>
<p>Look at <code>man ls</code> for more info.</p>
<p>To make it exclude directories, we use the -F option to add a "/" to each directory, and then filter for those that don't have the "/":</p>
<pre><code>ls -Frt | grep "[^/]$... | <p>Like the answer there except without -A</p> <pre><code>ls -rt | tail -n 1 </code></pre> <p>Look at <code>man ls</code> for more info.</p> <p>To make it exclude directories, we use the -F option to add a "/" to each directory, and then filter for those that don't have the "/":</p> <pre><code>ls -Frt | grep "[^/]$... | 34, 58, 218, 387, 10193 | bash, directory, find, linux, unix | <h1>linux: most recent file in a directory, excluding directories and . files</h1>
<p>I would like to find the most recently changed file in a directory, excluding hidden files (the ones that start with .) and also excluding directories.</p>
<p>This question is headed in the right direction, but not exactly what I nee... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,751 | bash | # linux: most recent file in a directory, excluding directories and . files
I would like to find the most recently changed file in a directory, excluding hidden files (the ones that start with .) and also excluding directories.
This question is headed in the right direction, but not exactly what I need:
[Linux: Most... | Like the answer there except without -A
```
ls -rt | tail -n 1
```
Look at `man ls` for more info.
To make it exclude directories, we use the -F option to add a "/" to each directory, and then filter for those that don't have the "/":
```
ls -Frt | grep "[^/]$" | tail -n 1
``` |
7362798 | Powershell Select-Object vs ForEach on Select-String results | 6 | 2011-09-09 14:00:03 | <p>Let's say I have the results of a call to Select-String in a variable $mat, parsing a regular expression from file contents:</p>
<pre><code>$mat = cat errors.txt | Select-String "'(?<code>\w+)'.+ID (?<id>[^:]+)"
</code></pre>
<p>According to the output of <code>$mat | Get-Member</code> the res... | 22,319 | 299,354 | 2022-06-23 09:33:50 | 7,363,134 | 11 | 2011-09-09 14:23:54 | 291,709 | 2011-09-09 17:42:04 | https://stackoverflow.com/q/7362798 | https://stackoverflow.com/a/7363134 | <p>When displaying properties, PowerShell auto-formats the properties of types that do not have a display format defined in a <code>*.format.ps1xml</code> file as a table for up to 4 properties. 5 or more properties displays as a list. When you select the Matches property with <code>Select-Object</code>, you are select... | <p>When displaying properties, PowerShell auto-formats the properties of types that do not have a display format defined in a <code>*.format.ps1xml</code> file as a table for up to 4 properties. 5 or more properties displays as a list. When you select the Matches property with <code>Select-Object</code>, you are select... | 18, 526 | powershell, regex | <h1>Powershell Select-Object vs ForEach on Select-String results</h1>
<p>Let's say I have the results of a call to Select-String in a variable $mat, parsing a regular expression from file contents:</p>
<pre><code>$mat = cat errors.txt | Select-String "'(?<code>\w+)'.+ID (?<id>[^:]+)"
</code></pre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,752 | bash | # Powershell Select-Object vs ForEach on Select-String results
Let's say I have the results of a call to Select-String in a variable $mat, parsing a regular expression from file contents:
```
$mat = cat errors.txt | Select-String "'(?<code>\w+)'.+ID (?<id>[^:]+)"
```
According to the output of `$mat | Get-Member` th... | When displaying properties, PowerShell auto-formats the properties of types that do not have a display format defined in a `*.format.ps1xml` file as a table for up to 4 properties. 5 or more properties displays as a list. When you select the Matches property with `Select-Object`, you are selecting a single property of ... |
6988513 | Powershell: Get return result from Powershell Script called from Within other PS Script | 6 | 2011-08-08 20:59:49 | <p><strong>Background:</strong>
I have a powershell script:<code>script1</code> that takes in a <code>sourceDirectory</code> and two destinations (call them <code>dest1Directory</code> and <code>dest2Directory</code>).</p>
<p>The sourceDirectory is structured like this:</p>
<blockquote>
<p>\Source\dest1\STUFF1</p>
... | 34,063 | 800,620 | 2011-08-09 16:58:06 | 6,989,175 | 11 | 2011-08-08 22:05:10 | 526,535 | 2011-08-08 22:05:10 | https://stackoverflow.com/q/6988513 | https://stackoverflow.com/a/6989175 | <p>Any uncaptured output is returned in Powershell.</p>
<p>So something like</p>
<pre><code>return $returnRollBackObj
</code></pre>
<p>is equivalent to</p>
<pre><code>$returnRollBackObj
return
</code></pre>
<p>So, since script2 is returning these objects, as long as these objects are not captured in script1, they ... | <p>Any uncaptured output is returned in Powershell.</p> <p>So something like</p> <pre><code>return $returnRollBackObj </code></pre> <p>is equivalent to</p> <pre><code>$returnRollBackObj return </code></pre> <p>So, since script2 is returning these objects, as long as these objects are not captured in script1, they ... | 526, 9206, 14456 | powershell, return-value, visual-studio-2010 | <h1>Powershell: Get return result from Powershell Script called from Within other PS Script</h1>
<p><strong>Background:</strong>
I have a powershell script:<code>script1</code> that takes in a <code>sourceDirectory</code> and two destinations (call them <code>dest1Directory</code> and <code>dest2Directory</code>).</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,753 | bash | # Powershell: Get return result from Powershell Script called from Within other PS Script
**Background:**
I have a powershell script:`script1` that takes in a `sourceDirectory` and two destinations (call them `dest1Directory` and `dest2Directory`).
The sourceDirectory is structured like this:
> \Source\dest1\STUFF1
... | Any uncaptured output is returned in Powershell.
So something like
```
return $returnRollBackObj
```
is equivalent to
```
$returnRollBackObj
return
```
So, since script2 is returning these objects, as long as these objects are not captured in script1, they will be returned by script1 as well. So you not have to do... |
5621954 | How can you add a Certificate to WebClient in Powershell | 6 | 2011-04-11 13:21:00 | <p>I wan't to examine a Webpage which requires Client Side Certificate Authentication.
How can i provide my Cert from the Certstore to the Webrequest:
Is there a way to specify this in Credentials odr within the Proxy?</p>
<pre><code>$webclient = New-Object Net.WebClient
# The next 5 lines are required if your network... | 10,582 | 232,756 | 2013-12-10 15:24:49 | 5,797,327 | 11 | 2011-04-26 22:42:19 | 243 | 2011-04-26 22:57:19 | https://stackoverflow.com/q/5621954 | https://stackoverflow.com/a/5797327 | <p>Using the new <a href="http://technet.microsoft.com/en-us/library/dd315241.aspx" rel="noreferrer">Add-Type</a> functionality in PowerShell v2, you can craft a custom class that you can then use to make your typical WebRequest. I have included a method on the custom class to allow you to add certificates that can be ... | <p>Using the new <a href="http://technet.microsoft.com/en-us/library/dd315241.aspx" rel="noreferrer">Add-Type</a> functionality in PowerShell v2, you can craft a custom class that you can then use to make your typical WebRequest. I have included a method on the custom class to allow you to add certificates that can be ... | 183, 526, 3487, 5954 | authentication, certificate, powershell, webclient | <h1>How can you add a Certificate to WebClient in Powershell</h1>
<p>I wan't to examine a Webpage which requires Client Side Certificate Authentication.
How can i provide my Cert from the Certstore to the Webrequest:
Is there a way to specify this in Credentials odr within the Proxy?</p>
<pre><code>$webclient = New-Ob... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,754 | bash | # How can you add a Certificate to WebClient in Powershell
I wan't to examine a Webpage which requires Client Side Certificate Authentication.
How can i provide my Cert from the Certstore to the Webrequest:
Is there a way to specify this in Credentials odr within the Proxy?
```
$webclient = New-Object Net.WebClient
#... | Using the new [Add-Type](http://technet.microsoft.com/en-us/library/dd315241.aspx) functionality in PowerShell v2, you can craft a custom class that you can then use to make your typical WebRequest. I have included a method on the custom class to allow you to add certificates that can be used for authentication.
```
P... |
4750305 | How to check if asp.net mvc 3 is installed? | 6 | 2011-01-20 17:16:18 | <p>I'm trying to write a powershell script that would install asp.net mvc 3 if it is not already installed. How do i check if a specific version of asp.net mvc 3 is installed?</p>
| 16,915 | 89,605 | 2011-01-21 22:17:10 | 4,750,445 | 11 | 2011-01-20 17:28:35 | 8,718 | 2011-01-20 17:28:35 | https://stackoverflow.com/q/4750305 | https://stackoverflow.com/a/4750445 | <p>I think you can't change the location of the install folder, so you could probably just:</p>
<pre><code>test-path "${Env:ProgramFiles(x86)}\Microsoft ASP.NET\ASP.NET MVC 3"
</code></pre>
| <p>I think you can't change the location of the install folder, so you could probably just:</p> <pre><code>test-path "${Env:ProgramFiles(x86)}\Microsoft ASP.NET\ASP.NET MVC 3" </code></pre> | 526 | powershell | <h1>How to check if asp.net mvc 3 is installed?</h1>
<p>I'm trying to write a powershell script that would install asp.net mvc 3 if it is not already installed. How do i check if a specific version of asp.net mvc 3 is installed?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,755 | bash | # How to check if asp.net mvc 3 is installed?
I'm trying to write a powershell script that would install asp.net mvc 3 if it is not already installed. How do i check if a specific version of asp.net mvc 3 is installed? | I think you can't change the location of the install folder, so you could probably just:
```
test-path "${Env:ProgramFiles(x86)}\Microsoft ASP.NET\ASP.NET MVC 3"
``` |
4440842 | Test if a variable is read-only | 6 | 2010-12-14 15:36:39 | <p>To test if a variable is read-only, there are the following ugly hacks:</p>
<pre><code># True if readonly
readonly -p | egrep "declare -[:lower:]+ ${var}="
# False if readonly
temp="$var"; eval $var=x 2>/dev/null && eval $var=\$temp
</code></pre>
<p>Is there a more elegant solution?</p>
| 3,864 | 96,588 | 2024-09-21 07:06:44 | 4,441,178 | 11 | 2010-12-14 16:03:42 | 212,846 | 2010-12-14 16:03:42 | https://stackoverflow.com/q/4440842 | https://stackoverflow.com/a/4441178 | <p>Using a subshell seems to work. Both with local and exported variables.</p>
<pre><code>$ foo=123
$ bar=456
$ readonly foo
$ echo $foo $bar
123 456
$ (unset foo 2> /dev/null) || echo "Read only"
Read only
$ (unset bar 2> /dev/null) || echo "Read only"
$
$ echo $foo $bar
123 456 # Still intact :-... | <p>Using a subshell seems to work. Both with local and exported variables.</p> <pre><code>$ foo=123 $ bar=456 $ readonly foo $ echo $foo $bar 123 456 $ (unset foo 2> /dev/null) || echo "Read only" Read only $ (unset bar 2> /dev/null) || echo "Read only" $ $ echo $foo $bar 123 456 # Still intact :-... | 387 | bash | <h1>Test if a variable is read-only</h1>
<p>To test if a variable is read-only, there are the following ugly hacks:</p>
<pre><code># True if readonly
readonly -p | egrep "declare -[:lower:]+ ${var}="
# False if readonly
temp="$var"; eval $var=x 2>/dev/null && eval $var=\$temp
</code></pre>
<p>Is there a m... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,756 | bash | # Test if a variable is read-only
To test if a variable is read-only, there are the following ugly hacks:
```
# True if readonly
readonly -p | egrep "declare -[:lower:]+ ${var}="
# False if readonly
temp="$var"; eval $var=x 2>/dev/null && eval $var=\$temp
```
Is there a more elegant solution? | Using a subshell seems to work. Both with local and exported variables.
```
$ foo=123
$ bar=456
$ readonly foo
$ echo $foo $bar
123 456
$ (unset foo 2> /dev/null) || echo "Read only"
Read only
$ (unset bar 2> /dev/null) || echo "Read only"
$
$ echo $foo $bar
123 456 # Still intact :-)
```
The important... |
4119991 | Bash: call script with customized keyboard shortcuts? | 6 | 2010-11-07 22:14:52 | <p>Lets say I have a script, "<code>myscript.sh</code>", with contents being simply <code>echo $PWD</code>. I'd like to bind somehow this script to a key combo in <code>bash</code> (<code>gnome-terminal</code>) - so that when I press this key combination, the output of "<code>myscript.sh</code>" is inserted ("pasted") ... | 10,013 | 277,826 | 2010-11-08 10:49:00 | 4,120,926 | 11 | 2010-11-08 02:50:32 | 26,428 | 2010-11-08 10:49:00 | https://stackoverflow.com/q/4119991 | https://stackoverflow.com/a/4120926 | <h3>Simple version:</h3>
<p>This command at a shell prompt:</p>
<pre><code>bind '"\ee": "${PWD##*/}\e\C-e"'
</code></pre>
<p>or this line added to your <code>~/.inputrc</code>:</p>
<pre><code>"\ee": "${PWD##*/}\e\C-e"
</code></pre>
<p>will cause <kbd>Alt</kbd>-<kbd>e</kbd> to ins... | <h3>Simple version:</h3> <p>This command at a shell prompt:</p> <pre><code>bind '"\ee": "${PWD##*/}\e\C-e"' </code></pre> <p>or this line added to your <code>~/.inputrc</code>:</p> <pre><code>"\ee": "${PWD##*/}\e\C-e" </code></pre> <p>will cause <kbd>Alt</kbd>-<kbd>e</kbd> to ins... | 58, 387, 964, 4198, 10353 | bash, customization, keyboard-shortcuts, linux, readline | <h1>Bash: call script with customized keyboard shortcuts?</h1>
<p>Lets say I have a script, "<code>myscript.sh</code>", with contents being simply <code>echo $PWD</code>. I'd like to bind somehow this script to a key combo in <code>bash</code> (<code>gnome-terminal</code>) - so that when I press this key combination, t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,757 | bash | # Bash: call script with customized keyboard shortcuts?
Lets say I have a script, "`myscript.sh`", with contents being simply `echo $PWD`. I'd like to bind somehow this script to a key combo in `bash` (`gnome-terminal`) - so that when I press this key combination, the output of "`myscript.sh`" is inserted ("pasted") a... | ### Simple version:
This command at a shell prompt:
```
bind '"\ee": "${PWD##*/}\e\C-e"'
```
or this line added to your `~/.inputrc`:
```
"\ee": "${PWD##*/}\e\C-e"
```
will cause `Alt`-`e` to insert the basename of the current directory on the command line. It requires that the default binding of the readline func... |
4031416 | Prevent parent directories from being tarred | 6 | 2010-10-27 08:54:02 | <p>Basically I just want to tar all the files in a directory, but not get all the parent directories in the archive.</p>
<p>I've tried -C, but I guess I'm not using it right.</p>
<pre><code>tar -cjf archive.tar.bz2 -C /var/some/log/path ./*
</code></pre>
<p>This results in tar trying to add all the files in the CWD.... | 3,822 | 484,934 | 2011-04-17 20:30:48 | 4,031,451 | 11 | 2010-10-27 09:00:01 | 276,052 | 2010-10-27 16:53:42 | https://stackoverflow.com/q/4031416 | https://stackoverflow.com/a/4031451 | <p>The parent directory (<code>/var/some/log</code>) is included, since <code>/var/some/log/path/..</code> is included when you do <code>./*</code>. Try just doing</p>
<pre><code>tar -cjf archive.tar.bz2 -C /var/some/log/path .
</code></pre>
<p>Test run:</p>
<pre><code>$ find tmp/some_files
tmp/some_files
tmp/some_f... | <p>The parent directory (<code>/var/some/log</code>) is included, since <code>/var/some/log/path/..</code> is included when you do <code>./*</code>. Try just doing</p> <pre><code>tar -cjf archive.tar.bz2 -C /var/some/log/path . </code></pre> <p>Test run:</p> <pre><code>$ find tmp/some_files tmp/some_files tmp/some_f... | 390, 8773 | shell, tar | <h1>Prevent parent directories from being tarred</h1>
<p>Basically I just want to tar all the files in a directory, but not get all the parent directories in the archive.</p>
<p>I've tried -C, but I guess I'm not using it right.</p>
<pre><code>tar -cjf archive.tar.bz2 -C /var/some/log/path ./*
</code></pre>
<p>This ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,758 | bash | # Prevent parent directories from being tarred
Basically I just want to tar all the files in a directory, but not get all the parent directories in the archive.
I've tried -C, but I guess I'm not using it right.
```
tar -cjf archive.tar.bz2 -C /var/some/log/path ./*
```
This results in tar trying to add all the fil... | The parent directory (`/var/some/log`) is included, since `/var/some/log/path/..` is included when you do `./*`. Try just doing
```
tar -cjf archive.tar.bz2 -C /var/some/log/path .
```
Test run:
```
$ find tmp/some_files
tmp/some_files
tmp/some_files/dir1
tmp/some_files/dir1/dir1file
tmp/some_files/hello
tmp/some_fi... |
3959521 | Access shell environment variables in Java | 6 | 2010-10-18 13:16:01 | <p>Does anyone know how to access the environment variables of the standard shell environment in Java? I am using the ProcessBuilder class and I have to specify specific environment variables used in a shell script I am running, these variables exist in the standard shell environment.</p>
<p>Accessing ProcessBuilder e... | 11,699 | 138,466 | 2014-11-26 21:04:13 | 3,959,550 | 11 | 2010-10-18 13:18:32 | 58,074 | 2010-10-18 13:18:32 | https://stackoverflow.com/q/3959521 | https://stackoverflow.com/a/3959550 | <p>You can get at the environment variables that existed when your program was created through <code>System.getenv()</code>:</p>
<p><a href="http://download.oracle.com/javase/tutorial/essential/environment/env.html" rel="noreferrer">http://download.oracle.com/javase/tutorial/essential/environment/env.html</a></p>
<bl... | <p>You can get at the environment variables that existed when your program was created through <code>System.getenv()</code>:</p> <p><a href="http://download.oracle.com/javase/tutorial/essential/environment/env.html" rel="noreferrer">http://download.oracle.com/javase/tutorial/essential/environment/env.html</a></p> <bl... | 17, 390, 9013 | environment-variables, java, shell | <h1>Access shell environment variables in Java</h1>
<p>Does anyone know how to access the environment variables of the standard shell environment in Java? I am using the ProcessBuilder class and I have to specify specific environment variables used in a shell script I am running, these variables exist in the standard s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,759 | bash | # Access shell environment variables in Java
Does anyone know how to access the environment variables of the standard shell environment in Java? I am using the ProcessBuilder class and I have to specify specific environment variables used in a shell script I am running, these variables exist in the standard shell envi... | You can get at the environment variables that existed when your program was created through `System.getenv()`:
<http://download.oracle.com/javase/tutorial/essential/environment/env.html>
> When a Java application uses a ProcessBuilder object to create a new process, the default set of environment variables passed to ... |
2972264 | Merge multiple XML files into one using PowerShell 2.0? | 6 | 2010-06-04 07:38:30 | <p>I have a directory of very large XML files with a structure as this:</p>
<p>file1.xml:</p>
<pre><code><root>
<EmployeeInfo attr="one" />
<EmployeeInfo attr="two" />
<EmployeeInfo attr="three" />
</root>
</code></pre>
<p>file2.xml:</p>
<pre><code><root>
<EmployeeInfo att... | 24,437 | 6,536 | 2012-10-17 05:01:04 | 2,975,494 | 11 | 2010-06-04 15:22:11 | 221,631 | 2010-06-04 15:22:11 | https://stackoverflow.com/q/2972264 | https://stackoverflow.com/a/2975494 | <p>While the XSLT way to do this is pretty short, so is the PowerShell way:</p>
<pre><code>$finalXml = "<root>"
foreach ($file in $files) {
[xml]$xml = Get-Content $file
$finalXml += $xml.InnerXml
}
$finalXml += "</root>"
([xml]$finalXml).Save("$pwd\final.xml")
</code></pre>
<p>Hope this helps... | <p>While the XSLT way to do this is pretty short, so is the PowerShell way:</p> <pre><code>$finalXml = "<root>" foreach ($file in $files) { [xml]$xml = Get-Content $file $finalXml += $xml.InnerXml } $finalXml += "</root>" ([xml]$finalXml).Save("$pwd\final.xml") </code></pre> <p>Hope this helps... | 19, 526, 24067 | powershell, powershell-2.0, xml | <h1>Merge multiple XML files into one using PowerShell 2.0?</h1>
<p>I have a directory of very large XML files with a structure as this:</p>
<p>file1.xml:</p>
<pre><code><root>
<EmployeeInfo attr="one" />
<EmployeeInfo attr="two" />
<EmployeeInfo attr="three" />
</root>
</code></pre>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,760 | bash | # Merge multiple XML files into one using PowerShell 2.0?
I have a directory of very large XML files with a structure as this:
file1.xml:
```
<root>
<EmployeeInfo attr="one" />
<EmployeeInfo attr="two" />
<EmployeeInfo attr="three" />
</root>
```
file2.xml:
```
<root>
<EmployeeInfo attr="four" />
<EmployeeInf... | While the XSLT way to do this is pretty short, so is the PowerShell way:
```
$finalXml = "<root>"
foreach ($file in $files) {
[xml]$xml = Get-Content $file
$finalXml += $xml.InnerXml
}
$finalXml += "</root>"
([xml]$finalXml).Save("$pwd\final.xml")
```
Hope this helps, |
1562666 | BASH scripts : whiptail file select | 6 | 2009-10-13 20:12:59 | <p>I've found a great little program that will allow me to add user friendly GUI's to my Bash Scripts;</p>
<h1>whiptail</h1>
<p>However the <a href="http://manpages.ubuntu.com/manpages/intrepid/man1/whiptail.1.html" rel="noreferrer">whiptail man page</a> isn't all that helpful and doesn't provide any examples. After d... | 21,207 | 174,648 | 2019-10-30 23:35:52 | 1,564,725 | 11 | 2009-10-14 07:15:46 | 26,428 | 2017-04-21 18:57:18 | https://stackoverflow.com/q/1562666 | https://stackoverflow.com/a/1564725 | <p>Build an array of file names and menu select tags:</p>
<pre><code>i=0
s=65 # decimal ASCII "A"
for f in *.tgz
do
# convert to octal then ASCII character for selection tag
files[i]=$(echo -en "\0$(( $s / 64 * 100 + $s % 64 / 8 * 10 + $s % 8 ))")
files[i+1]="$f" # save file name
((i+=2))
((... | <p>Build an array of file names and menu select tags:</p> <pre><code>i=0 s=65 # decimal ASCII "A" for f in *.tgz do # convert to octal then ASCII character for selection tag files[i]=$(echo -en "\0$(( $s / 64 * 100 + $s % 64 / 8 * 10 + $s % 8 ))") files[i+1]="$f" # save file name ((i+=2)) ((... | 387, 531, 1151 | bash, scripting, select | <h1>BASH scripts : whiptail file select</h1>
<p>I've found a great little program that will allow me to add user friendly GUI's to my Bash Scripts;</p>
<h1>whiptail</h1>
<p>However the <a href="http://manpages.ubuntu.com/manpages/intrepid/man1/whiptail.1.html" rel="noreferrer">whiptail man page</a> isn't all that helpf... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,761 | bash | # BASH scripts : whiptail file select
I've found a great little program that will allow me to add user friendly GUI's to my Bash Scripts;
# whiptail
However the [whiptail man page](http://manpages.ubuntu.com/manpages/intrepid/man1/whiptail.1.html) isn't all that helpful and doesn't provide any examples. After doing ... | Build an array of file names and menu select tags:
```
i=0
s=65 # decimal ASCII "A"
for f in *.tgz
do
# convert to octal then ASCII character for selection tag
files[i]=$(echo -en "\0$(( $s / 64 * 100 + $s % 64 / 8 * 10 + $s % 8 ))")
files[i+1]="$f" # save file name
((i+=2))
((s++))
done
```... |
1371858 | PowerShell: Copy-Item Cannot find path | 6 | 2009-09-03 07:16:52 | <p>I'm trying to get <a href="http://en.wikipedia.org/wiki/Windows_PowerShell" rel="noreferrer">PowerShell</a> to copy files from a remote computer (on which I have admin rights through <a href="http://en.wikipedia.org/wiki/Active_Directory" rel="noreferrer">AD</a>) to the local computer.
It fails in the strangest plac... | 25,996 | 36,465 | 2023-11-14 09:16:47 | 1,371,880 | 11 | 2009-09-03 07:22:44 | 36,465 | 2009-12-14 20:35:12 | https://stackoverflow.com/q/1371858 | https://stackoverflow.com/a/1371880 | <p>Eeeeh.... OK?</p>
<p>If I replaced the line </p>
<pre><code> Copy-Item $config -Destination $config_target_dir
</code></pre>
<p>with</p>
<pre><code> Copy-Item $config.FullName $config_target_dir
</code></pre>
<p>it suddenly magically worked....</p>
<p>What gives?</p>
| <p>Eeeeh.... OK?</p> <p>If I replaced the line </p> <pre><code> Copy-Item $config -Destination $config_target_dir </code></pre> <p>with</p> <pre><code> Copy-Item $config.FullName $config_target_dir </code></pre> <p>it suddenly magically worked....</p> <p>What gives?</p> | 526, 8716 | copy-item, powershell | <h1>PowerShell: Copy-Item Cannot find path</h1>
<p>I'm trying to get <a href="http://en.wikipedia.org/wiki/Windows_PowerShell" rel="noreferrer">PowerShell</a> to copy files from a remote computer (on which I have admin rights through <a href="http://en.wikipedia.org/wiki/Active_Directory" rel="noreferrer">AD</a>) to th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,762 | bash | # PowerShell: Copy-Item Cannot find path
I'm trying to get [PowerShell](http://en.wikipedia.org/wiki/Windows_PowerShell) to copy files from a remote computer (on which I have admin rights through [AD](http://en.wikipedia.org/wiki/Active_Directory)) to the local computer.
It fails in the strangest place. Here's a snipp... | Eeeeh.... OK?
If I replaced the line
```
Copy-Item $config -Destination $config_target_dir
```
with
```
Copy-Item $config.FullName $config_target_dir
```
it suddenly magically worked....
What gives? |
1302889 | Cloning permissions of a folder to another folder | 6 | 2009-08-19 22:06:25 | <p>Are there any ways in OS X to clone the permissions of one folder to another. Just to be clear, I don't want to copy the entire folder, just the permissions and then set them on another folder. I think this type of thing could be achieved on Linux/UNIX using the setfacl/getfacl commands, but I'm unsure on how to do ... | 12,155 | 153,112 | 2021-11-12 10:13:35 | 1,325,789 | 11 | 2009-08-25 02:36:26 | 89,817 | 2009-08-25 02:36:26 | https://stackoverflow.com/q/1302889 | https://stackoverflow.com/a/1325789 | <p>Tested on Mac OS X v10.5.7, in bash:</p>
<pre><code>chown $(stat -f%u:%g "$srcdir") "$dstdir" # Copy owner and group
chmod $(stat -f%Mp%Lp "$srcdir") "$dstdir" # Copy the mode bits
(ls -lde "$srcdir" | tail +2 | sed 's/^ [0-9]*: //'; echo) | chmod -E "$dstdir" # Copy the ACL
</code></pre>
<p>Notes: These operati... | <p>Tested on Mac OS X v10.5.7, in bash:</p> <pre><code>chown $(stat -f%u:%g "$srcdir") "$dstdir" # Copy owner and group chmod $(stat -f%Mp%Lp "$srcdir") "$dstdir" # Copy the mode bits (ls -lde "$srcdir" | tail +2 | sed 's/^ [0-9]*: //'; echo) | chmod -E "$dstdir" # Copy the ACL </code></pre> <p>Notes: These operati... | 359, 369, 390, 1576 | acl, macos, permissions, shell | <h1>Cloning permissions of a folder to another folder</h1>
<p>Are there any ways in OS X to clone the permissions of one folder to another. Just to be clear, I don't want to copy the entire folder, just the permissions and then set them on another folder. I think this type of thing could be achieved on Linux/UNIX using... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,763 | bash | # Cloning permissions of a folder to another folder
Are there any ways in OS X to clone the permissions of one folder to another. Just to be clear, I don't want to copy the entire folder, just the permissions and then set them on another folder. I think this type of thing could be achieved on Linux/UNIX using the setf... | Tested on Mac OS X v10.5.7, in bash:
```
chown $(stat -f%u:%g "$srcdir") "$dstdir" # Copy owner and group
chmod $(stat -f%Mp%Lp "$srcdir") "$dstdir" # Copy the mode bits
(ls -lde "$srcdir" | tail +2 | sed 's/^ [0-9]*: //'; echo) | chmod -E "$dstdir" # Copy the ACL
```
Notes: These operations (esp. changing ownershi... |
1282465 | Why cant I execute a commandlet with arguments from a string in powershell? | 6 | 2009-08-15 18:04:50 | <p>In windows powershell, I am trying to store a move command in a string and then execute it. Can someone tell me why this doesn't work?</p>
<pre><code>PS C:\Temp\> dir
Directory: Microsoft.PowerShell.Core\FileSystem::C:\Temp
Mode LastWriteTime Length Name
---- -------------... | 4,704 | 5,056 | 2009-11-08 21:26:49 | 1,282,515 | 11 | 2009-08-15 18:32:12 | 73,070 | 2009-08-15 18:32:12 | https://stackoverflow.com/q/1282465 | https://stackoverflow.com/a/1282515 | <p>From the help (about_Operators):</p>
<pre>
& Call operator
Description: Runs a command, script, or script block. Because the call
operator does not parse, it cannot interpret command parameters.</pre>
<p>You can use a script block instead of a string:</p>
<pre><code>$s = { mv sa.csproj sb.csproj }
& $s
<... | <p>From the help (about_Operators):</p> <pre> & Call operator Description: Runs a command, script, or script block. Because the call operator does not parse, it cannot interpret command parameters.</pre> <p>You can use a script block instead of a string:</p> <pre><code>$s = { mv sa.csproj sb.csproj } & $s <... | 526 | powershell | <h1>Why cant I execute a commandlet with arguments from a string in powershell?</h1>
<p>In windows powershell, I am trying to store a move command in a string and then execute it. Can someone tell me why this doesn't work?</p>
<pre><code>PS C:\Temp\> dir
Directory: Microsoft.PowerShell.Core\FileSystem::C:\Temp... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,764 | bash | # Why cant I execute a commandlet with arguments from a string in powershell?
In windows powershell, I am trying to store a move command in a string and then execute it. Can someone tell me why this doesn't work?
```
PS C:\Temp\> dir
Directory: Microsoft.PowerShell.Core\FileSystem::C:\Temp
Mode La... | From the help (about_Operators):
```
& Call operator
Description: Runs a command, script, or script block. Because the call
operator does not parse, it cannot interpret command parameters.
```
You can use a script block instead of a string:
```
$s = { mv sa.csproj sb.csproj }
& $s
```
Or you can use `Invoke-Ex... |
1236089 | How can I read the output from external commands in real time in Perl? | 6 | 2009-08-05 22:26:40 | <p>I have a few bash scripts I run, but they can take several hours to finish, during which time they spew out download speeds, ETAs and similar information. I need to capture this information in perl, but I am running into a problem, I cannot read the output line by line(unless I'm missing something).</p>
<p>Any help... | 4,770 | 97,513 | 2011-09-27 16:11:11 | 1,243,337 | 11 | 2009-08-07 07:06:21 | null | 2009-08-07 15:23:29 | https://stackoverflow.com/q/1236089 | https://stackoverflow.com/a/1243337 | <p>Instead of threads, and ``, use:</p>
<pre><code> open my $fh, '-|', 'some_program --with-options';
</code></pre>
<p>In this way open several filehandles (as many as many programs you need to run) and then use <a href="http://search.cpan.org/perldoc?IO::Select" rel="noreferrer"><code>IO::Select</code></a> to poll d... | <p>Instead of threads, and ``, use:</p> <pre><code> open my $fh, '-|', 'some_program --with-options'; </code></pre> <p>In this way open several filehandles (as many as many programs you need to run) and then use <a href="http://search.cpan.org/perldoc?IO::Select" rel="noreferrer"><code>IO::Select</code></a> to poll d... | 387, 580, 1701 | bash, perl, stdin | <h1>How can I read the output from external commands in real time in Perl?</h1>
<p>I have a few bash scripts I run, but they can take several hours to finish, during which time they spew out download speeds, ETAs and similar information. I need to capture this information in perl, but I am running into a problem, I can... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,765 | bash | # How can I read the output from external commands in real time in Perl?
I have a few bash scripts I run, but they can take several hours to finish, during which time they spew out download speeds, ETAs and similar information. I need to capture this information in perl, but I am running into a problem, I cannot read ... | Instead of threads, and ``, use:
```
open my $fh, '-|', 'some_program --with-options';
```
In this way open several filehandles (as many as many programs you need to run) and then use [`IO::Select`](http://search.cpan.org/perldoc?IO::Select) to poll data from them.
Simplistic example.
Let's assume I have shell scr... |
1203733 | How do I determine if a PowerShell Cmdlet parameter value was specified? | 6 | 2009-07-29 23:57:24 | <p>In PowerShell 1.0, if I have a cmdlet parameter of an enum type, what is the recommended method for testing whether the user specified that parameter on the cmdlet command line? For example:</p>
<pre><code>MyEnum : int { No = 0, Yes = 1, MaybeSo = 2 }
class DoSomethingCommand : PSCmdlet
...
private MyEnum isEnabl... | 7,460 | 147,430 | 2018-12-28 02:22:53 | 1,210,575 | 11 | 2009-07-31 03:37:37 | null | 2009-07-31 03:37:37 | https://stackoverflow.com/q/1203733 | https://stackoverflow.com/a/1210575 | <p>In this case, I would use a nullable wrapper around the enum type e.g. </p>
<pre><code>[Parameter(Mandatory = false)]
public MyEnum? IsEnabled { get; set; }
</code></pre>
<p>Note the ? modifier on MyEnum. Then you can test if it is set like so:</p>
<pre><code>if (this.IsEnabled.HasValue) { ... }
</code></pre>
| <p>In this case, I would use a nullable wrapper around the enum type e.g. </p> <pre><code>[Parameter(Mandatory = false)] public MyEnum? IsEnabled { get; set; } </code></pre> <p>Note the ? modifier on MyEnum. Then you can test if it is set like so:</p> <pre><code>if (this.IsEnabled.HasValue) { ... } </code></pre> | 9, 360, 526, 153947 | c#, parameters, powershell, powershell-cmdlet | <h1>How do I determine if a PowerShell Cmdlet parameter value was specified?</h1>
<p>In PowerShell 1.0, if I have a cmdlet parameter of an enum type, what is the recommended method for testing whether the user specified that parameter on the cmdlet command line? For example:</p>
<pre><code>MyEnum : int { No = 0, Yes ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,766 | bash | # How do I determine if a PowerShell Cmdlet parameter value was specified?
In PowerShell 1.0, if I have a cmdlet parameter of an enum type, what is the recommended method for testing whether the user specified that parameter on the cmdlet command line? For example:
```
MyEnum : int { No = 0, Yes = 1, MaybeSo = 2 }
c... | In this case, I would use a nullable wrapper around the enum type e.g.
```
[Parameter(Mandatory = false)]
public MyEnum? IsEnabled { get; set; }
```
Note the ? modifier on MyEnum. Then you can test if it is set like so:
```
if (this.IsEnabled.HasValue) { ... }
``` |
1034186 | Command line to update SVN folders | 6 | 2009-06-23 18:07:58 | <p>I have tried several things so far, but I haven't had much luck yet. I'm attempting to have a command line or PowerShell script that I can run once a day to make sure my numerous checked-out projects are up to date.</p>
<p>I know I would be looping through the directory folders inside my workspace, but when setting... | 17,294 | 102,587 | 2015-11-12 16:56:24 | 1,034,295 | 11 | 2009-06-23 18:27:38 | 54,249 | 2009-06-23 21:38:52 | https://stackoverflow.com/q/1034186 | https://stackoverflow.com/a/1034295 | <p>It might be easier in PowerShell:</p>
<pre><code>Set-Alias tsvn 'C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe'
dir C:\workspace | %{ tsvn /command:update /path:"$($_.FullName)" /closeonend:2 }
</code></pre>
<p>Or if you want to specify certain project directories:</p>
<pre><code>cd C:\workspace
$projects = '... | <p>It might be easier in PowerShell:</p> <pre><code>Set-Alias tsvn 'C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe' dir C:\workspace | %{ tsvn /command:update /path:"$($_.FullName)" /closeonend:2 } </code></pre> <p>Or if you want to specify certain project directories:</p> <pre><code>cd C:\workspace $projects = '... | 63, 526, 1231 | command-line, powershell, svn | <h1>Command line to update SVN folders</h1>
<p>I have tried several things so far, but I haven't had much luck yet. I'm attempting to have a command line or PowerShell script that I can run once a day to make sure my numerous checked-out projects are up to date.</p>
<p>I know I would be looping through the directory f... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,767 | bash | # Command line to update SVN folders
I have tried several things so far, but I haven't had much luck yet. I'm attempting to have a command line or PowerShell script that I can run once a day to make sure my numerous checked-out projects are up to date.
I know I would be looping through the directory folders inside my... | It might be easier in PowerShell:
```
Set-Alias tsvn 'C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe'
dir C:\workspace | %{ tsvn /command:update /path:"$($_.FullName)" /closeonend:2 }
```
Or if you want to specify certain project directories:
```
cd C:\workspace
$projects = 'Proj 1','Proj 2','Proj 3'
$projects | ... |
695474 | PowerShell converts values returned from function. How to avoid this? | 6 | 2009-03-29 21:59:28 | <p>I am trying to return List< T> from PowerShell function, but get one of:</p>
<ol>
<li>null - for empty list</li>
<li>System.Int32 - for list with one element</li>
<li>System.Object[] - for list with more elements</li>
</ol>
<p>Code:</p>
<pre><code>function CreateClrList
{
$list = New-Object "System.Collect... | 3,139 | 62,192 | 2020-12-05 07:31:35 | 695,483 | 11 | 2009-03-29 22:09:38 | null | 2009-03-29 22:09:38 | https://stackoverflow.com/q/695474 | https://stackoverflow.com/a/695483 | <p>Yeah, powershell unrolls all collections. One solution is to return a collection containing the real collection, using the unary comma:</p>
<pre><code>function CreateClrList
{
$list = New-Object "System.Collections.Generic.List``1[System.Int32]"
$list.Add(3)
,$list
}
</code></pre>
| <p>Yeah, powershell unrolls all collections. One solution is to return a collection containing the real collection, using the unary comma:</p> <pre><code>function CreateClrList { $list = New-Object "System.Collections.Generic.List``1[System.Int32]" $list.Add(3) ,$list } </code></pre> | 526, 9206 | powershell, return-value | <h1>PowerShell converts values returned from function. How to avoid this?</h1>
<p>I am trying to return List< T> from PowerShell function, but get one of:</p>
<ol>
<li>null - for empty list</li>
<li>System.Int32 - for list with one element</li>
<li>System.Object[] - for list with more elements</li>
</ol>
<p>Code:<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,768 | bash | # PowerShell converts values returned from function. How to avoid this?
I am trying to return List< T> from PowerShell function, but get one of:
1. null - for empty list
2. System.Int32 - for list with one element
3. System.Object[] - for list with more elements
Code:
```
function CreateClrList
{
$list = New-Ob... | Yeah, powershell unrolls all collections. One solution is to return a collection containing the real collection, using the unary comma:
```
function CreateClrList
{
$list = New-Object "System.Collections.Generic.List``1[System.Int32]"
$list.Add(3)
,$list
}
``` |
643143 | How to keep a file's format if you use the uniq command (in shell)? | 6 | 2009-03-13 15:07:28 | <p>In order to use the uniq command, you have to sort your file first.</p>
<p>But in the file I have, the order of the information is important, thus how can I keep the original format of the file but still get rid of duplicate content?</p>
| 1,221 | 72,321 | 2009-03-13 17:49:21 | 643,284 | 11 | 2009-03-13 15:37:11 | 430,749 | 2009-03-13 15:37:11 | https://stackoverflow.com/q/643143 | https://stackoverflow.com/a/643284 | <p>Another awk version:</p>
<pre><code>awk '!_[$0]++' infile
</code></pre>
| <p>Another awk version:</p> <pre><code>awk '!_[$0]++' infile </code></pre> | 34, 134, 390, 5310, 12147 | duplicates, file, shell, sorting, unix | <h1>How to keep a file's format if you use the uniq command (in shell)?</h1>
<p>In order to use the uniq command, you have to sort your file first.</p>
<p>But in the file I have, the order of the information is important, thus how can I keep the original format of the file but still get rid of duplicate content?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,769 | bash | # How to keep a file's format if you use the uniq command (in shell)?
In order to use the uniq command, you have to sort your file first.
But in the file I have, the order of the information is important, thus how can I keep the original format of the file but still get rid of duplicate content? | Another awk version:
```
awk '!_[$0]++' infile
``` |
7442112 | How to attribute a single commit to multiple developers? | 221 | 2011-09-16 08:38:09 | <p>The way all version control systems I'm familiar with work is that each commit is attributed to a single developer. The rise of Agile Engineering, and specifically pair programming, has lead to a situation where two developers have made a significant contribution to the same task, a bug fix for example.</p>
<p>The ... | 88,694 | null | 2024-11-04 10:27:28 | 7,442,255 | 200 | 2011-09-16 08:51:41 | 109,561 | 2023-06-22 12:47:12 | https://stackoverflow.com/q/7442112 | https://stackoverflow.com/a/7442255 | <pre><code>Commit title
Commit body
Co-authored-by: name <additional-dev-1@example.com>
Co-authored-by: name <additional-dev-2@example.com>
</code></pre>
<ul>
<li>Supported by <a href="https://github.blog/2018-01-29-commit-together-with-co-authors/" rel="noreferrer">GitHub</a> and <a href="https://gitlab.... | <pre><code>Commit title Commit body Co-authored-by: name <additional-dev-1@example.com> Co-authored-by: name <additional-dev-2@example.com> </code></pre> <ul> <li>Supported by <a href="https://github.blog/2018-01-29-commit-together-with-co-authors/" rel="noreferrer">GitHub</a> and <a href="https://gitlab.... | 63, 119, 456, 3986 | bazaar, git, svn, version-control | <h1>How to attribute a single commit to multiple developers?</h1>
<p>The way all version control systems I'm familiar with work is that each commit is attributed to a single developer. The rise of Agile Engineering, and specifically pair programming, has lead to a situation where two developers have made a significant ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 0 | bazaar | # How to attribute a single commit to multiple developers?
The way all version control systems I'm familiar with work is that each commit is attributed to a single developer. The rise of Agile Engineering, and specifically pair programming, has lead to a situation where two developers have made a significant contribut... | ```
Commit title
Commit body
Co-authored-by: name <additional-dev-1@example.com>
Co-authored-by: name <additional-dev-2@example.com>
```
- Supported by [GitHub](https://github.blog/2018-01-29-commit-together-with-co-authors/) and [GitLab](https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/17919)
- Used by othe... |
401331 | examining history of deleted file | 172 | 2008-12-30 20:05:29 | <p>If I delete a file in Subversion, how can I look at it's history and contents? If I try to do <code>svn cat</code> or <code>svn log</code> on a nonexistent file, it complains that the file doesn't exist.</p>
<p>Also, if I wanted to resurrect the file, should I just <code>svn add</code> it back?</p>
<p>(I asked spe... | 96,789 | 33,795 | 2017-03-17 02:22:20 | 401,353 | 88 | 2008-12-30 20:13:24 | 48,003 | 2010-01-08 18:20:50 | https://stackoverflow.com/q/401331 | https://stackoverflow.com/a/401353 | <p>To get the log of a deleted file, use</p>
<pre><code>svn log -r lastrevisionthefileexisted
</code></pre>
<p>If you want to resurrect the file and keep its version history, use</p>
<pre><code>svn copy url/of/file@lastrevisionthefileexisted -r lastrevisionthefileexisted path/to/workingcopy/file
</code></pre>
<p>If... | <p>To get the log of a deleted file, use</p> <pre><code>svn log -r lastrevisionthefileexisted </code></pre> <p>If you want to resurrect the file and keep its version history, use</p> <pre><code>svn copy url/of/file@lastrevisionthefileexisted -r lastrevisionthefileexisted path/to/workingcopy/file </code></pre> <p>If... | 63, 456, 3986 | bazaar, svn, version-control | <h1>examining history of deleted file</h1>
<p>If I delete a file in Subversion, how can I look at it's history and contents? If I try to do <code>svn cat</code> or <code>svn log</code> on a nonexistent file, it complains that the file doesn't exist.</p>
<p>Also, if I wanted to resurrect the file, should I just <code>s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 1 | bazaar | # examining history of deleted file
If I delete a file in Subversion, how can I look at it's history and contents? If I try to do `svn cat` or `svn log` on a nonexistent file, it complains that the file doesn't exist.
Also, if I wanted to resurrect the file, should I just `svn add` it back?
(I asked specifically abo... | To get the log of a deleted file, use
```
svn log -r lastrevisionthefileexisted
```
If you want to resurrect the file and keep its version history, use
```
svn copy url/of/file@lastrevisionthefileexisted -r lastrevisionthefileexisted path/to/workingcopy/file
```
If you just want the file content but unversioned (e.... |
1441317 | How to list versioned files in git? | 36 | 2009-09-17 20:58:30 | <p>I would like to list the versioned files in the root directory of a git repository. To do the same thing in bazaar, you run:</p>
<pre><code>bzr ls --versioned --non-recursive
</code></pre>
<p>How do I do this in git?</p>
| 12,063 | 3,757 | 2012-10-04 08:17:56 | 1,441,361 | 45 | 2009-09-17 21:06:38 | 19,563 | 2009-09-17 21:06:38 | https://stackoverflow.com/q/1441317 | https://stackoverflow.com/a/1441361 | <p>It would be more helpful if you described exactly what listing you want to show. Guessing from the bzr document, I imagine that you want something like this.</p>
<pre><code>git ls-tree --name-only HEAD
</code></pre>
<p>This lists the names of files in the current directory which are currently in the <code>HEAD</co... | <p>It would be more helpful if you described exactly what listing you want to show. Guessing from the bzr document, I imagine that you want something like this.</p> <pre><code>git ls-tree --name-only HEAD </code></pre> <p>This lists the names of files in the current directory which are currently in the <code>HEAD</co... | 119, 3986 | bazaar, git | <h1>How to list versioned files in git?</h1>
<p>I would like to list the versioned files in the root directory of a git repository. To do the same thing in bazaar, you run:</p>
<pre><code>bzr ls --versioned --non-recursive
</code></pre>
<p>How do I do this in git?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 2 | bazaar | # How to list versioned files in git?
I would like to list the versioned files in the root directory of a git repository. To do the same thing in bazaar, you run:
```
bzr ls --versioned --non-recursive
```
How do I do this in git? | It would be more helpful if you described exactly what listing you want to show. Guessing from the bzr document, I imagine that you want something like this.
```
git ls-tree --name-only HEAD
```
This lists the names of files in the current directory which are currently in the `HEAD` revision, which should be close to... |
2044852 | bzr pull vs bzr merge | 17 | 2010-01-11 20:55:00 | <p>I'm using bzr for a very simple task: getting the development version of GNU Emacs. After the initial <code>bzr branch</code>, I'd like to keep my local version up to date. I read about the documentation on <code>bzr pull</code> and <code>bzr merge</code>, but couldn't make sense out of it. I tried <code>bzr merge</... | 8,841 | 111,391 | 2014-06-08 13:56:19 | 2,046,979 | 35 | 2010-01-12 05:56:51 | 1,412 | 2010-01-12 21:17:35 | https://stackoverflow.com/q/2044852 | https://stackoverflow.com/a/2046979 | <blockquote>
<p>Note that I didn't make any local
changes. Is <code>bzr pull</code> the recommended
way?</p>
</blockquote>
<p>Yes, it sounds like <code>bzr pull</code> is the appropriate command for your use. <code>pull</code> takes a remote source branch and copies any changes from it to a local destination bra... | <blockquote> <p>Note that I didn't make any local changes. Is <code>bzr pull</code> the recommended way?</p> </blockquote> <p>Yes, it sounds like <code>bzr pull</code> is the appropriate command for your use. <code>pull</code> takes a remote source branch and copies any changes from it to a local destination bra... | 456, 3986 | bazaar, version-control | <h1>bzr pull vs bzr merge</h1>
<p>I'm using bzr for a very simple task: getting the development version of GNU Emacs. After the initial <code>bzr branch</code>, I'd like to keep my local version up to date. I read about the documentation on <code>bzr pull</code> and <code>bzr merge</code>, but couldn't make sense out o... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 3 | bazaar | # bzr pull vs bzr merge
I'm using bzr for a very simple task: getting the development version of GNU Emacs. After the initial `bzr branch`, I'd like to keep my local version up to date. I read about the documentation on `bzr pull` and `bzr merge`, but couldn't make sense out of it. I tried `bzr merge` for a few days, ... | > Note that I didn't make any local
> changes. Is `bzr pull` the recommended
> way?
Yes, it sounds like `bzr pull` is the appropriate command for your use. `pull` takes a remote source branch and copies any changes from it to a local destination branch at an older revision. (I use "remote" and "local" here to mean "so... |
1912934 | How to emulate 'git stash' in fossil, bzr? | 15 | 2009-12-16 07:26:17 | <p>Is it possible to emulate the behavior of 'git stash' when using fossil/bzr?</p>
<p>Basically I'm interested in handling the following workflow:</p>
<ul>
<li>at some point the source code tree has state X, it is commited</li>
<li>I proceed to writing new code, I write it for a while and I see the
opportunity of a ... | 2,779 | 145,256 | 2015-06-24 07:29:26 | 1,913,879 | 28 | 2009-12-16 10:54:57 | 65,736 | 2009-12-16 10:54:57 | https://stackoverflow.com/q/1912934 | https://stackoverflow.com/a/1913879 | <p>Use <code>bzr shelve</code> and <code>bzr unshelve</code> commands.</p>
| <p>Use <code>bzr shelve</code> and <code>bzr unshelve</code> commands.</p> | 3986, 11746, 13091 | bazaar, fossil, git-stash | <h1>How to emulate 'git stash' in fossil, bzr?</h1>
<p>Is it possible to emulate the behavior of 'git stash' when using fossil/bzr?</p>
<p>Basically I'm interested in handling the following workflow:</p>
<ul>
<li>at some point the source code tree has state X, it is commited</li>
<li>I proceed to writing new code, I ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 4 | bazaar | # How to emulate 'git stash' in fossil, bzr?
Is it possible to emulate the behavior of 'git stash' when using fossil/bzr?
Basically I'm interested in handling the following workflow:
- at some point the source code tree has state X, it is commited
- I proceed to writing new code, I write it for a while and I see the... | Use `bzr shelve` and `bzr unshelve` commands. |
1988014 | In bazaar, how do I change the default target of "bzr push"? | 13 | 2010-01-01 06:17:15 | <p><code>bzr push</code> defaults to the first target you pushed to. If I now want to push to a different location, but don't want to manually enter it every time, how do I change the default?</p>
| 1,244 | 105,084 | 2010-03-29 03:33:06 | 1,988,042 | 27 | 2010-01-01 06:39:24 | 105,084 | 2010-01-01 06:39:24 | https://stackoverflow.com/q/1988014 | https://stackoverflow.com/a/1988042 | <p>I figured it out. You do:</p>
<pre><code>bzr push --remember [location]
</code></pre>
| <p>I figured it out. You do:</p> <pre><code>bzr push --remember [location] </code></pre> | 456, 3346, 3986 | bazaar, dvcs, version-control | <h1>In bazaar, how do I change the default target of "bzr push"?</h1>
<p><code>bzr push</code> defaults to the first target you pushed to. If I now want to push to a different location, but don't want to manually enter it every time, how do I change the default?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 5 | bazaar | # In bazaar, how do I change the default target of "bzr push"?
`bzr push` defaults to the first target you pushed to. If I now want to push to a different location, but don't want to manually enter it every time, how do I change the default? | I figured it out. You do:
```
bzr push --remember [location]
``` |
20273368 | Launchpad pull request | 15 | 2013-11-28 19:13:52 | <p>I want to propose a change to the source code of a project which is hosted in Launchpad.</p>
<p>Problem is: I have no idea how to use the bazaar version control system, and I've never used Launchpad, so what are the equivalent steps of making a Github pull request, but applied to this system?</p>
<p>I have read so... | 1,736 | 3,047,097 | 2016-01-19 03:09:41 | 20,273,376 | 26 | 2013-11-28 19:14:36 | 544,947 | 2016-01-19 03:09:41 | https://stackoverflow.com/q/20273368 | https://stackoverflow.com/a/20273376 | <p>Alright, no need to read a <a href="http://www.joinfu.com/2008/08/a-contributors-guide-to-launchpadnet-part-2-code-management/">doctoral thesis</a> about it, or <a href="https://dev.launchpad.net/UsingMergeProposals">single documentation chapters</a> that lack details about the <a href="http://bazaar.canonical.com/"... | <p>Alright, no need to read a <a href="http://www.joinfu.com/2008/08/a-contributors-guide-to-launchpadnet-part-2-code-management/">doctoral thesis</a> about it, or <a href="https://dev.launchpad.net/UsingMergeProposals">single documentation chapters</a> that lack details about the <a href="http://bazaar.canonical.com/"... | 3986, 51632, 64512 | bazaar, launchpad, pull-request | <h1>Launchpad pull request</h1>
<p>I want to propose a change to the source code of a project which is hosted in Launchpad.</p>
<p>Problem is: I have no idea how to use the bazaar version control system, and I've never used Launchpad, so what are the equivalent steps of making a Github pull request, but applied to thi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 6 | bazaar | # Launchpad pull request
I want to propose a change to the source code of a project which is hosted in Launchpad.
Problem is: I have no idea how to use the bazaar version control system, and I've never used Launchpad, so what are the equivalent steps of making a Github pull request, but applied to this system?
I hav... | Alright, no need to read a [doctoral thesis](http://www.joinfu.com/2008/08/a-contributors-guide-to-launchpadnet-part-2-code-management/) about it, or [single documentation chapters](https://dev.launchpad.net/UsingMergeProposals) that lack details about the [bazaar](http://bazaar.canonical.com/) VCS that you don't know ... |
9684608 | Go back to old revision in Bazaar | 32 | 2012-03-13 13:11:23 | <p>I want to go back in my bazaar history (change working tree) to find the commit that introduced a certain bug.</p>
<p>I do not want to delete any commits, just change my working tree until I found the bug, and then I want to go back to the latest revision to work on.</p>
<p>What are the two commands for that (goin... | 11,686 | 635,523 | 2018-01-27 12:32:38 | 9,691,645 | 23 | 2012-03-13 20:33:02 | 291,383 | 2012-03-13 20:33:02 | https://stackoverflow.com/q/9684608 | https://stackoverflow.com/a/9691645 | <p>To revert the working tree back to a specific revision N:</p>
<pre><code>bzr revert -rN
</code></pre>
<p>To revert the working tree to the latest revision in the branch:</p>
<pre><code>bzr revert
</code></pre>
| <p>To revert the working tree back to a specific revision N:</p> <pre><code>bzr revert -rN </code></pre> <p>To revert the working tree to the latest revision in the branch:</p> <pre><code>bzr revert </code></pre> | 456, 3346, 3986, 130914 | bazaar, dvcs, vcs-checkout, version-control | <h1>Go back to old revision in Bazaar</h1>
<p>I want to go back in my bazaar history (change working tree) to find the commit that introduced a certain bug.</p>
<p>I do not want to delete any commits, just change my working tree until I found the bug, and then I want to go back to the latest revision to work on.</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bazaar%' OR '%bzr%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 7 | bazaar | # Go back to old revision in Bazaar
I want to go back in my bazaar history (change working tree) to find the commit that introduced a certain bug.
I do not want to delete any commits, just change my working tree until I found the bug, and then I want to go back to the latest revision to work on.
What are the two com... | To revert the working tree back to a specific revision N:
```
bzr revert -rN
```
To revert the working tree to the latest revision in the branch:
```
bzr revert
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.