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
49311215
What is exclamation mark at beginning of line doing in this BASH snippet?
10
2018-03-16 00:01:39
<p>I understand history expansion in C-shell and BASH, but I don't understand why the exclamation mark on the line with the <code>read</code> command is being used in this snippet from some source I'm looking at:</p> <pre><code>#!/bin/bash set -e . "$(dirname "$0")/includes.sh" ! read -d '' SOME_VAR &lt;&lt;"EOT" ...
2,860
8,075,005
2018-03-16 00:21:09
49,311,315
16
2018-03-16 00:13:21
827,263
2018-03-16 00:21:09
https://stackoverflow.com/q/49311215
https://stackoverflow.com/a/49311315
<p>The <code>set -e</code> command tells bash to exit if a pipeline returns a non-zero exit status (basically if a command fails).</p> <p>The <code>!</code> negates the exit status, but it also inhibits the effect of <code>set -e</code>. The idea is that if a command is being executed as part of a condition, you don't...
<p>The <code>set -e</code> command tells bash to exit if a pipeline returns a non-zero exit status (basically if a command fails).</p> <p>The <code>!</code> negates the exit status, but it also inhibits the effect of <code>set -e</code>. The idea is that if a command is being executed as part of a condition, you don't...
387, 390
bash, shell
<h1>What is exclamation mark at beginning of line doing in this BASH snippet?</h1> <p>I understand history expansion in C-shell and BASH, but I don't understand why the exclamation mark on the line with the <code>read</code> command is being used in this snippet from some source I'm looking at:</p> <pre><code>#!/bin/b...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,862
bash
# What is exclamation mark at beginning of line doing in this BASH snippet? I understand history expansion in C-shell and BASH, but I don't understand why the exclamation mark on the line with the `read` command is being used in this snippet from some source I'm looking at: ``` #!/bin/bash set -e . "$(dirname "$0")...
The `set -e` command tells bash to exit if a pipeline returns a non-zero exit status (basically if a command fails). The `!` negates the exit status, but it also inhibits the effect of `set -e`. The idea is that if a command is being executed as part of a condition, you don't want to terminate the shell. If it's prece...
48661016
Ansible playbook, what is the proper syntax to run a powershell script with a specific (domain) user, in an elevated mode?
10
2018-02-07 10:08:53
<p>running Ansible 2.4.2 in an offline environment, using kerberos to authenticate, </p> <p>Via an ansible playbook, what is the proper syntax to run a powershell script with a specific (domain) user: DOMAIN\someuser, in an elevated mode?</p> <p>By elevated mode I mean that in the Windows interface, I'd run the scrip...
58,271
5,239,648
2018-02-08 00:09:01
48,675,395
16
2018-02-08 00:09:01
9,016,691
2018-02-08 00:09:01
https://stackoverflow.com/q/48661016
https://stackoverflow.com/a/48675395
<p>I did the following to get it working in my playbook:</p> <pre><code>- name: Run ps1 script in privileged mode hosts: "{{ my_hosts }}" become_method: runas vars: ansible_become_password: mysupersecretpasswrod tasks: - win_shell: '.\myscript.ps1' become: yes become_user: Administrator <...
<p>I did the following to get it working in my playbook:</p> <pre><code>- name: Run ps1 script in privileged mode hosts: "{{ my_hosts }}" become_method: runas vars: ansible_become_password: mysupersecretpasswrod tasks: - win_shell: '.\myscript.ps1' become: yes become_user: Administrator <...
64, 526, 86394, 104426, 117136
ansible, ansible-2.x, kerberos-delegation, powershell, windows
<h1>Ansible playbook, what is the proper syntax to run a powershell script with a specific (domain) user, in an elevated mode?</h1> <p>running Ansible 2.4.2 in an offline environment, using kerberos to authenticate, </p> <p>Via an ansible playbook, what is the proper syntax to run a powershell script with a specific (...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,863
bash
# Ansible playbook, what is the proper syntax to run a powershell script with a specific (domain) user, in an elevated mode? running Ansible 2.4.2 in an offline environment, using kerberos to authenticate, Via an ansible playbook, what is the proper syntax to run a powershell script with a specific (domain) user: DOM...
I did the following to get it working in my playbook: ``` - name: Run ps1 script in privileged mode hosts: "{{ my_hosts }}" become_method: runas vars: ansible_become_password: mysupersecretpasswrod tasks: - win_shell: '.\myscript.ps1' become: yes become_user: Administrator ```
46565019
How to properly start a Gnome-Shell extension via command line?
10
2017-10-04 12:35:03
<p>After copying <code>myexentension@me.com</code> folder to <code>.../gnome-shell/extensions/</code> I'm executing this command on the terminal:</p> <p><code>gnome-shell-extension-tool -e myexentension@me.com</code></p> <p>Then, I restart my session with <kbd>Alt</kbd> + <kbd>F2</kbd> and execute <code>r</code>, and...
9,434
8,394,280
2023-05-18 00:21:33
47,952,111
16
2017-12-23 11:30:56
1,420,237
2022-01-22 01:32:13
https://stackoverflow.com/q/46565019
https://stackoverflow.com/a/47952111
<p>According to some answers around the internet, sending SIGHUP to the <code>gnome-shell</code> process restarts it (i. e. <code>killall -HUP gnome-shell</code>), but I haven’t been able to find a clear source on this and couldn’t find the signal handling in the code. What I do know is that this should be exactly equi...
<p>According to some answers around the internet, sending SIGHUP to the <code>gnome-shell</code> process restarts it (i. e. <code>killall -HUP gnome-shell</code>), but I haven’t been able to find a clear source on this and couldn’t find the signal handling in the code. What I do know is that this should be exactly equi...
387, 390, 3294, 68385, 78339
bash, gnome, gnome-shell, gnome-shell-extensions, shell
<h1>How to properly start a Gnome-Shell extension via command line?</h1> <p>After copying <code>myexentension@me.com</code> folder to <code>.../gnome-shell/extensions/</code> I'm executing this command on the terminal:</p> <p><code>gnome-shell-extension-tool -e myexentension@me.com</code></p> <p>Then, I restart my se...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,864
bash
# How to properly start a Gnome-Shell extension via command line? After copying `myexentension@me.com` folder to `.../gnome-shell/extensions/` I'm executing this command on the terminal: `gnome-shell-extension-tool -e myexentension@me.com` Then, I restart my session with `Alt` + `F2` and execute `r`, and everything ...
According to some answers around the internet, sending SIGHUP to the `gnome-shell` process restarts it (i. e. `killall -HUP gnome-shell`), but I haven’t been able to find a clear source on this and couldn’t find the signal handling in the code. What I do know is that this should be exactly equivalent to `Alt+F2 r`: ``...
47189213
Why is bash failing to create a symbolic link in /usr/local/bin?
10
2017-11-08 20:38:24
<p>Attempting to create a symbolic link for the subl command so that I can open flies in Sublime Test 3 from the terminal. However, it fails to find the /usr/local/bin directory, even though it is in my path.</p> <pre><code> $ ln -s /D/ProgramsD/SublimeText3/subl /usr/local/bin/subl ln: failed to create symbolic link...
24,865
8,223,706
2017-11-09 14:47:24
47,189,369
16
2017-11-08 20:46:10
641,955
2017-11-08 20:46:10
https://stackoverflow.com/q/47189213
https://stackoverflow.com/a/47189369
<blockquote> <p>ln: failed to create symbolic link '/usr/local/bin/subl': No such file or directory</p> </blockquote> <p>This error can happen when one of the parent directories of <code>/usr/local/bin/subl</code> don't exist.</p> <p>Create them with:</p> <pre><code>mkdir -p /usr/local/bin </code></pre> <blockquo...
<blockquote> <p>ln: failed to create symbolic link '/usr/local/bin/subl': No such file or directory</p> </blockquote> <p>This error can happen when one of the parent directories of <code>/usr/local/bin/subl</code> don't exist.</p> <p>Create them with:</p> <pre><code>mkdir -p /usr/local/bin </code></pre> <blockquo...
387, 391, 88190
bash, sublimetext3, terminal
<h1>Why is bash failing to create a symbolic link in /usr/local/bin?</h1> <p>Attempting to create a symbolic link for the subl command so that I can open flies in Sublime Test 3 from the terminal. However, it fails to find the /usr/local/bin directory, even though it is in my path.</p> <pre><code> $ ln -s /D/ProgramsD...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,865
bash
# Why is bash failing to create a symbolic link in /usr/local/bin? Attempting to create a symbolic link for the subl command so that I can open flies in Sublime Test 3 from the terminal. However, it fails to find the /usr/local/bin directory, even though it is in my path. ``` $ ln -s /D/ProgramsD/SublimeText3/subl /...
> ln: failed to create symbolic link '/usr/local/bin/subl': No such file or directory This error can happen when one of the parent directories of `/usr/local/bin/subl` don't exist. Create them with: ``` mkdir -p /usr/local/bin ``` > However, it fails to find the `/usr/local/bin` directory, even though it is in my p...
45881232
Base64 coreutils encoding padding (trailing "=" characters)
10
2017-08-25 12:16:21
<p>If I base64 encode a string which consists of seven characters e.g. <code>abcdefg</code> with the website <a href="https://www.base64encode.org/" rel="noreferrer">https://www.base64encode.org/</a> the result is <code>YWJjZGVmZw==</code>. The trailing "==" characters are padding because the number of input characters...
4,866
2,948,561
2022-03-15 17:36:36
45,881,258
16
2017-08-25 12:17:46
2,948,561
2017-08-25 12:17:46
https://stackoverflow.com/q/45881232
https://stackoverflow.com/a/45881258
<p>I've just noticed that the reason for the described behaviour is the newline which <code>echo</code> writes at the end. So the correct command is the following which suppress the newline</p> <pre><code>echo -n "abcdefg" | base64 </code></pre> <p>Then the output is like I expect it:</p> <pre><code>YWJjZGVmZw== </c...
<p>I've just noticed that the reason for the described behaviour is the newline which <code>echo</code> writes at the end. So the correct command is the following which suppress the newline</p> <pre><code>echo -n "abcdefg" | base64 </code></pre> <p>Then the output is like I expect it:</p> <pre><code>YWJjZGVmZw== </c...
387, 1011
base64, bash
<h1>Base64 coreutils encoding padding (trailing "=" characters)</h1> <p>If I base64 encode a string which consists of seven characters e.g. <code>abcdefg</code> with the website <a href="https://www.base64encode.org/" rel="noreferrer">https://www.base64encode.org/</a> the result is <code>YWJjZGVmZw==</code>. The traili...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,866
bash
# Base64 coreutils encoding padding (trailing "=" characters) If I base64 encode a string which consists of seven characters e.g. `abcdefg` with the website <https://www.base64encode.org/> the result is `YWJjZGVmZw==`. The trailing "==" characters are padding because the number of input characters cannot be divided by...
I've just noticed that the reason for the described behaviour is the newline which `echo` writes at the end. So the correct command is the following which suppress the newline ``` echo -n "abcdefg" | base64 ``` Then the output is like I expect it: ``` YWJjZGVmZw== ```
45147904
How do I terminate GNU parallel without killing running jobs?
10
2017-07-17 15:18:08
<p>I'm running a bunch of shell scripts like <code>parallel -a my_scripts bash</code> and at some point I decided I've run enough of them and would like to stop spawning new jobs, and simply let all the existing jobs finish. Put another way, I want to kill the parent process without killing the children.</p> <p>There ...
6,020
4,115,369
2022-10-10 09:42:22
45,155,136
16
2017-07-17 23:25:43
4,115,369
2022-10-10 09:42:22
https://stackoverflow.com/q/45147904
https://stackoverflow.com/a/45155136
<h2>Update:</h2> <p>If you have a new version of parallel <code>&gt;= 20190322</code>: as per @Bowi's comment, &quot;since 2019, it is no longer <code>SIGTERM</code>, it's <code>SIGHUP</code> instead:</p> <pre><code>kill -HUP $PARALLEL_PID </code></pre> <p><code>SIGTERM</code> now terminates the children without lettin...
<h2>Update:</h2> <p>If you have a new version of parallel <code>&gt;= 20190322</code>: as per @Bowi's comment, &quot;since 2019, it is no longer <code>SIGTERM</code>, it's <code>SIGHUP</code> instead:</p> <pre><code>kill -HUP $PARALLEL_PID </code></pre> <p><code>SIGTERM</code> now terminates the children without lettin...
58, 353, 387, 5910, 82247
bash, gnu-parallel, linux, parallel-processing, process
<h1>How do I terminate GNU parallel without killing running jobs?</h1> <p>I'm running a bunch of shell scripts like <code>parallel -a my_scripts bash</code> and at some point I decided I've run enough of them and would like to stop spawning new jobs, and simply let all the existing jobs finish. Put another way, I want ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,867
bash
# How do I terminate GNU parallel without killing running jobs? I'm running a bunch of shell scripts like `parallel -a my_scripts bash` and at some point I decided I've run enough of them and would like to stop spawning new jobs, and simply let all the existing jobs finish. Put another way, I want to kill the parent p...
## Update: If you have a new version of parallel `>= 20190322`: as per @Bowi's comment, "since 2019, it is no longer `SIGTERM`, it's `SIGHUP` instead: ``` kill -HUP $PARALLEL_PID ``` `SIGTERM` now terminates the children without letting them finish." See: - <https://superuser.com/questions/1660301/gnu-parallel-is-...
41721847
readarray -t option in bash default behavior?
10
2017-01-18 14:20:44
<p>From <code>man bash</code> on <code>readarray</code>:</p> <blockquote> <p>-t<br> Remove any trailing newline from a line read, before it is assigned to an array element.</p> </blockquote> <p>Is -t default behavior for readarray in bash?</p> <p>I tested it couple of times with -t and without on a file with new...
13,693
3,470,556
2017-01-18 14:45:22
41,722,162
16
2017-01-18 14:36:02
1,126,841
2017-01-18 14:36:02
https://stackoverflow.com/q/41721847
https://stackoverflow.com/a/41722162
<p>There is indeed a difference:</p> <pre><code># Newlines are retained as part each array element $ readarray foo &lt;&lt;EOF &gt; foo &gt; bar &gt; baz &gt; EOF $ printf '%s' "${foo[@]}" foo bar baz # Newlines are stripped $ readarray -t foo &lt;&lt;EOF foo bar baz EOF $ printf '%s' "${foo[@]}" foobarbaz </code></...
<p>There is indeed a difference:</p> <pre><code># Newlines are retained as part each array element $ readarray foo &lt;&lt;EOF &gt; foo &gt; bar &gt; baz &gt; EOF $ printf '%s' "${foo[@]}" foo bar baz # Newlines are stripped $ readarray -t foo &lt;&lt;EOF foo bar baz EOF $ printf '%s' "${foo[@]}" foobarbaz </code></...
114, 387
arrays, bash
<h1>readarray -t option in bash default behavior?</h1> <p>From <code>man bash</code> on <code>readarray</code>:</p> <blockquote> <p>-t<br> Remove any trailing newline from a line read, before it is assigned to an array element.</p> </blockquote> <p>Is -t default behavior for readarray in bash?</p> <p>I tested it...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,868
bash
# readarray -t option in bash default behavior? From `man bash` on `readarray`: > -t > Remove any trailing newline from a line read, before it is assigned to an array element. Is -t default behavior for readarray in bash? I tested it couple of times with -t and without on a file with newlines no difference notice...
There is indeed a difference: ``` # Newlines are retained as part each array element $ readarray foo <<EOF > foo > bar > baz > EOF $ printf '%s' "${foo[@]}" foo bar baz # Newlines are stripped $ readarray -t foo <<EOF foo bar baz EOF $ printf '%s' "${foo[@]}" foobarbaz ``` The format to `printf` does not include a ...
41194602
Docker disconnect all containers from docker network
10
2016-12-17 01:41:52
<p>I have docker network "my_network". I want to remove this docker network with <code>docker network rm my_network</code>. Before it I should disconnect all my containers from this network. I can use <code>docker network inspect</code> and get output like</p> <pre><code>[ { "Name": "my_network", ...
10,839
3,545,745
2017-05-09 18:44:56
41,194,696
16
2016-12-17 02:01:10
6,309
2017-05-09 18:44:56
https://stackoverflow.com/q/41194602
https://stackoverflow.com/a/41194696
<p><a href="https://docs.docker.com/engine/reference/commandline/network_inspect/" rel="noreferrer"><code>docker network inspect</code></a> has a <a href="http://docs.master.dockerproject.org/engine/admin/formatting/" rel="noreferrer">format option</a>.</p> <p>That means you can list all Container names with:</p> <pr...
<p><a href="https://docs.docker.com/engine/reference/commandline/network_inspect/" rel="noreferrer"><code>docker network inspect</code></a> has a <a href="http://docs.master.dockerproject.org/engine/admin/formatting/" rel="noreferrer">format option</a>.</p> <p>That means you can list all Container names with:</p> <pr...
387, 90304, 126320
bash, docker, docker-network
<h1>Docker disconnect all containers from docker network</h1> <p>I have docker network "my_network". I want to remove this docker network with <code>docker network rm my_network</code>. Before it I should disconnect all my containers from this network. I can use <code>docker network inspect</code> and get output like<...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,869
bash
# Docker disconnect all containers from docker network I have docker network "my_network". I want to remove this docker network with `docker network rm my_network`. Before it I should disconnect all my containers from this network. I can use `docker network inspect` and get output like ``` [ { "Name": "my...
[`docker network inspect`](https://docs.docker.com/engine/reference/commandline/network_inspect/) has a [format option](http://docs.master.dockerproject.org/engine/admin/formatting/). That means you can list all Container names with: ``` docker network inspect -f '{{range .Containers}}{{.Name}}{{end}}' network_name `...
33713088
Convert apache log date format to epoch in bash
10
2015-11-14 20:39:14
<p>My goal is to convert dates from my apache logs in the format <em>"12/Nov/2015:23:28:22"</em> to epoch format. Can this be done using the date command or do I need to parse and extract the information?</p>
4,122
2,704,766
2018-05-29 18:24:20
33,713,297
16
2015-11-14 20:57:59
4,687,135
2015-11-14 20:57:59
https://stackoverflow.com/q/33713088
https://stackoverflow.com/a/33713297
<p>It seems my <code>date</code> command wants <code>-</code> instead of <code>/</code> between the date parts and that to be separated by a space from the time part. So I used <code>sed</code> to do the conversion like so:</p> <pre><code>date -d "$(echo '12/Nov/2015:23:28:22' | sed -e 's,/,-,g' -e 's,:, ,')" +"%s" <...
<p>It seems my <code>date</code> command wants <code>-</code> instead of <code>/</code> between the date parts and that to be separated by a space from the time part. So I used <code>sed</code> to do the conversion like so:</p> <pre><code>date -d "$(echo '12/Nov/2015:23:28:22' | sed -e 's,/,-,g' -e 's,:, ,')" +"%s" <...
58, 387, 390, 106673
bash, centos7, linux, shell
<h1>Convert apache log date format to epoch in bash</h1> <p>My goal is to convert dates from my apache logs in the format <em>"12/Nov/2015:23:28:22"</em> to epoch format. Can this be done using the date command or do I need to parse and extract the information?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,870
bash
# Convert apache log date format to epoch in bash My goal is to convert dates from my apache logs in the format *"12/Nov/2015:23:28:22"* to epoch format. Can this be done using the date command or do I need to parse and extract the information?
It seems my `date` command wants `-` instead of `/` between the date parts and that to be separated by a space from the time part. So I used `sed` to do the conversion like so: ``` date -d "$(echo '12/Nov/2015:23:28:22' | sed -e 's,/,-,g' -e 's,:, ,')" +"%s" ```
31524786
How can I call many URLs from a list asynchronously
10
2015-07-20 19:28:31
<p>I have a few hundred thousand URLs that I need to call. These are calls to an application server which will process them and write a status code to a table. I do not need to wait for a response (success/fail), only that the server got the request. I also want to be able to specify how many concurrent jobs can be run...
16,648
2,430,498
2019-05-07 19:53:53
31,525,044
16
2015-07-20 19:43:57
712,649
2015-07-20 19:43:57
https://stackoverflow.com/q/31524786
https://stackoverflow.com/a/31525044
<p>With Jobs you incur a large amount of overhead, because each new Job spawns a new process.</p> <p>Use <a href="https://serverfault.com/questions/626711/how-do-i-run-my-powershell-scripts-in-parallel-without-using-jobs/626712#626712">Runspaces</a> instead!</p> <pre><code>$maxConcurrentJobs = 10 $content = Get-Conte...
<p>With Jobs you incur a large amount of overhead, because each new Job spawns a new process.</p> <p>Use <a href="https://serverfault.com/questions/626711/how-do-i-run-my-powershell-scripts-in-parallel-without-using-jobs/626712#626712">Runspaces</a> instead!</p> <pre><code>$maxConcurrentJobs = 10 $content = Get-Conte...
526, 24067, 43392
powershell, powershell-2.0, start-job
<h1>How can I call many URLs from a list asynchronously</h1> <p>I have a few hundred thousand URLs that I need to call. These are calls to an application server which will process them and write a status code to a table. I do not need to wait for a response (success/fail), only that the server got the request. I also w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,871
bash
# How can I call many URLs from a list asynchronously I have a few hundred thousand URLs that I need to call. These are calls to an application server which will process them and write a status code to a table. I do not need to wait for a response (success/fail), only that the server got the request. I also want to be...
With Jobs you incur a large amount of overhead, because each new Job spawns a new process. Use [Runspaces](https://serverfault.com/questions/626711/how-do-i-run-my-powershell-scripts-in-parallel-without-using-jobs/626712#626712) instead! ``` $maxConcurrentJobs = 10 $content = Get-Content -Path "C:\Temp\urls.txt" # C...
27257333
How do I escape curly braces {...} in powershell?
10
2014-12-02 19:26:24
<p>I need to generate multiple lines of xml tag with a GUID in them:</p> <pre><code>&lt;xmltag_10 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/&gt; &lt;xmltag_11 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/&gt; </code></pre> <p>and so on</p> <p>I have this line in a loop where $guid is generated each iteration,...
19,318
1,108,510
2019-08-23 19:33:02
27,257,380
16
2014-12-02 19:29:26
3,905,079
2019-08-23 19:32:30
https://stackoverflow.com/q/27257333
https://stackoverflow.com/a/27257380
<p>To escape curly braces, simply double them:</p> <pre><code>'{0}, {{1}}, {{{2}}}' -f 'zero', 'one', 'two' # outputs: # zero, {1}, {two} # i.e. # - {0} is replaced by zero because of normal substitution rules # - {{1}} is not replaced, as we've escaped/doubled the brackets # - {2} is replaced by two, but the doubl...
<p>To escape curly braces, simply double them:</p> <pre><code>'{0}, {{1}}, {{{2}}}' -f 'zero', 'one', 'two' # outputs: # zero, {1}, {two} # i.e. # - {0} is replaced by zero because of normal substitution rules # - {{1}} is not replaced, as we've escaped/doubled the brackets # - {2} is replaced by two, but the doubl...
526, 3567, 4804
escaping, guid, powershell
<h1>How do I escape curly braces {...} in powershell?</h1> <p>I need to generate multiple lines of xml tag with a GUID in them:</p> <pre><code>&lt;xmltag_10 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/&gt; &lt;xmltag_11 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/&gt; </code></pre> <p>and so on</p> <p>I have t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,872
bash
# How do I escape curly braces {...} in powershell? I need to generate multiple lines of xml tag with a GUID in them: ``` <xmltag_10 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/> <xmltag_11 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/> ``` and so on I have this line in a loop where $guid is generated each ite...
To escape curly braces, simply double them: ``` '{0}, {{1}}, {{{2}}}' -f 'zero', 'one', 'two' # outputs: # zero, {1}, {two} # i.e. # - {0} is replaced by zero because of normal substitution rules # - {{1}} is not replaced, as we've escaped/doubled the brackets # - {2} is replaced by two, but the doubled brackets su...
26619272
Permission denied when i try to execute a python script from bash?
10
2014-10-28 22:00:55
<p>I downloaded a python script from the web and when i try to execute it from bash it throws a exception: </p> <p><code>User:python_script user$ ./python_script.py -n some_parameter -b</code> </p> <p>The output is the following:</p> <pre><code>-bash: ./python_script.py: Permission denied </code></pre> <p>the file ...
36,610
4,140,027
2014-10-28 22:03:18
26,619,301
16
2014-10-28 22:03:18
367,273
2014-10-28 22:03:18
https://stackoverflow.com/q/26619272
https://stackoverflow.com/a/26619301
<p>You need to add execute permissions like so:</p> <pre><code>chmod u+x python_script.py </code></pre> <p>This assumes that the script is owned by you. If it isn't, you might need to change the group/other execute permissions or <code>chown</code> the file as appropriate.</p>
<p>You need to add execute permissions like so:</p> <pre><code>chmod u+x python_script.py </code></pre> <p>This assumes that the script is owned by you. If it isn't, you might need to change the group/other execute permissions or <code>chown</code> the file as appropriate.</p>
16, 387, 390, 59047
bash, python, python-2.7, shell
<h1>Permission denied when i try to execute a python script from bash?</h1> <p>I downloaded a python script from the web and when i try to execute it from bash it throws a exception: </p> <p><code>User:python_script user$ ./python_script.py -n some_parameter -b</code> </p> <p>The output is the following:</p> <pre><c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,873
bash
# Permission denied when i try to execute a python script from bash? I downloaded a python script from the web and when i try to execute it from bash it throws a exception: `User:python_script user$ ./python_script.py -n some_parameter -b` The output is the following: ``` -bash: ./python_script.py: Permission denie...
You need to add execute permissions like so: ``` chmod u+x python_script.py ``` This assumes that the script is owned by you. If it isn't, you might need to change the group/other execute permissions or `chown` the file as appropriate.
22296839
need a shell script to convert big endian to little endian
10
2014-03-10 09:52:47
<p>I need a shell script program to print the hexadecimal number from big endian to little endian</p> <h3>For example</h3> <ul> <li>Input: <code>my virtual address = 00d66d7e</code></li> <li>Output: <code>7e6dd600</code></li> </ul> <p>How can I can I create this in a bash script?</p>
23,825
2,431,159
2023-01-03 02:47:18
22,297,123
16
2014-03-10 10:05:49
650,405
2014-03-10 10:05:49
https://stackoverflow.com/q/22296839
https://stackoverflow.com/a/22297123
<p>For 32 bit addresses, assuming it's zero padded:</p> <pre><code>v=00d66d7e echo ${v:6:2}${v:4:2}${v:2:2}${v:0:2} # 7e6dd600 </code></pre>
<p>For 32 bit addresses, assuming it's zero padded:</p> <pre><code>v=00d66d7e echo ${v:6:2}${v:4:2}${v:2:2}${v:0:2} # 7e6dd600 </code></pre>
387, 390, 11692
bash, endianness, shell
<h1>need a shell script to convert big endian to little endian</h1> <p>I need a shell script program to print the hexadecimal number from big endian to little endian</p> <h3>For example</h3> <ul> <li>Input: <code>my virtual address = 00d66d7e</code></li> <li>Output: <code>7e6dd600</code></li> </ul> <p>How can I can I c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,874
bash
# need a shell script to convert big endian to little endian I need a shell script program to print the hexadecimal number from big endian to little endian ### For example - Input: `my virtual address = 00d66d7e` - Output: `7e6dd600` How can I can I create this in a bash script?
For 32 bit addresses, assuming it's zero padded: ``` v=00d66d7e echo ${v:6:2}${v:4:2}${v:2:2}${v:0:2} # 7e6dd600 ```
20629581
awk substitute shell variables
10
2013-12-17 08:46:51
<p>I am struggling with awk substitution, for some reason the following code does not substitute anything, it just prints the output unaltered. Can anyone see what I am missing here? Any help would be very much appreachiated! (PS! The $DOCPATH and $SITEPATH are shell variables, they work perfectly fine in my awk setup)...
14,502
2,304,259
2014-03-30 09:42:20
20,629,779
16
2013-12-17 08:58:33
2,235,132
2013-12-17 08:58:33
https://stackoverflow.com/q/20629581
https://stackoverflow.com/a/20629779
<p>Saying:</p> <pre><code>sub( /docpath/, sitepath ) </code></pre> <p>causes <code>awk</code> to replace the pattern <code>docpath</code>, not the variable <code>docpath</code>.</p> <p>You need to say:</p> <pre><code>awk -v docpath="$DOCPATH" -v sitepath="$SITEPATH" '{sub(docpath, sitepath)}1' filename </code></pre...
<p>Saying:</p> <pre><code>sub( /docpath/, sitepath ) </code></pre> <p>causes <code>awk</code> to replace the pattern <code>docpath</code>, not the variable <code>docpath</code>.</p> <p>You need to say:</p> <pre><code>awk -v docpath="$DOCPATH" -v sitepath="$SITEPATH" '{sub(docpath, sitepath)}1' filename </code></pre...
276, 387, 990, 16107
awk, bash, substitution, variables
<h1>awk substitute shell variables</h1> <p>I am struggling with awk substitution, for some reason the following code does not substitute anything, it just prints the output unaltered. Can anyone see what I am missing here? Any help would be very much appreachiated! (PS! The $DOCPATH and $SITEPATH are shell variables, t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,875
bash
# awk substitute shell variables I am struggling with awk substitution, for some reason the following code does not substitute anything, it just prints the output unaltered. Can anyone see what I am missing here? Any help would be very much appreachiated! (PS! The $DOCPATH and $SITEPATH are shell variables, they work ...
Saying: ``` sub( /docpath/, sitepath ) ``` causes `awk` to replace the pattern `docpath`, not the variable `docpath`. You need to say: ``` awk -v docpath="$DOCPATH" -v sitepath="$SITEPATH" '{sub(docpath, sitepath)}1' filename ```
19447352
Using grep inside shell script gives file not found error
10
2013-10-18 10:25:46
<p>I cannot believe I've spent 1.5 hours on something as trivial as this. I'm writing a <strong>very</strong> simple shell script which greps a file, stores the output in a variable, and echos the variable to STDOUT.</p> <p>I have checked the grep command with the regex on the command line, and it works fine. But for ...
25,233
1,493,303
2013-10-18 10:38:51
19,447,478
16
2013-10-18 10:31:32
1,066,031
2013-10-18 10:38:51
https://stackoverflow.com/q/19447352
https://stackoverflow.com/a/19447478
<p>You need to use command substitution:</p> <pre><code>#!/usr/bin/env bash test=$(grep 'foo' "$1") echo "$test" </code></pre> <p>Command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed like this:</p> <pre><code>$(command) </code></pr...
<p>You need to use command substitution:</p> <pre><code>#!/usr/bin/env bash test=$(grep 'foo' "$1") echo "$test" </code></pre> <p>Command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed like this:</p> <pre><code>$(command) </code></pr...
387, 390, 549, 1271
bash, grep, shell, ubuntu
<h1>Using grep inside shell script gives file not found error</h1> <p>I cannot believe I've spent 1.5 hours on something as trivial as this. I'm writing a <strong>very</strong> simple shell script which greps a file, stores the output in a variable, and echos the variable to STDOUT.</p> <p>I have checked the grep comm...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,876
bash
# Using grep inside shell script gives file not found error I cannot believe I've spent 1.5 hours on something as trivial as this. I'm writing a **very** simple shell script which greps a file, stores the output in a variable, and echos the variable to STDOUT. I have checked the grep command with the regex on the com...
You need to use command substitution: ``` #!/usr/bin/env bash test=$(grep 'foo' "$1") echo "$test" ``` Command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed like this: ``` $(command) ``` or like this using backticks: ``` `command`...
15579739
In an xterm, can I turn off bold or underline without resetting the current color?
10
2013-03-22 20:58:33
<p>I'm processing input (from sources like, but limited to, ls -la --color) and underlining certain sections of the text. I don't process these inputs character-by-character, but with lots of regular expressions, which makes it rather difficult to track whether the substring I'm affecting is already colored or in bold...
6,413
30,997
2023-08-12 21:45:51
15,581,497
16
2013-03-22 23:34:33
30,997
2013-03-22 23:34:33
https://stackoverflow.com/q/15579739
https://stackoverflow.com/a/15581497
<p>Nobody seems to document it, but adding 20 to the decorator codes will turn them off:</p> <pre><code> echo -e "\\033[34;4m" underlined "\\033[24m" not underlined echo -e "\\033[34;1m" bold "\\033[2m" not bold echo -e "\\033[34;2m" dark "\\033[22m" not dark echo -e "\\033[34;7m" inverse "\\033[27m" not invers...
<p>Nobody seems to document it, but adding 20 to the decorator codes will turn them off:</p> <pre><code> echo -e "\\033[34;4m" underlined "\\033[24m" not underlined echo -e "\\033[34;1m" bold "\\033[2m" not bold echo -e "\\033[34;2m" dark "\\033[22m" not dark echo -e "\\033[34;7m" inverse "\\033[27m" not invers...
387, 555, 8737, 12066, 14323
ansi-escape, bash, formatting, underline, xterm
<h1>In an xterm, can I turn off bold or underline without resetting the current color?</h1> <p>I'm processing input (from sources like, but limited to, ls -la --color) and underlining certain sections of the text. I don't process these inputs character-by-character, but with lots of regular expressions, which makes it...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,877
bash
# In an xterm, can I turn off bold or underline without resetting the current color? I'm processing input (from sources like, but limited to, ls -la --color) and underlining certain sections of the text. I don't process these inputs character-by-character, but with lots of regular expressions, which makes it rather di...
Nobody seems to document it, but adding 20 to the decorator codes will turn them off: ``` echo -e "\\033[34;4m" underlined "\\033[24m" not underlined echo -e "\\033[34;1m" bold "\\033[2m" not bold echo -e "\\033[34;2m" dark "\\033[22m" not dark echo -e "\\033[34;7m" inverse "\\033[27m" not inverse ```
15422757
How to pass variables from a shell script to an expect script?
10
2013-03-15 00:37:43
<p>I've shell script as below:</p> <pre><code>#!/bin/bash echo "Select the Gateway Server:" echo " 1. Gateway 1" echo " 2. Gateway 2" echo " 3. Gateway 3" read gatewayHost case $gatewayHost in 1) gateway="abc.com" ;; 2) gateway="pqr.com" ;; 3) gateway="xyz.com" ;; *) echo "Invalid choice" ;; e...
28,207
1,914,541
2017-02-19 18:08:38
15,422,824
16
2013-03-15 00:45:02
459,745
2013-03-15 00:45:02
https://stackoverflow.com/q/15422757
https://stackoverflow.com/a/15422824
<p>From your shell script:</p> <pre><code>/mypath/abc $gateway </code></pre> <p>From your expect script:</p> <pre><code>#!/usr/bin/expect set gateway [lindex $argv 0]; # Grab the first command line parameter set timeout 3 spawn ssh "james@$gateway" expect "password:" send "TSfdsHhtfs\r"; interact </code></pre>
<p>From your shell script:</p> <pre><code>/mypath/abc $gateway </code></pre> <p>From your expect script:</p> <pre><code>#!/usr/bin/expect set gateway [lindex $argv 0]; # Grab the first command line parameter set timeout 3 spawn ssh "james@$gateway" expect "password:" send "TSfdsHhtfs\r"; interact </code></pre>
387, 390, 9048
bash, expect, shell
<h1>How to pass variables from a shell script to an expect script?</h1> <p>I've shell script as below:</p> <pre><code>#!/bin/bash echo "Select the Gateway Server:" echo " 1. Gateway 1" echo " 2. Gateway 2" echo " 3. Gateway 3" read gatewayHost case $gatewayHost in 1) gateway="abc.com" ;; 2) gateway="p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,878
bash
# How to pass variables from a shell script to an expect script? I've shell script as below: ``` #!/bin/bash echo "Select the Gateway Server:" echo " 1. Gateway 1" echo " 2. Gateway 2" echo " 3. Gateway 3" read gatewayHost case $gatewayHost in 1) gateway="abc.com" ;; 2) gateway="pqr.com" ;; 3) ga...
From your shell script: ``` /mypath/abc $gateway ``` From your expect script: ``` #!/usr/bin/expect set gateway [lindex $argv 0]; # Grab the first command line parameter set timeout 3 spawn ssh "james@$gateway" expect "password:" send "TSfdsHhtfs\r"; interact ```
14602963
Faster grep function for big (27GB) files
10
2013-01-30 11:31:19
<p>I have to grep from a file (5MB) containing specific strings the same strings (and other information) from a big file (27GB). To speed up the analysis I split the 27GB file into 1GB files and then applied the following script (with the help of some people here). However it is not very efficient (to produce a 180KB ...
14,286
1,216,241
2019-03-05 18:15:57
14,603,747
16
2013-01-30 12:13:22
7,412
2013-01-30 12:13:22
https://stackoverflow.com/q/14602963
https://stackoverflow.com/a/14603747
<p>A few things you can try:</p> <p>1) You are reading <code>input.sam</code> multiple times. It only needs to be read once before your first loop starts. Save the ids to a temporary file which will be read by <code>grep</code>.</p> <p>2) Prefix your grep command with <code>LC_ALL=C</code> to use the C locale instead...
<p>A few things you can try:</p> <p>1) You are reading <code>input.sam</code> multiple times. It only needs to be read once before your first loop starts. Save the ids to a temporary file which will be read by <code>grep</code>.</p> <p>2) Prefix your grep command with <code>LC_ALL=C</code> to use the C locale instead...
387, 990, 1271, 5310
awk, bash, file, grep
<h1>Faster grep function for big (27GB) files</h1> <p>I have to grep from a file (5MB) containing specific strings the same strings (and other information) from a big file (27GB). To speed up the analysis I split the 27GB file into 1GB files and then applied the following script (with the help of some people here). Ho...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,879
bash
# Faster grep function for big (27GB) files I have to grep from a file (5MB) containing specific strings the same strings (and other information) from a big file (27GB). To speed up the analysis I split the 27GB file into 1GB files and then applied the following script (with the help of some people here). However it i...
A few things you can try: 1) You are reading `input.sam` multiple times. It only needs to be read once before your first loop starts. Save the ids to a temporary file which will be read by `grep`. 2) Prefix your grep command with `LC_ALL=C` to use the C locale instead of UTF-8. This will speed up `grep`. 3) Use `fgr...
14351991
Get a subset of lines from a big text file using PowerShell v2
10
2013-01-16 05:36:26
<p>I'm working with a big text file, I mean more than 100&nbsp;MB big, and I need to loop through a specific number of lines, a kind of subset so I'm trying with this,</p> <pre><code>$info = Get-Content -Path $TextFile | Select-Object -Index $from,$to foreach ($line in $info) { ,,, </code></pre> <p>But it does not wo...
29,006
903,471
2016-07-18 03:28:33
14,353,603
16
2013-01-16 07:52:34
9,833
2013-01-16 07:52:34
https://stackoverflow.com/q/14351991
https://stackoverflow.com/a/14353603
<pre><code>PS&gt; help select -param index -Index &lt;Int32[]&gt; Selects objects from an array based on their index values. Enter the indexes in a comma-separated list. Indexes in an array begin with 0, where 0 represents the first value and (n-1) represents the last value. Required? ...
<pre><code>PS&gt; help select -param index -Index &lt;Int32[]&gt; Selects objects from an array based on their index values. Enter the indexes in a comma-separated list. Indexes in an array begin with 0, where 0 represents the first value and (n-1) represents the last value. Required? ...
526, 17938
powershell, text-files
<h1>Get a subset of lines from a big text file using PowerShell v2</h1> <p>I'm working with a big text file, I mean more than 100&nbsp;MB big, and I need to loop through a specific number of lines, a kind of subset so I'm trying with this,</p> <pre><code>$info = Get-Content -Path $TextFile | Select-Object -Index $from...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,880
bash
# Get a subset of lines from a big text file using PowerShell v2 I'm working with a big text file, I mean more than 100 MB big, and I need to loop through a specific number of lines, a kind of subset so I'm trying with this, ``` $info = Get-Content -Path $TextFile | Select-Object -Index $from,$to foreach ($line in $i...
``` PS> help select -param index -Index <Int32[]> Selects objects from an array based on their index values. Enter the indexes in a comma-separated list. Indexes in an array begin with 0, where 0 represents the first value and (n-1) represents the last value. Required? false Positi...
12521647
Getting TeamCity to recognize Powershell messages
10
2012-09-20 22:10:45
<p>How do I get TeamCity to output messages in the build log with Powershell?</p> <p>I am using TeamCity 7.1.</p> <p>Here is my Powershell Build Step:<img src="https://i.sstatic.net/z76Ld.png" alt="enter image description here"></p> <p>The script is:</p> <pre><code>write-host "##teamcity[message 'Getting production...
7,290
257,975
2012-10-23 09:15:36
13,027,115
16
2012-10-23 09:15:36
1,039,742
2012-10-23 09:15:36
https://stackoverflow.com/q/12521647
https://stackoverflow.com/a/13027115
<p>As described in <a href="http://confluence.jetbrains.net/display/TCD7/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingMessagesForBuildLog">documentation</a> "message" service message can have multiple arguments, so you need to specify at least argument 'text': <code>"##teamcity[mes...
<p>As described in <a href="http://confluence.jetbrains.net/display/TCD7/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingMessagesForBuildLog">documentation</a> "message" service message can have multiple arguments, so you need to specify at least argument 'text': <code>"##teamcity[mes...
526, 76363
powershell, teamcity-7.0
<h1>Getting TeamCity to recognize Powershell messages</h1> <p>How do I get TeamCity to output messages in the build log with Powershell?</p> <p>I am using TeamCity 7.1.</p> <p>Here is my Powershell Build Step:<img src="https://i.sstatic.net/z76Ld.png" alt="enter image description here"></p> <p>The script is:</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,881
bash
# Getting TeamCity to recognize Powershell messages How do I get TeamCity to output messages in the build log with Powershell? I am using TeamCity 7.1. Here is my Powershell Build Step:![enter image description here](https://i.sstatic.net/z76Ld.png) The script is: ``` write-host "##teamcity[message 'Getting produc...
As described in [documentation](http://confluence.jetbrains.net/display/TCD7/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingMessagesForBuildLog) "message" service message can have multiple arguments, so you need to specify at least argument 'text': `"##teamcity[message text='Getting ...
12137908
Running the Clean, Build and Rebuild through the Package Manager Console
10
2012-08-27 07:36:08
<p>I want to run the Clean, Build and Rebuild commands through the Package Manager Console in Visual Studio but so far I haven't been able to find how.</p> <p>The following command gets me the first project inside the solution:</p> <pre><code>$project = Get-Project | select -First 1 </code></pre> <p>When I run the <...
3,542
463,785
2012-08-27 12:38:53
12,142,141
16
2012-08-27 12:38:53
268,874
2012-08-27 12:38:53
https://stackoverflow.com/q/12137908
https://stackoverflow.com/a/12142141
<p>Visual Studio's object model provides a way to build the entire solution or a single project via the <a href="http://msdn.microsoft.com/en-US/library/envdte.solutionbuild%28v=vs.100%29" rel="noreferrer">SolutionBuild</a> object.</p> <p>Building the solution is straightforward from the NuGet Package Manager Console....
<p>Visual Studio's object model provides a way to build the entire solution or a single project via the <a href="http://msdn.microsoft.com/en-US/library/envdte.solutionbuild%28v=vs.100%29" rel="noreferrer">SolutionBuild</a> object.</p> <p>Building the solution is straightforward from the NuGet Package Manager Console....
526, 33953, 62770
nuget, powershell, visual-studio
<h1>Running the Clean, Build and Rebuild through the Package Manager Console</h1> <p>I want to run the Clean, Build and Rebuild commands through the Package Manager Console in Visual Studio but so far I haven't been able to find how.</p> <p>The following command gets me the first project inside the solution:</p> <pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,882
bash
# Running the Clean, Build and Rebuild through the Package Manager Console I want to run the Clean, Build and Rebuild commands through the Package Manager Console in Visual Studio but so far I haven't been able to find how. The following command gets me the first project inside the solution: ``` $project = Get-Proje...
Visual Studio's object model provides a way to build the entire solution or a single project via the [SolutionBuild](http://msdn.microsoft.com/en-US/library/envdte.solutionbuild%28v=vs.100%29) object. Building the solution is straightforward from the NuGet Package Manager Console. ``` $dte.Solution.SolutionBuild.Clea...
11579008
Writing to an excel sheet using Bash
10
2012-07-20 12:03:57
<p>Is it possible to write to an excel sheet(any type) from a bash script ?</p> <p>What I am looking for is something along these lines :</p> <pre><code>sed -e :a -e '$!N; s/\n/ /; ta' file.c &gt; #( first coloumn ,second row of the spread sheet ) echo "$cdvar" &gt; #( second coloumn ,third row of the spread sheet )...
84,111
1,457,118
2021-12-13 02:25:01
11,590,073
16
2012-07-21 06:46:49
1,472,538
2021-12-13 02:25:01
https://stackoverflow.com/q/11579008
https://stackoverflow.com/a/11590073
<p>You could write excel by <code>bash</code>, <code>perl</code>, <code>python</code>, .. I think that each program language has its solutions.</p> <p><strong>bash</strong></p> <p>You could use <code>join</code> or <code>awk</code>, and I think that there are other solutions.</p> <p><em>join</em></p> <p>If you want <co...
<p>You could write excel by <code>bash</code>, <code>perl</code>, <code>python</code>, .. I think that each program language has its solutions.</p> <p><strong>bash</strong></p> <p>You could use <code>join</code> or <code>awk</code>, and I think that there are other solutions.</p> <p><em>join</em></p> <p>If you want <co...
387, 522, 990, 5282
awk, bash, excel, sed
<h1>Writing to an excel sheet using Bash</h1> <p>Is it possible to write to an excel sheet(any type) from a bash script ?</p> <p>What I am looking for is something along these lines :</p> <pre><code>sed -e :a -e '$!N; s/\n/ /; ta' file.c &gt; #( first coloumn ,second row of the spread sheet ) echo "$cdvar" &gt; #( s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,883
bash
# Writing to an excel sheet using Bash Is it possible to write to an excel sheet(any type) from a bash script ? What I am looking for is something along these lines : ``` sed -e :a -e '$!N; s/\n/ /; ta' file.c > #( first coloumn ,second row of the spread sheet ) echo "$cdvar" > #( second coloumn ,third row of the s...
You could write excel by `bash`, `perl`, `python`, .. I think that each program language has its solutions. **bash** You could use `join` or `awk`, and I think that there are other solutions. *join* If you want `join` to files with same column, look these posts: [Bash join command](https://stackoverflow.com/questio...
11117493
How to delete the rows that start with "C" with awk?
10
2012-06-20 10:21:30
<p>How can I delete the rows that start with "C" from a text file using <code>awk</code>?</p> <p>Any suggestions please.</p>
8,360
1,460,569
2012-06-20 17:07:29
11,118,962
16
2012-06-20 11:54:06
1,209,279
2012-06-20 13:02:45
https://stackoverflow.com/q/11117493
https://stackoverflow.com/a/11118962
<p>If data is in file <code>data.txt</code>, then</p> <p>With <code>awk</code>:</p> <pre><code>awk '!/^C/' data.txt </code></pre> <p>With <code>grep</code>:</p> <pre><code>grep -v ^C data.txt </code></pre> <p>Display all lines without "C" at the start.</p> <p><code>^C</code> means to match letter "C" at <em>star...
<p>If data is in file <code>data.txt</code>, then</p> <p>With <code>awk</code>:</p> <pre><code>awk '!/^C/' data.txt </code></pre> <p>With <code>grep</code>:</p> <pre><code>grep -v ^C data.txt </code></pre> <p>Display all lines without "C" at the start.</p> <p><code>^C</code> means to match letter "C" at <em>star...
390, 990
awk, shell
<h1>How to delete the rows that start with "C" with awk?</h1> <p>How can I delete the rows that start with "C" from a text file using <code>awk</code>?</p> <p>Any suggestions please.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,884
bash
# How to delete the rows that start with "C" with awk? How can I delete the rows that start with "C" from a text file using `awk`? Any suggestions please.
If data is in file `data.txt`, then With `awk`: ``` awk '!/^C/' data.txt ``` With `grep`: ``` grep -v ^C data.txt ``` Display all lines without "C" at the start. `^C` means to match letter "C" at *start* of line. `!` in awk, and `-v` in grep negate the match.
10671634
Cakephp shell :Shell class HelloShell could not be found
10
2012-05-20 07:36:16
<p>I am a newer to cakephp .I config the cakephp shell as the cakephp handbook says,when I run the HelloShell with the command cake Hello ,I got the error information as follows:</p> <pre><code>Error: Shell class HelloShell could not be found. 1#G:\htdocs\cakedemo\lib\Cake\Console\ShellDispatcher.php(191):ShellDispat...
11,230
1,404,881
2016-03-24 10:39:31
10,672,041
16
2012-05-20 08:45:39
461,173
2014-06-16 09:38:57
https://stackoverflow.com/q/10671634
https://stackoverflow.com/a/10672041
<p>there is your mistake. you should always be in your APP path to execute the cake console.</p> <pre><code>...app/&gt;../lib/Cake/Console/cake MyShell </code></pre> <p>or (using the APP Console folder):</p> <pre><code>...app/&gt;Console/cake MyShell </code></pre> <p>and MyShell should then be in <code>...app/Conso...
<p>there is your mistake. you should always be in your APP path to execute the cake console.</p> <pre><code>...app/&gt;../lib/Cake/Console/cake MyShell </code></pre> <p>or (using the APP Console folder):</p> <pre><code>...app/&gt;Console/cake MyShell </code></pre> <p>and MyShell should then be in <code>...app/Conso...
390, 3437
cakephp, shell
<h1>Cakephp shell :Shell class HelloShell could not be found</h1> <p>I am a newer to cakephp .I config the cakephp shell as the cakephp handbook says,when I run the HelloShell with the command cake Hello ,I got the error information as follows:</p> <pre><code>Error: Shell class HelloShell could not be found. 1#G:\htd...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,885
bash
# Cakephp shell :Shell class HelloShell could not be found I am a newer to cakephp .I config the cakephp shell as the cakephp handbook says,when I run the HelloShell with the command cake Hello ,I got the error information as follows: ``` Error: Shell class HelloShell could not be found. 1#G:\htdocs\cakedemo\lib\Cake...
there is your mistake. you should always be in your APP path to execute the cake console. ``` ...app/>../lib/Cake/Console/cake MyShell ``` or (using the APP Console folder): ``` ...app/>Console/cake MyShell ``` and MyShell should then be in `...app/Console/Command/`. Thats all there is to it.
9178685
Change DataSource of SSRS Report with Powershell
10
2012-02-07 15:11:44
<p>I'm trying to ahange data sources of multiple SSRS Report with Powershell to one shared data source on my reporting server. Here my code:</p> <pre><code>cls; $reportserver = "myServer";&lt;br/&gt; $url = "http://$($reportserver)/reportserver/reportservice2005.asmx?WSDL";";&lt;br/&gt; $ssrs = New-WebServiceProxy -...
27,438
1,194,945
2018-11-19 19:26:18
9,309,605
16
2012-02-16 10:28:21
1,194,945
2012-02-16 10:28:21
https://stackoverflow.com/q/9178685
https://stackoverflow.com/a/9309605
<p>Thanks e82.eric!</p> <p>you led me to the working solution. Here it is:</p> <pre><code>cls; #Set variables: $reportserver = "myServer"; $newDataSourcePath = "/Data Sources/MyDS" $newDataSourceName = "MyDS"; $reportFolderPath = "/DH" #------------------------------------------------------------------------ $ssrs ...
<p>Thanks e82.eric!</p> <p>you led me to the working solution. Here it is:</p> <pre><code>cls; #Set variables: $reportserver = "myServer"; $newDataSourcePath = "/Data Sources/MyDS" $newDataSourceName = "MyDS"; $reportFolderPath = "/DH" #------------------------------------------------------------------------ $ssrs ...
526, 3512, 25916
datasource, powershell, reportingservices-2005
<h1>Change DataSource of SSRS Report with Powershell</h1> <p>I'm trying to ahange data sources of multiple SSRS Report with Powershell to one shared data source on my reporting server. Here my code:</p> <pre><code>cls; $reportserver = "myServer";&lt;br/&gt; $url = "http://$($reportserver)/reportserver/reportservice2...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,886
bash
# Change DataSource of SSRS Report with Powershell I'm trying to ahange data sources of multiple SSRS Report with Powershell to one shared data source on my reporting server. Here my code: ``` cls; $reportserver = "myServer";<br/> $url = "http://$($reportserver)/reportserver/reportservice2005.asmx?WSDL";";<br/> $ss...
Thanks e82.eric! you led me to the working solution. Here it is: ``` cls; #Set variables: $reportserver = "myServer"; $newDataSourcePath = "/Data Sources/MyDS" $newDataSourceName = "MyDS"; $reportFolderPath = "/DH" #------------------------------------------------------------------------ $ssrs = New-WebServiceProxy...
9052220
Hash inside Makefile shell call causes unexpected behaviour
10
2012-01-29 09:35:12
<p>The following command prints the absolute path of a particular C++ header, according to where g++ believes it to be.</p> <pre><code>echo \#include\&lt;ham/hamsterdb.h\&gt; | g++ -M -x c++-header - | grep hamsterdb.hpp | sed -e 's/-: //' -e 's/ \\//' </code></pre> <p>On my system, this outputs: <code>/usr/local/in...
6,963
184,741
2023-11-10 17:37:07
9,052,257
16
2012-01-29 09:45:02
545,027
2012-01-29 09:51:53
https://stackoverflow.com/q/9052220
https://stackoverflow.com/a/9052257
<p>You have to escape the hash twice in order to use it inside functions: once for Make and once again for the shell.</p> <p>That is,</p> <pre><code>FILE = $(shell echo \\\#include\ \&lt;ham/hamsterdb.h\&gt;) </code></pre> <p>Notice three backslashes instead of two as one could expect. The third backslash is needed ...
<p>You have to escape the hash twice in order to use it inside functions: once for Make and once again for the shell.</p> <p>That is,</p> <pre><code>FILE = $(shell echo \\\#include\ \&lt;ham/hamsterdb.h\&gt;) </code></pre> <p>Notice three backslashes instead of two as one could expect. The third backslash is needed ...
390, 4301, 4747, 13824
echo, g++, makefile, shell
<h1>Hash inside Makefile shell call causes unexpected behaviour</h1> <p>The following command prints the absolute path of a particular C++ header, according to where g++ believes it to be.</p> <pre><code>echo \#include\&lt;ham/hamsterdb.h\&gt; | g++ -M -x c++-header - | grep hamsterdb.hpp | sed -e 's/-: //' -e 's/ \\...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,887
bash
# Hash inside Makefile shell call causes unexpected behaviour The following command prints the absolute path of a particular C++ header, according to where g++ believes it to be. ``` echo \#include\<ham/hamsterdb.h\> | g++ -M -x c++-header - | grep hamsterdb.hpp | sed -e 's/-: //' -e 's/ \\//' ``` On my system, thi...
You have to escape the hash twice in order to use it inside functions: once for Make and once again for the shell. That is, ``` FILE = $(shell echo \\\#include\ \<ham/hamsterdb.h\>) ``` Notice three backslashes instead of two as one could expect. The third backslash is needed because otherwise the first one would es...
7872789
Script repeat itself after X minutes
10
2011-10-24 08:09:51
<p>I have a bash script in Ubuntu, I want it to run every 10 minutes for example after it's done. How can I do this? Thanks!</p>
10,051
1,009,123
2017-11-22 09:06:57
7,873,066
16
2011-10-24 08:38:54
925,381
2011-10-24 08:38:54
https://stackoverflow.com/q/7872789
https://stackoverflow.com/a/7873066
<p>You can check <code>watch</code>.<br> From <a href="http://linux.die.net/man/1/watch">the man pages of <code>watch</code></a> the description says <code>watch - execute a program periodically, showing output fullscreen</code>, you can try <code>watch -n 600 my_script.sh</code> which will execute <code>myscript.sh</c...
<p>You can check <code>watch</code>.<br> From <a href="http://linux.die.net/man/1/watch">the man pages of <code>watch</code></a> the description says <code>watch - execute a program periodically, showing output fullscreen</code>, you can try <code>watch -n 600 my_script.sh</code> which will execute <code>myscript.sh</c...
387, 2314
bash, loops
<h1>Script repeat itself after X minutes</h1> <p>I have a bash script in Ubuntu, I want it to run every 10 minutes for example after it's done. How can I do this? Thanks!</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,888
bash
# Script repeat itself after X minutes I have a bash script in Ubuntu, I want it to run every 10 minutes for example after it's done. How can I do this? Thanks!
You can check `watch`. From [the man pages of `watch`](http://linux.die.net/man/1/watch) the description says `watch - execute a program periodically, showing output fullscreen`, you can try `watch -n 600 my_script.sh` which will execute `myscript.sh` every 600 seconds i.e. 10 minutes. `watch` shows the output to ful...
5948717
Calling shell command from ruby with proper argument escaping
10
2011-05-10 10:33:22
<p>I want to do the following securely</p> <pre><code>system "echo '#{params[:message]}' &gt; /dev/log" </code></pre> <p>What is the <strong>proper</strong> way for escaping arguments when calling a native command?</p> <p>(Example evil input: <code>'; rm -Rf *; echo 'I won.</code>)</p>
1,965
163,454
2011-05-10 10:51:47
5,948,901
16
2011-05-10 10:51:47
24,195
2011-05-10 10:51:47
https://stackoverflow.com/q/5948717
https://stackoverflow.com/a/5948901
<p>If you do</p> <pre><code>system "echo", params[:message] </code></pre> <p>Then the second argument, will be sent as an argument, it will not be executed.</p>
<p>If you do</p> <pre><code>system "echo", params[:message] </code></pre> <p>Then the second argument, will be sent as an argument, it will not be executed.</p>
12, 390, 4804
escaping, ruby, shell
<h1>Calling shell command from ruby with proper argument escaping</h1> <p>I want to do the following securely</p> <pre><code>system "echo '#{params[:message]}' &gt; /dev/log" </code></pre> <p>What is the <strong>proper</strong> way for escaping arguments when calling a native command?</p> <p>(Example evil input: <co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,889
bash
# Calling shell command from ruby with proper argument escaping I want to do the following securely ``` system "echo '#{params[:message]}' > /dev/log" ``` What is the **proper** way for escaping arguments when calling a native command? (Example evil input: `'; rm -Rf *; echo 'I won.`)
If you do ``` system "echo", params[:message] ``` Then the second argument, will be sent as an argument, it will not be executed.
2753350
How to make shell output redirect (>) write while script is still running?
10
2010-05-02 11:50:45
<p>I wrote a short script that never terminates. This script continuously generates output that I have to check on every now and then. I'm running it on a lab computer through SSH, and redirecting the output to a file in my public_html folder on that machine.</p> <pre><code>python script.py &gt; ~/public_html/results....
19,692
224,949
2010-05-02 12:40:00
2,753,361
16
2010-05-02 11:53:03
226,266
2010-05-02 11:53:03
https://stackoverflow.com/q/2753350
https://stackoverflow.com/a/2753361
<p>You need to flush the output <code>sys.stdout.flush()</code> (or smth) if you want to see it immediately. See <a href="https://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print">this</a></p>
<p>You need to flush the output <code>sys.stdout.flush()</code> (or smth) if you want to see it immediately. See <a href="https://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print">this</a></p>
16, 58, 387, 390, 1231
bash, command-line, linux, python, shell
<h1>How to make shell output redirect (>) write while script is still running?</h1> <p>I wrote a short script that never terminates. This script continuously generates output that I have to check on every now and then. I'm running it on a lab computer through SSH, and redirecting the output to a file in my public_html ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,890
bash
# How to make shell output redirect (>) write while script is still running? I wrote a short script that never terminates. This script continuously generates output that I have to check on every now and then. I'm running it on a lab computer through SSH, and redirecting the output to a file in my public_html folder on...
You need to flush the output `sys.stdout.flush()` (or smth) if you want to see it immediately. See [this](https://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print)
1827561
PowerShell: passing blocks as parameters to functions
10
2009-12-01 17:04:51
<p>I will explain my question on an example. Let's have following code in C#:</p> <pre><code>void A(Action block) { B(() =&gt; { Console.WriteLine(2); block(); }); } void B(Action block) { Console.WriteLine(1); block(); } void Main() { A(() =&gt; { Console.WriteLine(3); }); } </code></pre> <p>The outp...
4,163
121,968
2015-04-16 00:17:02
1,827,658
16
2009-12-01 17:23:42
153,982
2009-12-01 17:23:42
https://stackoverflow.com/q/1827561
https://stackoverflow.com/a/1827658
<p>Yeah, you're going recursive because the <code>$block</code> reference in the scriptblock passed into function B gets evaluated in the context of function B and as a result, evaluates to the value of B's <code>$block</code> parameter. </p> <p>If you don't want to change the parameter name (don't blame you) you can...
<p>Yeah, you're going recursive because the <code>$block</code> reference in the scriptblock passed into function B gets evaluated in the context of function B and as a result, evaluates to the value of B's <code>$block</code> parameter. </p> <p>If you don't want to change the parameter name (don't blame you) you can...
1, 9, 360, 526
.net, c#, parameters, powershell
<h1>PowerShell: passing blocks as parameters to functions</h1> <p>I will explain my question on an example. Let's have following code in C#:</p> <pre><code>void A(Action block) { B(() =&gt; { Console.WriteLine(2); block(); }); } void B(Action block) { Console.WriteLine(1); block(); } void Main() { A(() =&g...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,891
bash
# PowerShell: passing blocks as parameters to functions I will explain my question on an example. Let's have following code in C#: ``` void A(Action block) { B(() => { Console.WriteLine(2); block(); }); } void B(Action block) { Console.WriteLine(1); block(); } void Main() { A(() => { Console.WriteLine(...
Yeah, you're going recursive because the `$block` reference in the scriptblock passed into function B gets evaluated in the context of function B and as a result, evaluates to the value of B's `$block` parameter. If you don't want to change the parameter name (don't blame you) you can force PowerShell to create a new ...
722901
Advice for Windows XP Scripting, WSH versus PowerShell
10
2009-04-06 19:49:55
<p>After much experience scripting in the Unix/Linux open-source world, using languages such as Bourne Shell, Perl, Python, and Ruby, I now find myself needing to do some Windows XP administration scripting. It appears that the legacy environment is Windows Script Host (WSH), which can use various scripting languages, ...
8,887
87,420
2017-05-18 08:10:26
723,084
16
2009-04-06 20:27:47
4,035
2009-04-06 20:56:06
https://stackoverflow.com/q/722901
https://stackoverflow.com/a/723084
<blockquote> <p>Is it "worthwhile"?</p> </blockquote> <p>Absolutely. Here are number of reasons why.<br /></p> <ol> <li>More and more Microsoft products are based-on PowerShell - e.g. Exchange Server 2007, SQL Server 2008, etc.<br /></li> <li>PowerShell can access Microsoft .NET.</li> <li>Easy to learn - You only ...
<blockquote> <p>Is it "worthwhile"?</p> </blockquote> <p>Absolutely. Here are number of reasons why.<br /></p> <ol> <li>More and more Microsoft products are based-on PowerShell - e.g. Exchange Server 2007, SQL Server 2008, etc.<br /></li> <li>PowerShell can access Microsoft .NET.</li> <li>Easy to learn - You only ...
494, 526, 531, 2216, 6701
powershell, scripting, vbscript, windows-xp, wsh
<h1>Advice for Windows XP Scripting, WSH versus PowerShell</h1> <p>After much experience scripting in the Unix/Linux open-source world, using languages such as Bourne Shell, Perl, Python, and Ruby, I now find myself needing to do some Windows XP administration scripting. It appears that the legacy environment is Window...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,892
bash
# Advice for Windows XP Scripting, WSH versus PowerShell After much experience scripting in the Unix/Linux open-source world, using languages such as Bourne Shell, Perl, Python, and Ruby, I now find myself needing to do some Windows XP administration scripting. It appears that the legacy environment is Windows Script ...
> Is it "worthwhile"? Absolutely. Here are number of reasons why. 1. More and more Microsoft products are based-on PowerShell - e.g. Exchange Server 2007, SQL Server 2008, etc. 2. PowerShell can access Microsoft .NET. 3. Easy to learn - You only need few commands to explore capabilities of PowerShell - e.g.) Get-Comm...
628617
Moving All Files From Directories One Step Up
10
2009-03-10 01:24:32
<p>I have a directories that look like this</p> <pre><code>fool@brat:/mydir/ucsc_mm8&gt; tar -xvf *.tar 1/chr1.fa.masked 1/chr1_random.fa.masked 2/chr2.fa.masked 3/chr3.fa.masked 4/chr4.fa.masked 5/chr5.fa.masked 5/chr5_random.fa.masked 19/chr19.fa.masked Un/chrUn_random.fa.masked </code></pre> <p>What I want to do ...
8,729
67,405
2012-05-05 06:00:03
628,627
16
2009-03-10 01:32:54
74,493
2009-03-10 01:32:54
https://stackoverflow.com/q/628617
https://stackoverflow.com/a/628627
<p>The typical way of moving files all files matching a particular expression is</p> <pre><code>mv 1/*.masked targetDir </code></pre> <p>where targetDir could be .. </p> <p>If you want to move it from directories 1,2,3 then you can do something like</p> <pre><code>mv */*.masked targetDir </code></pre> <p>Or, if yo...
<p>The typical way of moving files all files matching a particular expression is</p> <pre><code>mv 1/*.masked targetDir </code></pre> <p>where targetDir could be .. </p> <p>If you want to move it from directories 1,2,3 then you can do something like</p> <pre><code>mv */*.masked targetDir </code></pre> <p>Or, if yo...
34, 58, 387, 390, 12668
bash, linux, mv, shell, unix
<h1>Moving All Files From Directories One Step Up</h1> <p>I have a directories that look like this</p> <pre><code>fool@brat:/mydir/ucsc_mm8&gt; tar -xvf *.tar 1/chr1.fa.masked 1/chr1_random.fa.masked 2/chr2.fa.masked 3/chr3.fa.masked 4/chr4.fa.masked 5/chr5.fa.masked 5/chr5_random.fa.masked 19/chr19.fa.masked Un/chrU...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,893
bash
# Moving All Files From Directories One Step Up I have a directories that look like this ``` fool@brat:/mydir/ucsc_mm8> tar -xvf *.tar 1/chr1.fa.masked 1/chr1_random.fa.masked 2/chr2.fa.masked 3/chr3.fa.masked 4/chr4.fa.masked 5/chr5.fa.masked 5/chr5_random.fa.masked 19/chr19.fa.masked Un/chrUn_random.fa.masked ``` ...
The typical way of moving files all files matching a particular expression is ``` mv 1/*.masked targetDir ``` where targetDir could be .. If you want to move it from directories 1,2,3 then you can do something like ``` mv */*.masked targetDir ``` Or, if you want to specifically move it from numbered directories, y...
70211581
Disable a device without a confirmation - PowerShell
9
2021-12-03 08:43:57
<p>I'm working on a script that automates the process of disabling multiple Devices in Windows 10. This is my attempt:</p> <pre><code>Get-PnpDevice something | Disable-PnpDevice </code></pre> <p>That code asks the user to enter <code>y</code> or <code>n</code> to confirm the process of disabling the device.</p> <p>How ...
8,084
16,330,115
2021-12-03 08:56:19
70,211,708
16
2021-12-03 08:56:19
14,638,694
2021-12-03 08:56:19
https://stackoverflow.com/q/70211581
https://stackoverflow.com/a/70211708
<p>If the script uses PowerShell cmdlets, you can specify -<strong>Confirm:$false</strong> to suppress the prompt.</p> <pre><code>Get-PnpDevice something | Disable-PnpDevice -Confirm:$false </code></pre>
<p>If the script uses PowerShell cmdlets, you can specify -<strong>Confirm:$false</strong> to suppress the prompt.</p> <pre><code>Get-PnpDevice something | Disable-PnpDevice -Confirm:$false </code></pre>
64, 526
powershell, windows
<h1>Disable a device without a confirmation - PowerShell</h1> <p>I'm working on a script that automates the process of disabling multiple Devices in Windows 10. This is my attempt:</p> <pre><code>Get-PnpDevice something | Disable-PnpDevice </code></pre> <p>That code asks the user to enter <code>y</code> or <code>n</cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,894
bash
# Disable a device without a confirmation - PowerShell I'm working on a script that automates the process of disabling multiple Devices in Windows 10. This is my attempt: ``` Get-PnpDevice something | Disable-PnpDevice ``` That code asks the user to enter `y` or `n` to confirm the process of disabling the device. H...
If the script uses PowerShell cmdlets, you can specify -**Confirm:$false** to suppress the prompt. ``` Get-PnpDevice something | Disable-PnpDevice -Confirm:$false ```
56220620
.NET tracing in PowerShell without creating .config file
9
2019-05-20 12:01:15
<p>I know I can enable <a href="https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/tracing-and-instrumenting-applications" rel="nofollow noreferrer">.NET tracing</a> by adding <a href="https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/trace-debug/system-diagnostics-elemen...
2,597
850,848
2020-05-31 10:48:11
56,296,231
16
2019-05-24 16:13:12
909,199
2019-05-28 08:28:09
https://stackoverflow.com/q/56220620
https://stackoverflow.com/a/56296231
<p>Just enabling the default trace sources (<code>Trace.Information</code> etc.) in code (and therefore in Powershell) is relatively easy.</p> <p>Doing so for the <code>System.Net</code> trace sources is more complicated because they are not publicly accessible.</p> <p>I have previously seen that in C#, calling a <co...
<p>Just enabling the default trace sources (<code>Trace.Information</code> etc.) in code (and therefore in Powershell) is relatively easy.</p> <p>Doing so for the <code>System.Net</code> trace sources is more complicated because they are not publicly accessible.</p> <p>I have previously seen that in C#, calling a <co...
1, 526, 3107
.net, app-config, powershell
<h1>.NET tracing in PowerShell without creating .config file</h1> <p>I know I can enable <a href="https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/tracing-and-instrumenting-applications" rel="nofollow noreferrer">.NET tracing</a> by adding <a href="https://learn.microsoft.com/en-us/dotnet/framewor...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,895
bash
# .NET tracing in PowerShell without creating .config file I know I can enable [.NET tracing](https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/tracing-and-instrumenting-applications) by adding [`<system.diagnostics>` element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-...
Just enabling the default trace sources (`Trace.Information` etc.) in code (and therefore in Powershell) is relatively easy. Doing so for the `System.Net` trace sources is more complicated because they are not publicly accessible. I have previously seen that in C#, calling a `System.Net` method e.g. `Dns.Resolve` was...
54797475
How to remove duplicate elements in an existing array in bash?
9
2019-02-21 00:41:51
<p>How do I create a newArray containing only the unique elements present in Array?</p> <p>Ex: ARRAY contains elements <code>aa ab bb aa ab cc</code> at ARRAY[0-5] respectively.</p> <p>When I print newARRAY, I want only <code>aa ab bb cc</code> at newARRAY[0-3] respectively.</p> <p>I've searched stack overflow for a...
15,270
11,087,586
2019-02-21 01:21:38
54,797,587
16
2019-02-21 00:53:47
3,030,305
2019-02-21 01:16:44
https://stackoverflow.com/q/54797475
https://stackoverflow.com/a/54797587
<h3>Naive approach</h3> <p>To get the unique elements of <code>arr</code> and assuming that no element contains newlines:</p> <pre><code>$ printf "%s\n" "${arr[@]}" | sort -u aa ab bb cc </code></pre> <h3>Better approach</h3> <p>To get a NUL-separated list that works even if there were newlines:</p> <pre><code>$ p...
<h3>Naive approach</h3> <p>To get the unique elements of <code>arr</code> and assuming that no element contains newlines:</p> <pre><code>$ printf "%s\n" "${arr[@]}" | sort -u aa ab bb cc </code></pre> <h3>Better approach</h3> <p>To get a NUL-separated list that works even if there were newlines:</p> <pre><code>$ p...
34, 387
bash, unix
<h1>How to remove duplicate elements in an existing array in bash?</h1> <p>How do I create a newArray containing only the unique elements present in Array?</p> <p>Ex: ARRAY contains elements <code>aa ab bb aa ab cc</code> at ARRAY[0-5] respectively.</p> <p>When I print newARRAY, I want only <code>aa ab bb cc</code> a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,896
bash
# How to remove duplicate elements in an existing array in bash? How do I create a newArray containing only the unique elements present in Array? Ex: ARRAY contains elements `aa ab bb aa ab cc` at ARRAY[0-5] respectively. When I print newARRAY, I want only `aa ab bb cc` at newARRAY[0-3] respectively. I've searched ...
### Naive approach To get the unique elements of `arr` and assuming that no element contains newlines: ``` $ printf "%s\n" "${arr[@]}" | sort -u aa ab bb cc ``` ### Better approach To get a NUL-separated list that works even if there were newlines: ``` $ printf "%s\0" "${arr[@]}" | sort -uz aaabbbcc ``` (This, of...
54041428
How to list directory size of all child directories?
9
2019-01-04 15:01:34
<p>From the shell, I need to list the size of all child directories. I am currently using:</p> <pre><code>du -hs * | sort -hr </code></pre> <p>However, this only gets one level down and does not traverse the directory tree.</p>
8,825
6,152,965
2019-01-04 15:28:06
54,041,662
16
2019-01-04 15:18:01
8,344,060
2019-01-04 15:27:29
https://stackoverflow.com/q/54041428
https://stackoverflow.com/a/54041662
<p>The simplest is:</p> <pre><code>du -h --max-depth=1 parent </code></pre> <p>This will show all sizes of the children of <code>parent</code> If you also want the grandchildren, you can do</p> <pre><code>du -h --max-depth=2 parent </code></pre> <p>If you want the whole family</p> <pre><code>du -h parent </code></...
<p>The simplest is:</p> <pre><code>du -h --max-depth=1 parent </code></pre> <p>This will show all sizes of the children of <code>parent</code> If you also want the grandchildren, you can do</p> <pre><code>du -h --max-depth=2 parent </code></pre> <p>If you want the whole family</p> <pre><code>du -h parent </code></...
58, 387, 390
bash, linux, shell
<h1>How to list directory size of all child directories?</h1> <p>From the shell, I need to list the size of all child directories. I am currently using:</p> <pre><code>du -hs * | sort -hr </code></pre> <p>However, this only gets one level down and does not traverse the directory tree.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,897
bash
# How to list directory size of all child directories? From the shell, I need to list the size of all child directories. I am currently using: ``` du -hs * | sort -hr ``` However, this only gets one level down and does not traverse the directory tree.
The simplest is: ``` du -h --max-depth=1 parent ``` This will show all sizes of the children of `parent` If you also want the grandchildren, you can do ``` du -h --max-depth=2 parent ``` If you want the whole family ``` du -h parent ``` All these will just summarize the total directory size of each subdirectory u...
51622424
PowerShell: invoke-sqlcmd with Get-Credential doesn't work
9
2018-07-31 21:34:03
<p>I've never seen a so easy script failing so royally:</p> <pre><code>$SQLServer = "localhost" $cred = Get-Credential invoke-sqlcmd -ServerInstance $SQLServer -Credential $cred -Query "select @@version" </code></pre> <p><a href="https://i.sstatic.net/6n4CI.png" rel="noreferrer"><img src="https://i.sstatic.net/6n4CI....
14,295
4,652,358
2018-07-31 23:33:58
51,623,386
16
2018-07-31 23:22:40
604,196
2018-07-31 23:33:58
https://stackoverflow.com/q/51622424
https://stackoverflow.com/a/51623386
<p>The issue could be resulting from the fact that Microsoft has two versions of <code>Invoke-Sqlcmd</code>:</p> <ol> <li><a href="https://learn.microsoft.com/en-us/sql/database-engine/invoke-sqlcmd-cmdlet" rel="noreferrer">The Database Engine</a> - <strong>no</strong> <code>-Credentials</code> parameter.</li> <li><a ...
<p>The issue could be resulting from the fact that Microsoft has two versions of <code>Invoke-Sqlcmd</code>:</p> <ol> <li><a href="https://learn.microsoft.com/en-us/sql/database-engine/invoke-sqlcmd-cmdlet" rel="noreferrer">The Database Engine</a> - <strong>no</strong> <code>-Credentials</code> parameter.</li> <li><a ...
72, 526, 115585
invoke-sqlcmd, powershell, sql-server
<h1>PowerShell: invoke-sqlcmd with Get-Credential doesn't work</h1> <p>I've never seen a so easy script failing so royally:</p> <pre><code>$SQLServer = "localhost" $cred = Get-Credential invoke-sqlcmd -ServerInstance $SQLServer -Credential $cred -Query "select @@version" </code></pre> <p><a href="https://i.sstatic.ne...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,898
bash
# PowerShell: invoke-sqlcmd with Get-Credential doesn't work I've never seen a so easy script failing so royally: ``` $SQLServer = "localhost" $cred = Get-Credential invoke-sqlcmd -ServerInstance $SQLServer -Credential $cred -Query "select @@version" ``` [![enter image description here](https://i.sstatic.net/6n4CI.p...
The issue could be resulting from the fact that Microsoft has two versions of `Invoke-Sqlcmd`: 1. [The Database Engine](https://learn.microsoft.com/en-us/sql/database-engine/invoke-sqlcmd-cmdlet) - **no** `-Credentials` parameter. 2. [The SqlServer module](https://learn.microsoft.com/en-us/powershell/module/sqlserver/...
51471554
Align columns in comma-separated file
9
2018-07-23 04:25:35
<p>I am writing the script in linux and the result of the script is a csv file. I want to format this file. My output file is:</p> <pre><code>"T_Hours","T_Count","T_Hours","P_Avg_5","Diffrence_Between_P_Avg_5_and_T_Count" "00","446","00","533","87" "01","159","01","224","65" "02","95","02","140","45" "03","84","03","1...
8,447
9,920,688
2019-05-15 15:05:30
51,471,616
16
2018-07-23 04:33:17
3,787,051
2019-05-15 15:05:30
https://stackoverflow.com/q/51471554
https://stackoverflow.com/a/51471616
<p>Here's a portable way:</p> <pre><code>sed 's/,/:,/g' output.csv | column -t -s: | sed 's/ ,/,/g' </code></pre> <p><strong>Explanation:</strong></p> <p><code>column -t</code> aligns columns. The input separator can be specified with <code>-s</code> but the output separator is always a space (unless you have versio...
<p>Here's a portable way:</p> <pre><code>sed 's/,/:,/g' output.csv | column -t -s: | sed 's/ ,/,/g' </code></pre> <p><strong>Explanation:</strong></p> <p><code>column -t</code> aligns columns. The input separator can be specified with <code>-s</code> but the output separator is always a space (unless you have versio...
387, 5282
bash, sed
<h1>Align columns in comma-separated file</h1> <p>I am writing the script in linux and the result of the script is a csv file. I want to format this file. My output file is:</p> <pre><code>"T_Hours","T_Count","T_Hours","P_Avg_5","Diffrence_Between_P_Avg_5_and_T_Count" "00","446","00","533","87" "01","159","01","224","...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,899
bash
# Align columns in comma-separated file I am writing the script in linux and the result of the script is a csv file. I want to format this file. My output file is: ``` "T_Hours","T_Count","T_Hours","P_Avg_5","Diffrence_Between_P_Avg_5_and_T_Count" "00","446","00","533","87" "01","159","01","224","65" "02","95","02","...
Here's a portable way: ``` sed 's/,/:,/g' output.csv | column -t -s: | sed 's/ ,/,/g' ``` **Explanation:** `column -t` aligns columns. The input separator can be specified with `-s` but the output separator is always a space (unless you have version like *GNU* or *util-linux* supporting the `-o` flag, see [this answ...
43941322
dyld_insert_libraries ignored when calling application through bash
9
2017-05-12 15:24:02
<p>For my application, I am using DYLD_INSERT_LIBRARIES to switch libraries. I am running Mac OS X, El Capitan.</p> <p>If I set these environment variables in my shell:</p> <pre><code>export PYTHONHOME=${HOME}/anaconda export DYLD_INSERT_LIBRARIES=${HOME}/anaconda/lib/libpython2.7.dylib:${HOME}/anaconda/lib/libmkl_r...
3,094
104,910
2018-01-27 18:16:24
48,478,771
16
2018-01-27 17:55:12
986,902
2018-01-27 18:16:24
https://stackoverflow.com/q/43941322
https://stackoverflow.com/a/48478771
<p>This is a security feature of recent macOS versions.</p> <p>The system <code>bash</code> executable has been marked as "restricted", disabling the DYLD_* features. To work around this, you can make a copy of <code>bash</code> and use that instead.</p> <p>By looking for the following details in the implementations ...
<p>This is a security feature of recent macOS versions.</p> <p>The system <code>bash</code> executable has been marked as "restricted", disabling the DYLD_* features. To work around this, you can make a copy of <code>bash</code> and use that instead.</p> <p>By looking for the following details in the implementations ...
369, 387, 8952
bash, macos, shared-libraries
<h1>dyld_insert_libraries ignored when calling application through bash</h1> <p>For my application, I am using DYLD_INSERT_LIBRARIES to switch libraries. I am running Mac OS X, El Capitan.</p> <p>If I set these environment variables in my shell:</p> <pre><code>export PYTHONHOME=${HOME}/anaconda export DYLD_INSERT_LI...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,900
bash
# dyld_insert_libraries ignored when calling application through bash For my application, I am using DYLD_INSERT_LIBRARIES to switch libraries. I am running Mac OS X, El Capitan. If I set these environment variables in my shell: ``` export PYTHONHOME=${HOME}/anaconda export DYLD_INSERT_LIBRARIES=${HOME}/anaconda/lib...
This is a security feature of recent macOS versions. The system `bash` executable has been marked as "restricted", disabling the DYLD_* features. To work around this, you can make a copy of `bash` and use that instead. By looking for the following details in the implementations of `dyld`, I see that this restriction ...
46081687
How to make "select" display the options in a single column?
9
2017-09-06 18:04:22
<p>I have a random situation, when I use multiple choice menu in bash and add more items to my list selection, the menu does no longer stack up line by line</p> <pre><code>echo " [?] What would you like to do:" echo # End opt="" select recon in Enumeration General Web-Recon Services Msfvenom Other do opt="$re...
4,692
7,778,016
2017-09-06 18:33:33
46,081,970
16
2017-09-06 18:24:12
3,776,858
2017-09-06 18:24:12
https://stackoverflow.com/q/46081687
https://stackoverflow.com/a/46081970
<p>Use <code>COLUMNS=0</code> before your <code>select</code> command.</p> <p>Tested with bash 4.2.8.</p>
<p>Use <code>COLUMNS=0</code> before your <code>select</code> command.</p> <p>Tested with bash 4.2.8.</p>
58, 387, 1151
bash, linux, select
<h1>How to make "select" display the options in a single column?</h1> <p>I have a random situation, when I use multiple choice menu in bash and add more items to my list selection, the menu does no longer stack up line by line</p> <pre><code>echo " [?] What would you like to do:" echo # End opt="" select reco...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,901
bash
# How to make "select" display the options in a single column? I have a random situation, when I use multiple choice menu in bash and add more items to my list selection, the menu does no longer stack up line by line ``` echo " [?] What would you like to do:" echo # End opt="" select recon in Enumeration Gen...
Use `COLUMNS=0` before your `select` command. Tested with bash 4.2.8.
43789845
How to detect if a Ruby script is running through a shell pipe?
9
2017-05-04 18:02:39
<p>My question is similar to this one: <a href="https://stackoverflow.com/questions/911168/how-to-detect-if-my-shell-script-is-running-through-a-pipe">How to detect if my shell script is running through a pipe?</a>. The difference is that the script I’m working on is written in Ruby.</p> <p>Let’s say I run:</p> <pre>...
1,422
1,141,709
2020-05-09 03:28:25
43,791,242
16
2017-05-04 19:24:47
1,143,549
2017-05-04 21:03:37
https://stackoverflow.com/q/43789845
https://stackoverflow.com/a/43791242
<p>Use <code>$stdout.isatty</code> or more idiomatically, <code>$stdout.tty?</code>. I created a little test.rb file to demonstrate, contents:</p> <pre><code>puts $stdout.isatty </code></pre> <p>Results:</p> <pre><code>$ ruby test.rb true $ ruby test.rb | cat false </code></pre> <p>Reference: <a href="https://ruby...
<p>Use <code>$stdout.isatty</code> or more idiomatically, <code>$stdout.tty?</code>. I created a little test.rb file to demonstrate, contents:</p> <pre><code>puts $stdout.isatty </code></pre> <p>Results:</p> <pre><code>$ ruby test.rb true $ ruby test.rb | cat false </code></pre> <p>Reference: <a href="https://ruby...
12, 390, 5813
pipe, ruby, shell
<h1>How to detect if a Ruby script is running through a shell pipe?</h1> <p>My question is similar to this one: <a href="https://stackoverflow.com/questions/911168/how-to-detect-if-my-shell-script-is-running-through-a-pipe">How to detect if my shell script is running through a pipe?</a>. The difference is that the scri...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,902
bash
# How to detect if a Ruby script is running through a shell pipe? My question is similar to this one: [How to detect if my shell script is running through a pipe?](https://stackoverflow.com/questions/911168/how-to-detect-if-my-shell-script-is-running-through-a-pipe). The difference is that the script I’m working on is...
Use `$stdout.isatty` or more idiomatically, `$stdout.tty?`. I created a little test.rb file to demonstrate, contents: ``` puts $stdout.isatty ``` Results: ``` $ ruby test.rb true $ ruby test.rb | cat false ``` Reference: <https://ruby-doc.org/core/IO.html#method-i-isatty>
41931855
Why env does not print PS1 variable?
9
2017-01-30 08:49:57
<p>When we print the value of <code>PS1</code>, it is set:</p> <pre><code>$ echo $PS1 [\u@\h \W]\$ </code></pre> <p>We can use <code>env</code> command to print environment variables. Why does it not list <code>PS1</code> variable ?</p> <pre><code>$ env | grep PS1 # No output here </code></pre>
4,208
1,119,997
2017-01-30 09:31:40
41,932,102
16
2017-01-30 09:05:55
null
2017-01-30 09:28:15
https://stackoverflow.com/q/41931855
https://stackoverflow.com/a/41932102
<p>Because PS1 is not (usually, and in your specific case) an environment variable.</p> <p>There are many variables set in a bash instance which you can list with:</p> <pre><code>$ set BASH=/bin/bash BASHOPTS=checkwinsize:cmdhist:… BASH_ALIASES=() BASH_ARGC=() . . SHLVL=1 SSH_AGENT_PID=853 SSH_AUTH_SOCK=/tmp/ssh-Ofup...
<p>Because PS1 is not (usually, and in your specific case) an environment variable.</p> <p>There are many variables set in a bash instance which you can list with:</p> <pre><code>$ set BASH=/bin/bash BASHOPTS=checkwinsize:cmdhist:… BASH_ALIASES=() BASH_ARGC=() . . SHLVL=1 SSH_AGENT_PID=853 SSH_AUTH_SOCK=/tmp/ssh-Ofup...
58, 387, 9013
bash, environment-variables, linux
<h1>Why env does not print PS1 variable?</h1> <p>When we print the value of <code>PS1</code>, it is set:</p> <pre><code>$ echo $PS1 [\u@\h \W]\$ </code></pre> <p>We can use <code>env</code> command to print environment variables. Why does it not list <code>PS1</code> variable ?</p> <pre><code>$ env | grep PS1 # No o...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,903
bash
# Why env does not print PS1 variable? When we print the value of `PS1`, it is set: ``` $ echo $PS1 [\u@\h \W]\$ ``` We can use `env` command to print environment variables. Why does it not list `PS1` variable ? ``` $ env | grep PS1 # No output here ```
Because PS1 is not (usually, and in your specific case) an environment variable. There are many variables set in a bash instance which you can list with: ``` $ set BASH=/bin/bash BASHOPTS=checkwinsize:cmdhist:… BASH_ALIASES=() BASH_ARGC=() . . SHLVL=1 SSH_AGENT_PID=853 SSH_AUTH_SOCK=/tmp/ssh-Ofupc03xWIs7/agent.795 TE...
40402048
Preserving hashtable order
9
2016-11-03 12:54:01
<p>Let's say I've this script :</p> <pre><code>$data= @{ A = 1 C = 2 B = 3 } foreach($key in $data.Keys){ $item = $data[$key] Write-Host "$($key) : $($item)" } </code></pre> <p>The output is:</p> <pre><code>C : 2 B : 3 A : 1 </code></pre> <p>As you can see, the output is in different order that...
3,845
588,868
2016-11-03 12:58:22
40,402,084
16
2016-11-03 12:56:31
1,324,345
2016-11-03 12:56:31
https://stackoverflow.com/q/40402048
https://stackoverflow.com/a/40402084
<p>Requires PowerShell 3, but you can use the <code>[ordered]</code> accelerator to keep things in order.</p> <pre><code>$data= [ordered]@{ A = 1 C = 2 B = 3 } </code></pre>
<p>Requires PowerShell 3, but you can use the <code>[ordered]</code> accelerator to keep things in order.</p> <pre><code>$data= [ordered]@{ A = 1 C = 2 B = 3 } </code></pre>
526
powershell
<h1>Preserving hashtable order</h1> <p>Let's say I've this script :</p> <pre><code>$data= @{ A = 1 C = 2 B = 3 } foreach($key in $data.Keys){ $item = $data[$key] Write-Host "$($key) : $($item)" } </code></pre> <p>The output is:</p> <pre><code>C : 2 B : 3 A : 1 </code></pre> <p>As you can see, t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,904
bash
# Preserving hashtable order Let's say I've this script : ``` $data= @{ A = 1 C = 2 B = 3 } foreach($key in $data.Keys){ $item = $data[$key] Write-Host "$($key) : $($item)" } ``` The output is: ``` C : 2 B : 3 A : 1 ``` As you can see, the output is in different order that the input. Is there...
Requires PowerShell 3, but you can use the `[ordered]` accelerator to keep things in order. ``` $data= [ordered]@{ A = 1 C = 2 B = 3 } ```
39215064
Insert into mysql from Bash script
9
2016-08-29 20:56:01
<p>Utilized a few posts here and Google and friends and I'm trying desperately to get something simple to work. I want to insert data into mysql via a bash script.</p> <pre><code>#!/bin/bash -x DB_USER='jhatter'; DB_PASSWD='XXXXXXX'; DB_NAME='ppr'; TABLE='graph'; #Collect Rank Information from flightaware.com day=$(...
57,371
6,771,850
2016-08-29 21:02:43
39,215,128
16
2016-08-29 21:00:27
641,955
2016-08-29 21:02:43
https://stackoverflow.com/q/39215064
https://stackoverflow.com/a/39215128
<p>You can pass the commands in a <em>here-document</em>, like this:</p> <pre><code>mysql --user=$DB_USER --password=$DB_PASSWD $DB_NAME &lt;&lt; EOF INSERT INTO $TABLE (\`id\`, \`day\`, \`time\`, \`rank\`) VALUES (NULL, "$day", "$time", "$rank"); EOF </code></pre> <p>Notice that the <code>`</code> need to be escaped...
<p>You can pass the commands in a <em>here-document</em>, like this:</p> <pre><code>mysql --user=$DB_USER --password=$DB_PASSWD $DB_NAME &lt;&lt; EOF INSERT INTO $TABLE (\`id\`, \`day\`, \`time\`, \`rank\`) VALUES (NULL, "$day", "$time", "$rank"); EOF </code></pre> <p>Notice that the <code>`</code> need to be escaped...
21, 387
bash, mysql
<h1>Insert into mysql from Bash script</h1> <p>Utilized a few posts here and Google and friends and I'm trying desperately to get something simple to work. I want to insert data into mysql via a bash script.</p> <pre><code>#!/bin/bash -x DB_USER='jhatter'; DB_PASSWD='XXXXXXX'; DB_NAME='ppr'; TABLE='graph'; #Collect ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,905
bash
# Insert into mysql from Bash script Utilized a few posts here and Google and friends and I'm trying desperately to get something simple to work. I want to insert data into mysql via a bash script. ``` #!/bin/bash -x DB_USER='jhatter'; DB_PASSWD='XXXXXXX'; DB_NAME='ppr'; TABLE='graph'; #Collect Rank Information fro...
You can pass the commands in a *here-document*, like this: ``` mysql --user=$DB_USER --password=$DB_PASSWD $DB_NAME << EOF INSERT INTO $TABLE (\`id\`, \`day\`, \`time\`, \`rank\`) VALUES (NULL, "$day", "$time", "$rank"); EOF ``` Notice that the `` ` `` need to be escaped. I also removed the `QUIT` command, as it's un...
36128042
Powershell error adding to an array
9
2016-03-21 10:06:53
<p>Hi I am trying to run a script to get users in a network into an array so that it can be outputted to a csv file along with other data that I am going to get, such as distribution groups. </p> <p>The code script I am running is giving an error: </p> <blockquote> <p>Method invocation failed because [System.Manage...
121,143
5,840,839
2025-12-02 10:29:56
36,128,262
16
2016-03-21 10:16:33
712,649
2025-12-02 10:29:56
https://stackoverflow.com/q/36128042
https://stackoverflow.com/a/36128262
<p>Don't reuse the same variable name for the array, and the individual objects that you want to add to the array. Here I've renamed the <code>PSObject</code> variable to <code>$ActiveDirectoryObject</code>:</p> <pre><code>$ActiveDirectoryList=@() $UserDetails = get-aduser -filter {enabled -eq $true} -properties * | S...
<p>Don't reuse the same variable name for the array, and the individual objects that you want to add to the array. Here I've renamed the <code>PSObject</code> variable to <code>$ActiveDirectoryObject</code>:</p> <pre><code>$ActiveDirectoryList=@() $UserDetails = get-aduser -filter {enabled -eq $true} -properties * | S...
526
powershell
<h1>Powershell error adding to an array</h1> <p>Hi I am trying to run a script to get users in a network into an array so that it can be outputted to a csv file along with other data that I am going to get, such as distribution groups. </p> <p>The code script I am running is giving an error: </p> <blockquote> <p>Me...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,906
bash
# Powershell error adding to an array Hi I am trying to run a script to get users in a network into an array so that it can be outputted to a csv file along with other data that I am going to get, such as distribution groups. The code script I am running is giving an error: > Method invocation failed because [System...
Don't reuse the same variable name for the array, and the individual objects that you want to add to the array. Here I've renamed the `PSObject` variable to `$ActiveDirectoryObject`: ``` $ActiveDirectoryList=@() $UserDetails = get-aduser -filter {enabled -eq $true} -properties * | Select DisplayName,EmailAddress, SAM...
34092367
Powershell script to count specific files in directories & subdirectories
9
2015-12-04 16:00:04
<p>I am trying to make a powershell script which will count all the .xml files in directories &amp; subdirectories and list the value + path.</p> <p>So far I have done the this:</p> <pre><code>Get-ChildItem -Path c:/test -recurse -include *.xml </code></pre> <p>Which is close to what I want but without the actual fi...
19,762
5,612,718
2015-12-09 14:40:14
34,092,507
16
2015-12-04 16:06:44
47,402
2015-12-09 14:40:14
https://stackoverflow.com/q/34092367
https://stackoverflow.com/a/34092507
<pre><code>Get-ChildItem -Path c:/test -recurse -filter *.xml | Group-Object -Property Directory </code></pre> <p>And to get a nicer table, you could add <code>-NoElement</code> to <code>Group-Object</code>.</p> <p>To exclude some directories, try:</p> <pre><code>$excludedPaths = @("Windows", "Program Files", "Progr...
<pre><code>Get-ChildItem -Path c:/test -recurse -filter *.xml | Group-Object -Property Directory </code></pre> <p>And to get a nicer table, you could add <code>-NoElement</code> to <code>Group-Object</code>.</p> <p>To exclude some directories, try:</p> <pre><code>$excludedPaths = @("Windows", "Program Files", "Progr...
526, 7989, 29006
count, get-childitem, powershell
<h1>Powershell script to count specific files in directories & subdirectories</h1> <p>I am trying to make a powershell script which will count all the .xml files in directories &amp; subdirectories and list the value + path.</p> <p>So far I have done the this:</p> <pre><code>Get-ChildItem -Path c:/test -recurse -incl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,907
bash
# Powershell script to count specific files in directories & subdirectories I am trying to make a powershell script which will count all the .xml files in directories & subdirectories and list the value + path. So far I have done the this: ``` Get-ChildItem -Path c:/test -recurse -include *.xml ``` Which is close t...
``` Get-ChildItem -Path c:/test -recurse -filter *.xml | Group-Object -Property Directory ``` And to get a nicer table, you could add `-NoElement` to `Group-Object`. To exclude some directories, try: ``` $excludedPaths = @("Windows", "Program Files", "Program Files (x86)"); $searchPaths = Get-ChildItem -Path C:\ -Di...
32341733
Does piping ls to head stop it's execution half way?
9
2015-09-01 22:16:44
<p>If I run <code>ls folder | head</code> in a directory with a lot of files, the execution time is about 50 times faster than <code>ls folder | tail</code>. Does the <code>head</code> command stops <code>ls</code> from executing wholy when it has enough (10) lines?</p> <p>I couldn't find the answer to this anywhere b...
1,492
5,290,212
2015-09-01 22:26:24
32,341,793
16
2015-09-01 22:21:47
5,233,270
2015-09-01 22:24:02
https://stackoverflow.com/q/32341733
https://stackoverflow.com/a/32341793
<p>Once <code>head</code> has read enough lines from it's <code>stdin</code> (<code>stdout</code> of <code>ls</code>), then it exits and therefore closes the <code>stdin</code>. When that happens, the pipe is considered to be broken and <code>ls</code> receives a <code>SIGPIPE</code> signal. As a reaction to that it te...
<p>Once <code>head</code> has read enough lines from it's <code>stdin</code> (<code>stdout</code> of <code>ls</code>), then it exits and therefore closes the <code>stdin</code>. When that happens, the pipe is considered to be broken and <code>ls</code> receives a <code>SIGPIPE</code> signal. As a reaction to that it te...
58, 387, 5813
bash, linux, pipe
<h1>Does piping ls to head stop it's execution half way?</h1> <p>If I run <code>ls folder | head</code> in a directory with a lot of files, the execution time is about 50 times faster than <code>ls folder | tail</code>. Does the <code>head</code> command stops <code>ls</code> from executing wholy when it has enough (10...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,908
bash
# Does piping ls to head stop it's execution half way? If I run `ls folder | head` in a directory with a lot of files, the execution time is about 50 times faster than `ls folder | tail`. Does the `head` command stops `ls` from executing wholy when it has enough (10) lines? I couldn't find the answer to this anywhere...
Once `head` has read enough lines from it's `stdin` (`stdout` of `ls`), then it exits and therefore closes the `stdin`. When that happens, the pipe is considered to be broken and `ls` receives a `SIGPIPE` signal. As a reaction to that it terminates as well, way before processing everything that it would normally do. In...
30033784
bash + sed: trim trailing zeroes off a floating point number?
9
2015-05-04 15:21:27
<p>I'm trying to get trim off trailing decimal zeroes off a floating point number, but no luck so far.</p> <pre><code>echo "3/2" | bc -l | sed s/0\{1,\}\$// 1.50000000000000000000 </code></pre> <p>I was hoping to get <code>1.5</code> but somehow the trailing zeroes are not truncated. If instead of <code>0\{1,\}</code...
8,092
3,914,111
2024-09-26 09:45:31
30,048,933
16
2015-05-05 09:20:46
2,885,763
2015-05-05 09:20:46
https://stackoverflow.com/q/30033784
https://stackoverflow.com/a/30048933
<pre><code>echo "3/2" | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//' </code></pre> <ul> <li>remove trailing 0 IF there is a decimal separator</li> <li>remove the separator if there are only 0 after separator also (assuming there is at least a digit before like BC does)</li> </ul>
<pre><code>echo "3/2" | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//' </code></pre> <ul> <li>remove trailing 0 IF there is a decimal separator</li> <li>remove the separator if there are only 0 after separator also (assuming there is at least a digit before like BC does)</li> </ul>
18, 305, 387, 5282
bash, floating-point, regex, sed
<h1>bash + sed: trim trailing zeroes off a floating point number?</h1> <p>I'm trying to get trim off trailing decimal zeroes off a floating point number, but no luck so far.</p> <pre><code>echo "3/2" | bc -l | sed s/0\{1,\}\$// 1.50000000000000000000 </code></pre> <p>I was hoping to get <code>1.5</code> but somehow t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,909
bash
# bash + sed: trim trailing zeroes off a floating point number? I'm trying to get trim off trailing decimal zeroes off a floating point number, but no luck so far. ``` echo "3/2" | bc -l | sed s/0\{1,\}\$// 1.50000000000000000000 ``` I was hoping to get `1.5` but somehow the trailing zeroes are not truncated. If ins...
``` echo "3/2" | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//' ``` - remove trailing 0 IF there is a decimal separator - remove the separator if there are only 0 after separator also (assuming there is at least a digit before like BC does)
23351432
Executing a Powershell Script in Fake
9
2014-04-28 21:23:47
<p>What is the best way to go about executing a Powershell script in the Fake build automation tool ?</p> <p>I feel that there should be an obvious answer to this question, but have not been able to find anything by searching.</p>
1,939
395,440
2014-04-29 09:29:43
23,360,748
16
2014-04-29 09:29:43
30,348
2014-04-29 09:29:43
https://stackoverflow.com/q/23351432
https://stackoverflow.com/a/23360748
<p>As you mention in your comment, using the <code>PowerShell</code> class makes this very easy.</p> <pre><code>#r "FakeLib.dll" #r "System.Management.Automation" open Fake open System.Management.Automation Target "RunSomePowerShell" &lt;| fun _ -&gt; PowerShell.Create() .AddScript("(Get-Process | ? Proces...
<p>As you mention in your comment, using the <code>PowerShell</code> class makes this very easy.</p> <pre><code>#r "FakeLib.dll" #r "System.Management.Automation" open Fake open System.Management.Automation Target "RunSomePowerShell" &lt;| fun _ -&gt; PowerShell.Create() .AddScript("(Get-Process | ? Proces...
526, 1198, 97260
f#, f#-fake, powershell
<h1>Executing a Powershell Script in Fake</h1> <p>What is the best way to go about executing a Powershell script in the Fake build automation tool ?</p> <p>I feel that there should be an obvious answer to this question, but have not been able to find anything by searching.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,910
bash
# Executing a Powershell Script in Fake What is the best way to go about executing a Powershell script in the Fake build automation tool ? I feel that there should be an obvious answer to this question, but have not been able to find anything by searching.
As you mention in your comment, using the `PowerShell` class makes this very easy. ``` #r "FakeLib.dll" #r "System.Management.Automation" open Fake open System.Management.Automation Target "RunSomePowerShell" <| fun _ -> PowerShell.Create() .AddScript("(Get-Process | ? ProcessName -eq 'chrome' | measure Wo...
22361722
Simplifying advanced Bash prompt variable (PS1) code
9
2014-03-12 19:20:12
<p>So I've found the following cool Bash prompt:</p> <p><img src="https://i.sstatic.net/7vdZq.jpg" alt="Bash prompt"></p> <p>..with the very basic logic of:</p> <pre><code>PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ $...
3,788
1,821,548
2014-03-12 20:15:43
22,362,727
16
2014-03-12 20:10:03
1,126,841
2014-03-12 20:15:43
https://stackoverflow.com/q/22361722
https://stackoverflow.com/a/22362727
<p>Use <code>PROMPT_COMMAND</code> to build the value up in a sane fashion. This saves a lot of quoting and makes the text much more readable. Note that you can use <code>\e</code> instead of <code>\033</code> to represent the escape character inside a prompt.</p> <pre><code>set_prompt () { local last_command=$? ...
<p>Use <code>PROMPT_COMMAND</code> to build the value up in a sane fashion. This saves a lot of quoting and makes the text much more readable. Note that you can use <code>\e</code> instead of <code>\033</code> to represent the escape character inside a prompt.</p> <pre><code>set_prompt () { local last_command=$? ...
387, 53034
bash, ps1
<h1>Simplifying advanced Bash prompt variable (PS1) code</h1> <p>So I've found the following cool Bash prompt:</p> <p><img src="https://i.sstatic.net/7vdZq.jpg" alt="Bash prompt"></p> <p>..with the very basic logic of:</p> <pre><code>PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\2...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,911
bash
# Simplifying advanced Bash prompt variable (PS1) code So I've found the following cool Bash prompt: ![Bash prompt](https://i.sstatic.net/7vdZq.jpg) ..with the very basic logic of: ``` PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\";...
Use `PROMPT_COMMAND` to build the value up in a sane fashion. This saves a lot of quoting and makes the text much more readable. Note that you can use `\e` instead of `\033` to represent the escape character inside a prompt. ``` set_prompt () { local last_command=$? # Must come first! PS1="" # Add a brigh...
21434064
How to become a Jenkins user?
9
2014-01-29 14:31:26
<p>I have installed Jenkins and during installation an user named <code>jenkins</code> has been created. I can see from the documentation:</p> <p><a href="https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu" rel="noreferrer">The 'jenkins' user is created to run this service.</a> </p> <p>Now I nee...
24,585
2,195,440
2018-08-14 04:50:41
21,435,987
16
2014-01-29 15:52:03
2,195,440
2014-01-29 16:21:03
https://stackoverflow.com/q/21434064
https://stackoverflow.com/a/21435987
<p>Basically for this Jenkins user <code>jenkins</code> bash was not configured.</p> <pre><code>jenkins:x:496:492:Jenkins Continuous Build server:/var/lib/jenkins:/bin/false </code></pre> <p>So we need to set the bash for this user and that resolved the issue. I used the following command:</p> <pre><code>sudo usermo...
<p>Basically for this Jenkins user <code>jenkins</code> bash was not configured.</p> <pre><code>jenkins:x:496:492:Jenkins Continuous Build server:/var/lib/jenkins:/bin/false </code></pre> <p>So we need to set the bash for this user and that resolved the issue. I used the following command:</p> <pre><code>sudo usermo...
387, 390, 1066, 48063, 64999
bash, continuous-deployment, continuous-integration, jenkins, shell
<h1>How to become a Jenkins user?</h1> <p>I have installed Jenkins and during installation an user named <code>jenkins</code> has been created. I can see from the documentation:</p> <p><a href="https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu" rel="noreferrer">The 'jenkins' user is created to r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,912
bash
# How to become a Jenkins user? I have installed Jenkins and during installation an user named `jenkins` has been created. I can see from the documentation: [The 'jenkins' user is created to run this service.](https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu) Now I need to become this `jenkin...
Basically for this Jenkins user `jenkins` bash was not configured. ``` jenkins:x:496:492:Jenkins Continuous Build server:/var/lib/jenkins:/bin/false ``` So we need to set the bash for this user and that resolved the issue. I used the following command: ``` sudo usermod -s /bin/bash jenkins ``` See below: ``` jenki...
19515962
telnet redis bash script
9
2013-10-22 10:58:11
<p>How can I extract the output from a telnet command on a remote redis-server in a bash script.</p> <p>I would do:</p> <pre><code>telnet remote-redis-ip 6379 LRANGE mylist 0 -1 </code></pre> <p>And save the result in a variable. How can I reach this goal under a bash script?</p> <p>Thanks,</p>
38,199
1,128,345
2013-10-22 14:30:57
19,520,520
16
2013-10-22 14:22:13
2,446,350
2013-10-22 14:30:57
https://stackoverflow.com/q/19515962
https://stackoverflow.com/a/19520520
<p>try this </p> <pre><code>RET=`telnet remote-redis-ip 6379 &lt;&lt; EOF LRANGE mylist 0 -1 EOF` echo $RET </code></pre> <p>and I think using expect <a href="https://stackoverflow.com/questions/7013137/automating-telnet-session-using-bash-scripts">automating telnet session using bash scripts</a> post by fedorqui wi...
<p>try this </p> <pre><code>RET=`telnet remote-redis-ip 6379 &lt;&lt; EOF LRANGE mylist 0 -1 EOF` echo $RET </code></pre> <p>and I think using expect <a href="https://stackoverflow.com/questions/7013137/automating-telnet-session-using-bash-scripts">automating telnet session using bash scripts</a> post by fedorqui wi...
387, 6056, 43464
bash, redis, telnet
<h1>telnet redis bash script</h1> <p>How can I extract the output from a telnet command on a remote redis-server in a bash script.</p> <p>I would do:</p> <pre><code>telnet remote-redis-ip 6379 LRANGE mylist 0 -1 </code></pre> <p>And save the result in a variable. How can I reach this goal under a bash script?</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,913
bash
# telnet redis bash script How can I extract the output from a telnet command on a remote redis-server in a bash script. I would do: ``` telnet remote-redis-ip 6379 LRANGE mylist 0 -1 ``` And save the result in a variable. How can I reach this goal under a bash script? Thanks,
try this ``` RET=`telnet remote-redis-ip 6379 << EOF LRANGE mylist 0 -1 EOF` echo $RET ``` and I think using expect [automating telnet session using bash scripts](https://stackoverflow.com/questions/7013137/automating-telnet-session-using-bash-scripts) post by fedorqui will be better
18061606
add string in each line at the begining of column
9
2013-08-05 15:11:48
<p>I am interested in adding a string <code>chr</code> to the beginning of column in each line.</p> <p>The file is tab delimited and looks something like:</p> <pre><code>re1 1 AGT re2 1 AGT re3 2 ACGTCA re12 3 ACGTACT </code></pre> <p>what I need is:</p> <pre><code>re1 chr1 AGT re2 chr1 AGT re3 chr2 ...
15,790
2,553,476
2023-06-29 12:59:16
18,061,775
16
2013-08-05 15:20:17
1,983,854
2013-08-05 15:20:17
https://stackoverflow.com/q/18061606
https://stackoverflow.com/a/18061775
<p>What about this?</p> <pre><code>$ awk '$2="chr"$2' file re1 chr1 AGT re2 chr1 AGT re3 chr2 ACGTCA re12 chr3 ACGTACT </code></pre> <h3>Explanation</h3> <p>With <code>$2="chr"$2</code> we add <code>chr</code> to the 2nd field. Then we do not need any other command to get the desired output, as the default behaviour...
<p>What about this?</p> <pre><code>$ awk '$2="chr"$2' file re1 chr1 AGT re2 chr1 AGT re3 chr2 ACGTCA re12 chr3 ACGTACT </code></pre> <h3>Explanation</h3> <p>With <code>$2="chr"$2</code> we add <code>chr</code> to the 2nd field. Then we do not need any other command to get the desired output, as the default behaviour...
139, 387, 990
awk, bash, string
<h1>add string in each line at the begining of column</h1> <p>I am interested in adding a string <code>chr</code> to the beginning of column in each line.</p> <p>The file is tab delimited and looks something like:</p> <pre><code>re1 1 AGT re2 1 AGT re3 2 ACGTCA re12 3 ACGTACT </code></pre> <p>what I need is:...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,914
bash
# add string in each line at the begining of column I am interested in adding a string `chr` to the beginning of column in each line. The file is tab delimited and looks something like: ``` re1 1 AGT re2 1 AGT re3 2 ACGTCA re12 3 ACGTACT ``` what I need is: ``` re1 chr1 AGT re2 chr1 AGT re3 chr2 ...
What about this? ``` $ awk '$2="chr"$2' file re1 chr1 AGT re2 chr1 AGT re3 chr2 ACGTCA re12 chr3 ACGTACT ``` ### Explanation With `$2="chr"$2` we add `chr` to the 2nd field. Then we do not need any other command to get the desired output, as the default behaviour of awk is `print $0`. To make sure the OFS (output f...
17530141
how to include a file containing variables in a shell script
9
2013-07-08 15:12:14
<p>i have many script shell and i want to include a file containing variables in this shell </p> <p>script?</p> <p>My var script:</p> <pre><code>################################################################################### ORACLE_LOGIN=login ORACLE_PWD=pwd CHEMIN_1="/home/" CHEMIN_2="/scripts/" LOG_FILE="$CHEM...
23,092
296,635
2021-12-08 18:39:13
17,530,211
16
2013-07-08 15:15:44
1,057,909
2013-07-08 15:15:44
https://stackoverflow.com/q/17530141
https://stackoverflow.com/a/17530211
<p>It depends which shell, but one of these two usually works:</p> <pre><code>. var </code></pre> <p>or</p> <pre><code>source var </code></pre> <p>I'm not sure about ksh, but I'd imagine both would work.</p>
<p>It depends which shell, but one of these two usually works:</p> <pre><code>. var </code></pre> <p>or</p> <pre><code>source var </code></pre> <p>I'm not sure about ksh, but I'd imagine both would work.</p>
58, 387, 10327
bash, linux, sh
<h1>how to include a file containing variables in a shell script</h1> <p>i have many script shell and i want to include a file containing variables in this shell </p> <p>script?</p> <p>My var script:</p> <pre><code>################################################################################### ORACLE_LOGIN=login...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,915
bash
# how to include a file containing variables in a shell script i have many script shell and i want to include a file containing variables in this shell script? My var script: ``` ################################################################################### ORACLE_LOGIN=login ORACLE_PWD=pwd CHEMIN_1="/home/" C...
It depends which shell, but one of these two usually works: ``` . var ``` or ``` source var ``` I'm not sure about ksh, but I'd imagine both would work.
16897659
show just one column in result?
9
2013-06-03 13:16:32
<p>Bit of a simple question but how do I select a specific column in the below code? </p> <p>I only want to show TIME column and nothing else. I try and put in FORMAT_TABLE TIME but it just populates with TIME multiple times without actually showing the time..</p> <pre><code>$server_event = Get-Content -Path "c:\Temp...
30,862
461,030
2013-06-03 13:31:36
16,897,769
16
2013-06-03 13:22:02
520,612
2013-06-03 13:22:02
https://stackoverflow.com/q/16897659
https://stackoverflow.com/a/16897769
<p>try:</p> <pre><code>$event = Get-EventLog -computerName $servers -logname system | Where-Object {$_.EventID -eq 6009} | Select TimeGenerated -First 1 </code></pre>
<p>try:</p> <pre><code>$event = Get-EventLog -computerName $servers -logname system | Where-Object {$_.EventID -eq 6009} | Select TimeGenerated -First 1 </code></pre>
526, 24067
powershell, powershell-2.0
<h1>show just one column in result?</h1> <p>Bit of a simple question but how do I select a specific column in the below code? </p> <p>I only want to show TIME column and nothing else. I try and put in FORMAT_TABLE TIME but it just populates with TIME multiple times without actually showing the time..</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
8,916
bash
# show just one column in result? Bit of a simple question but how do I select a specific column in the below code? I only want to show TIME column and nothing else. I try and put in FORMAT_TABLE TIME but it just populates with TIME multiple times without actually showing the time.. ``` $server_event = Get-Content -...
try: ``` $event = Get-EventLog -computerName $servers -logname system | Where-Object {$_.EventID -eq 6009} | Select TimeGenerated -First 1 ```
14553804
sed not replacing lines
9
2013-01-28 00:12:40
<p>I have a file with 1 line of text, called <code>output</code>. I have write access to the file. I can change it from an editor with no problems.</p> <pre><code>$ cat output 1 $ ls -l o* -rw-rw-r-- 1 jbk jbk 2 Jan 27 18:44 output </code></pre> <p>What I want to do is replace the first (and only) line in this file w...
20,148
2,015,873
2014-01-24 18:31:03
14,553,816
16
2013-01-28 00:13:58
778,118
2013-01-28 00:23:13
https://stackoverflow.com/q/14553804
https://stackoverflow.com/a/14553816
<p>Sed operates on streams and prints its output to standard out.</p> <p>It does not modify the input file.</p> <p>It's typically used like this when you want to capture its output in a file:</p> <pre><code># # replace every occurrence of foo with bar in input-file # sed 's/foo/bar/g' input-file &gt; output-file </c...
<p>Sed operates on streams and prints its output to standard out.</p> <p>It does not modify the input file.</p> <p>It's typically used like this when you want to capture its output in a file:</p> <pre><code># # replace every occurrence of foo with bar in input-file # sed 's/foo/bar/g' input-file &gt; output-file </c...
387, 2498, 5282
bash, replace, sed
<h1>sed not replacing lines</h1> <p>I have a file with 1 line of text, called <code>output</code>. I have write access to the file. I can change it from an editor with no problems.</p> <pre><code>$ cat output 1 $ ls -l o* -rw-rw-r-- 1 jbk jbk 2 Jan 27 18:44 output </code></pre> <p>What I want to do is replace the fir...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,917
bash
# sed not replacing lines I have a file with 1 line of text, called `output`. I have write access to the file. I can change it from an editor with no problems. ``` $ cat output 1 $ ls -l o* -rw-rw-r-- 1 jbk jbk 2 Jan 27 18:44 output ``` What I want to do is replace the first (and only) line in this file with a new v...
Sed operates on streams and prints its output to standard out. It does not modify the input file. It's typically used like this when you want to capture its output in a file: ``` # # replace every occurrence of foo with bar in input-file # sed 's/foo/bar/g' input-file > output-file ``` The above command invokes `se...
14234907
Replacing values in large table using conversion table
9
2013-01-09 12:09:46
<p>I am trying to replace values in a large space-delimited text-file and could not find a suitable answer for this specific problem:</p> <p>Say I have a file "OLD_FILE", containing a header and approximately 2 million rows:</p> <pre><code>COL1 COL2 COL3 COL4 COL5 rs10 7 92221824 C A rs1000000 12 125456933 G A rs10...
2,793
1,961,199
2017-09-22 05:51:54
14,235,083
16
2013-01-09 12:20:59
751,863
2013-01-10 00:34:47
https://stackoverflow.com/q/14234907
https://stackoverflow.com/a/14235083
<p>Here's one way using <code>awk</code>:</p> <pre><code>awk 'NR==1 { next } FNR==NR { a[$1]=$2; next } $1 in a { $1=a[$1] }1' TABLE OLD_FILE </code></pre> <p>Results:</p> <pre><code>COL1 COL2 COL3 COL4 COL5 7_92383888 7 92221824 C A 12_126890980 12 125456933 G A 4_21618674 4 21227772 T C 4_1357325 4 1347325 G C 4_3...
<p>Here's one way using <code>awk</code>:</p> <pre><code>awk 'NR==1 { next } FNR==NR { a[$1]=$2; next } $1 in a { $1=a[$1] }1' TABLE OLD_FILE </code></pre> <p>Results:</p> <pre><code>COL1 COL2 COL3 COL4 COL5 7_92383888 7 92221824 C A 12_126890980 12 125456933 G A 4_21618674 4 21227772 T C 4_1357325 4 1347325 G C 4_3...
34, 387, 990, 5282, 26600
awk, bash, large-data, sed, unix
<h1>Replacing values in large table using conversion table</h1> <p>I am trying to replace values in a large space-delimited text-file and could not find a suitable answer for this specific problem:</p> <p>Say I have a file "OLD_FILE", containing a header and approximately 2 million rows:</p> <pre><code>COL1 COL2 COL3...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,918
bash
# Replacing values in large table using conversion table I am trying to replace values in a large space-delimited text-file and could not find a suitable answer for this specific problem: Say I have a file "OLD_FILE", containing a header and approximately 2 million rows: ``` COL1 COL2 COL3 COL4 COL5 rs10 7 92221824 ...
Here's one way using `awk`: ``` awk 'NR==1 { next } FNR==NR { a[$1]=$2; next } $1 in a { $1=a[$1] }1' TABLE OLD_FILE ``` Results: ``` COL1 COL2 COL3 COL4 COL5 7_92383888 7 92221824 C A 12_126890980 12 125456933 G A 4_21618674 4 21227772 T C 4_1357325 4 1347325 G C 4_37225069 4 36901464 C A 4_84778125 4 84997149 T C ...
13546672
Custom Oh My Zsh theme: long prompts disappear / cut off
9
2012-11-24 23:21:11
<p>I had a go at making my own Oh My Zsh theme earlier. All is well, except when I type long lines in the prompt (any longer than the line seen below), the line disappears. The line re-appears if I resize the window, however.</p> <p>Is there something in my theme that is causing this to happen?</p> <p><img src="https...
5,862
null
2018-10-07 02:06:50
14,179,542
16
2013-01-06 05:16:19
1,084,945
2013-01-06 05:16:19
https://stackoverflow.com/q/13546672
https://stackoverflow.com/a/14179542
<p>Incidentally, your link is broken, highlighting one of the issues with posting a link to code instead of code itself - any future viewers of your question can't get a full picture. </p> <p>I think your problem is that the 'color' characters you use should be escaped in a pair of <a href="http://www.manpagez.com/man...
<p>Incidentally, your link is broken, highlighting one of the issues with posting a link to code instead of code itself - any future viewers of your question can't get a full picture. </p> <p>I think your problem is that the 'color' characters you use should be escaped in a pair of <a href="http://www.manpagez.com/man...
390, 1669, 3791, 5003
prompt, shell, themes, zsh
<h1>Custom Oh My Zsh theme: long prompts disappear / cut off</h1> <p>I had a go at making my own Oh My Zsh theme earlier. All is well, except when I type long lines in the prompt (any longer than the line seen below), the line disappears. The line re-appears if I resize the window, however.</p> <p>Is there something i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,919
bash
# Custom Oh My Zsh theme: long prompts disappear / cut off I had a go at making my own Oh My Zsh theme earlier. All is well, except when I type long lines in the prompt (any longer than the line seen below), the line disappears. The line re-appears if I resize the window, however. Is there something in my theme that ...
Incidentally, your link is broken, highlighting one of the issues with posting a link to code instead of code itself - any future viewers of your question can't get a full picture. I think your problem is that the 'color' characters you use should be escaped in a pair of [`%{...%}`](http://www.manpagez.com/man/1/zshmi...
12420524
why find need "{} \"?
9
2012-09-14 08:13:27
<p>I use command of find, for example: </p> <pre><code>find . -name "*.log" -exec grep "running" {} \; </code></pre> <p>why the command of find need <code>{}</code> , a blank and <code>\</code>?</p>
2,729
689,464
2012-09-14 08:56:37
12,420,573
16
2012-09-14 08:17:36
429,322
2012-09-14 08:17:36
https://stackoverflow.com/q/12420524
https://stackoverflow.com/a/12420573
<p>This is because of the <code>-exec</code> parameter: the <code>{}</code> is a placeholder for the file that will be passed to the command.</p> <p>the semicolon (<code>;</code>) tells <code>find</code> that the <code>-exec</code> argument list is over, but since <code>;</code> is also a shell operator, you need to e...
<p>This is because of the <code>-exec</code> parameter: the <code>{}</code> is a placeholder for the file that will be passed to the command.</p> <p>the semicolon (<code>;</code>) tells <code>find</code> that the <code>-exec</code> argument list is over, but since <code>;</code> is also a shell operator, you need to e...
58, 387
bash, linux
<h1>why find need "{} \"?</h1> <p>I use command of find, for example: </p> <pre><code>find . -name "*.log" -exec grep "running" {} \; </code></pre> <p>why the command of find need <code>{}</code> , a blank and <code>\</code>?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,920
bash
# why find need "{} \"? I use command of find, for example: ``` find . -name "*.log" -exec grep "running" {} \; ``` why the command of find need `{}` , a blank and `\`?
This is because of the `-exec` parameter: the `{}` is a placeholder for the file that will be passed to the command. the semicolon (`;`) tells `find` that the `-exec` argument list is over, but since `;` is also a shell operator, you need to escape it so that it reaches `find`: `\;` `-exec` works like this: for every...
10671667
How do I run MinGW with a script?
9
2012-05-20 07:42:54
<p>Is there a way to run MinGW, from msys.bat or any other method, from a batch file and input a <code>.sh</code> file for it to run?</p>
13,947
451,860
2017-01-06 22:31:30
11,910,944
16
2012-08-11 00:50:00
1,002,260
2012-08-11 00:50:00
https://stackoverflow.com/q/10671667
https://stackoverflow.com/a/11910944
<p>Batch file like this</p> <pre><code>C:\MinGW\msys\1.0\bin\sh ~/test.sh pause </code></pre>
<p>Batch file like this</p> <pre><code>C:\MinGW\msys\1.0\bin\sh ~/test.sh pause </code></pre>
387, 4086, 7002
bash, batch-file, mingw
<h1>How do I run MinGW with a script?</h1> <p>Is there a way to run MinGW, from msys.bat or any other method, from a batch file and input a <code>.sh</code> file for it to run?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,921
bash
# How do I run MinGW with a script? Is there a way to run MinGW, from msys.bat or any other method, from a batch file and input a `.sh` file for it to run?
Batch file like this ``` C:\MinGW\msys\1.0\bin\sh ~/test.sh pause ```
10140213
bash substitute first character in every line
9
2012-04-13 11:47:32
<p>My file looks like this:</p> <pre><code> 1 chrX_73833098_73834098 1 chrX_73889652_73890652 1 chrX_91194501_91195501 1 chrX_92000157_92001157 1 chrX_92106500_92107500 </code></pre> <p>I want to replace first character "1" into 0. Wanted output is :</p> <pre><code> 0 chrX_73833098_73834098 0 chrX_738896...
49,161
1,286,528
2017-07-04 06:50:26
10,140,263
16
2012-04-13 11:50:58
1,277,417
2012-04-13 11:56:38
https://stackoverflow.com/q/10140213
https://stackoverflow.com/a/10140263
<p>There is whitespace character at the begging of each line.</p> <p>you can try:</p> <pre><code>sed 's/^\s*./0/g' file </code></pre> <p>\s - match white space characters</p> <p>output:</p> <pre><code>0 chrX_73833098_73834098 0 chrX_73889652_73890652 0 chrX_91194501_91195501 0 chrX_92000157_92001157 0 chrX_921065...
<p>There is whitespace character at the begging of each line.</p> <p>you can try:</p> <pre><code>sed 's/^\s*./0/g' file </code></pre> <p>\s - match white space characters</p> <p>output:</p> <pre><code>0 chrX_73833098_73834098 0 chrX_73889652_73890652 0 chrX_91194501_91195501 0 chrX_92000157_92001157 0 chrX_921065...
387, 5282
bash, sed
<h1>bash substitute first character in every line</h1> <p>My file looks like this:</p> <pre><code> 1 chrX_73833098_73834098 1 chrX_73889652_73890652 1 chrX_91194501_91195501 1 chrX_92000157_92001157 1 chrX_92106500_92107500 </code></pre> <p>I want to replace first character "1" into 0. Wanted output is :</p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,922
bash
# bash substitute first character in every line My file looks like this: ``` 1 chrX_73833098_73834098 1 chrX_73889652_73890652 1 chrX_91194501_91195501 1 chrX_92000157_92001157 1 chrX_92106500_92107500 ``` I want to replace first character "1" into 0. Wanted output is : ``` 0 chrX_73833098_73834098 0 ...
There is whitespace character at the begging of each line. you can try: ``` sed 's/^\s*./0/g' file ``` \s - match white space characters output: ``` 0 chrX_73833098_73834098 0 chrX_73889652_73890652 0 chrX_91194501_91195501 0 chrX_92000157_92001157 0 chrX_92106500_92107500 ``` if you want to preserve whitespace c...
10006449
Changing the first letter of every line in a file to uppercase
9
2012-04-04 07:09:09
<p>I need to change the first letter of every line in a file to uppercase, e.g.</p> <pre><code>the bear ate the fish. the river was too fast. </code></pre> <p>Would become:</p> <pre><code>The bear ate the fish. The river was too fast. </code></pre> <ul> <li>The document contains some special letters: a, a, á, à, ǎ,...
12,299
834,616
2017-09-13 12:13:30
10,006,514
16
2012-04-04 07:14:12
1,076,171
2012-04-04 07:27:22
https://stackoverflow.com/q/10006449
https://stackoverflow.com/a/10006514
<p>Use <code>sed</code>:</p> <pre><code>sed 's/^\(.\)/\U\1/' yourfile &gt; convertedfile </code></pre> <p>Little explanation:</p> <ul> <li>the <code>^</code> represents the start of a line.</li> <li><code>.</code> matches any character</li> <li><code>\U</code> converts to uppercase</li> <li><code>\( ... \)</code> s...
<p>Use <code>sed</code>:</p> <pre><code>sed 's/^\(.\)/\U\1/' yourfile &gt; convertedfile </code></pre> <p>Little explanation:</p> <ul> <li>the <code>^</code> represents the start of a line.</li> <li><code>.</code> matches any character</li> <li><code>\U</code> converts to uppercase</li> <li><code>\( ... \)</code> s...
387, 6107, 14966
bash, case, unicode-string
<h1>Changing the first letter of every line in a file to uppercase</h1> <p>I need to change the first letter of every line in a file to uppercase, e.g.</p> <pre><code>the bear ate the fish. the river was too fast. </code></pre> <p>Would become:</p> <pre><code>The bear ate the fish. The river was too fast. </code></p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,923
bash
# Changing the first letter of every line in a file to uppercase I need to change the first letter of every line in a file to uppercase, e.g. ``` the bear ate the fish. the river was too fast. ``` Would become: ``` The bear ate the fish. The river was too fast. ``` - The document contains some special letters: a, ...
Use `sed`: ``` sed 's/^\(.\)/\U\1/' yourfile > convertedfile ``` Little explanation: - the `^` represents the start of a line. - `.` matches any character - `\U` converts to uppercase - `\( ... \)` specifies a section to be referenced later (as `\1` in this case); parentheses are to be escaped here. Do **not** try...
9259166
How to force wget to skip links leading to parent elements?
9
2012-02-13 10:49:16
<p>Let's say I've got:</p> <pre><code>http://svnserver/repoid/appname/language/module/ </code></pre> <p>I'm trying to download everything below <strong>module</strong> node, unfortunately page contains links to both - items below and items above in hierarchy (much like bash <code>ls -ltr</code> output). So when I use...
5,426
571,293
2014-09-03 14:36:07
9,259,224
16
2012-02-13 10:53:25
null
2012-02-13 10:53:25
https://stackoverflow.com/q/9259166
https://stackoverflow.com/a/9259224
<p>Sounds like you are looking for the <code>--no-parent</code> parameter. </p> <p>From the output of <code>wget --help</code> </p> <pre><code> -np, --no-parent don't ascend to the parent directory. </code></pre>
<p>Sounds like you are looking for the <code>--no-parent</code> parameter. </p> <p>From the output of <code>wget --help</code> </p> <pre><code> -np, --no-parent don't ascend to the parent directory. </code></pre>
387, 5583
bash, wget
<h1>How to force wget to skip links leading to parent elements?</h1> <p>Let's say I've got:</p> <pre><code>http://svnserver/repoid/appname/language/module/ </code></pre> <p>I'm trying to download everything below <strong>module</strong> node, unfortunately page contains links to both - items below and items above in ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,924
bash
# How to force wget to skip links leading to parent elements? Let's say I've got: ``` http://svnserver/repoid/appname/language/module/ ``` I'm trying to download everything below **module** node, unfortunately page contains links to both - items below and items above in hierarchy (much like bash `ls -ltr` output). S...
Sounds like you are looking for the `--no-parent` parameter. From the output of `wget --help` ``` -np, --no-parent don't ascend to the parent directory. ```
8519219
xargs and find, rm complaining about \n (newline) in filename
9
2011-12-15 11:17:39
<p>I am trying to delete the oldest file in a tree with a script in Debian.</p> <pre><code>find /home/backups -type f \( -name \*.tgz -o -name \*.gz \) -print0 | xargs -0 ls -t | tail -1 | xargs -0 rm </code></pre> <p>But I am getting an error:</p> <pre><code>rm: cannot remove `/home/backups/tree/structure/file.2011...
15,865
1,076,412
2012-10-05 12:20:54
8,519,277
16
2011-12-15 11:21:51
648,658
2012-05-22 06:25:03
https://stackoverflow.com/q/8519219
https://stackoverflow.com/a/8519277
<p>The <code>ls</code> appends a newline and the last xargs -0 says the newline is part of the file name. Run the last xargs with <code>-d '\n'</code> instead of <code>-0</code>.</p> <p>BTW, due to the way xargs works, your whole pipe is a bug waiting to happen. Consider a really long file name list produced by the <c...
<p>The <code>ls</code> appends a newline and the last xargs -0 says the newline is part of the file name. Run the last xargs with <code>-d '\n'</code> instead of <code>-0</code>.</p> <p>BTW, due to the way xargs works, your whole pipe is a bug waiting to happen. Consider a really long file name list produced by the <c...
58, 387, 10326
bash, linux, xargs
<h1>xargs and find, rm complaining about \n (newline) in filename </h1> <p>I am trying to delete the oldest file in a tree with a script in Debian.</p> <pre><code>find /home/backups -type f \( -name \*.tgz -o -name \*.gz \) -print0 | xargs -0 ls -t | tail -1 | xargs -0 rm </code></pre> <p>But I am getting an error:</...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,925
bash
# xargs and find, rm complaining about \n (newline) in filename I am trying to delete the oldest file in a tree with a script in Debian. ``` find /home/backups -type f \( -name \*.tgz -o -name \*.gz \) -print0 | xargs -0 ls -t | tail -1 | xargs -0 rm ``` But I am getting an error: ``` rm: cannot remove `/home/backu...
The `ls` appends a newline and the last xargs -0 says the newline is part of the file name. Run the last xargs with `-d '\n'` instead of `-0`. BTW, due to the way xargs works, your whole pipe is a bug waiting to happen. Consider a really long file name list produced by the `find`, so that the `xargs -0 ls` runs `ls` m...
8516823
redirecting output to a file in C
9
2011-12-15 07:57:05
<p>i coded a basic shell in C for executing basic commands it'll execute commands <code>ls</code>, <code>ls -al</code> , <code>ls -al | more</code> etc.</p> <p>i want to execute following command in my shell. like ;</p> <pre><code>ls -al &gt; a.txt </code></pre> <p>this will give me <code>a.txt</code> file which con...
56,124
1,099,365
2012-06-11 06:28:18
8,517,401
16
2011-12-15 08:52:56
85,371
2011-12-15 08:52:56
https://stackoverflow.com/q/8516823
https://stackoverflow.com/a/8517401
<p>This is the result of my testing things out with dup2</p> <p>The more subtle point is remembering fflush at the right times :) Otherwise, you'll get very surprising results.</p> <p>Also, prefer <code>fileno</code> instead of hardcoding <code>1</code> (stdout) <code>2</code> (stderr).</p> <p>Redirecting <code>stdi...
<p>This is the result of my testing things out with dup2</p> <p>The more subtle point is remembering fflush at the right times :) Otherwise, you'll get very surprising results.</p> <p>Also, prefer <code>fileno</code> instead of hardcoding <code>1</code> (stdout) <code>2</code> (stderr).</p> <p>Redirecting <code>stdi...
58, 390
linux, shell
<h1>redirecting output to a file in C</h1> <p>i coded a basic shell in C for executing basic commands it'll execute commands <code>ls</code>, <code>ls -al</code> , <code>ls -al | more</code> etc.</p> <p>i want to execute following command in my shell. like ;</p> <pre><code>ls -al &gt; a.txt </code></pre> <p>this wil...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,926
bash
# redirecting output to a file in C i coded a basic shell in C for executing basic commands it'll execute commands `ls`, `ls -al` , `ls -al | more` etc. i want to execute following command in my shell. like ; ``` ls -al > a.txt ``` this will give me `a.txt` file which contain output of `ls -al` process. i found a o...
This is the result of my testing things out with dup2 The more subtle point is remembering fflush at the right times :) Otherwise, you'll get very surprising results. Also, prefer `fileno` instead of hardcoding `1` (stdout) `2` (stderr). Redirecting `stdin` was left as an exercise for the reader ``` #include <stdio...
8287453
How do I write this in Powershell script?
9
2011-11-27 17:26:24
<p>I am very new to Powershell script.</p> <p>I am trying to run a powershell script from a cmd</p> <pre><code>powershell.exe Set-ExecutionPolicy Unrestricted powershell.exe .\startup.ps1 </code></pre> <p>I need two lines within powershell script.</p> <pre><code>%WINDIR%\system32\inetsrv\appcmd.exe add apppool /nam...
10,362
92,153
2011-11-27 20:02:51
8,288,516
16
2011-11-27 19:52:38
73,070
2011-11-27 19:52:38
https://stackoverflow.com/q/8287453
https://stackoverflow.com/a/8288516
<p><strong>Short answer, including a question:</strong> Why the hell does that need to be a PowerShell script?</p> <p>You can simply create a batch file containing</p> <pre><code>%WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated" %WINDIR%\sy...
<p><strong>Short answer, including a question:</strong> Why the hell does that need to be a PowerShell script?</p> <p>You can simply create a batch file containing</p> <pre><code>%WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated" %WINDIR%\sy...
526
powershell
<h1>How do I write this in Powershell script?</h1> <p>I am very new to Powershell script.</p> <p>I am trying to run a powershell script from a cmd</p> <pre><code>powershell.exe Set-ExecutionPolicy Unrestricted powershell.exe .\startup.ps1 </code></pre> <p>I need two lines within powershell script.</p> <pre><code>%W...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,927
bash
# How do I write this in Powershell script? I am very new to Powershell script. I am trying to run a powershell script from a cmd ``` powershell.exe Set-ExecutionPolicy Unrestricted powershell.exe .\startup.ps1 ``` I need two lines within powershell script. ``` %WINDIR%\system32\inetsrv\appcmd.exe add apppool /nam...
**Short answer, including a question:** Why the hell does that need to be a PowerShell script? You can simply create a batch file containing ``` %WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated" %WINDIR%\system32\inetsrv\appcmd.exe set app ...
6911520
"Read" command in bash script is being skipped
9
2011-08-02 11:47:09
<p>I'm creating a script to update my linux distribution if I need to wipe the HD or I need to install Linux on another machine. So this script basically install all the programs I usually need. At the beginning a have a "read" command that asks if I want to install all the packages automatically or not. If I choose no...
9,781
null
2017-07-06 19:53:44
6,924,649
16
2011-08-03 09:55:47
855,954
2011-08-03 09:55:47
https://stackoverflow.com/q/6911520
https://stackoverflow.com/a/6924649
<p>The relevant portions of the code are still not complete but based on the comments I'm going to guess that your while loop looks like</p> <pre><code>while read -r ... ; do # do stuff ... # read user input read -r var done &lt; file </code></pre> <p>From this the problem is immediately apparent: the ...
<p>The relevant portions of the code are still not complete but based on the comments I'm going to guess that your while loop looks like</p> <pre><code>while read -r ... ; do # do stuff ... # read user input read -r var done &lt; file </code></pre> <p>From this the problem is immediately apparent: the ...
387, 3222
bash, user-input
<h1>"Read" command in bash script is being skipped</h1> <p>I'm creating a script to update my linux distribution if I need to wipe the HD or I need to install Linux on another machine. So this script basically install all the programs I usually need. At the beginning a have a "read" command that asks if I want to insta...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,928
bash
# "Read" command in bash script is being skipped I'm creating a script to update my linux distribution if I need to wipe the HD or I need to install Linux on another machine. So this script basically install all the programs I usually need. At the beginning a have a "read" command that asks if I want to install all th...
The relevant portions of the code are still not complete but based on the comments I'm going to guess that your while loop looks like ``` while read -r ... ; do # do stuff ... # read user input read -r var done < file ``` From this the problem is immediately apparent: the inner `read` is getting its in...
6461769
Enable / disable wifi via bash scripting on Android
9
2011-06-23 23:23:26
<p>I am trying to enable / disable the wifi device in my android device in a bash script. I am using the terminal emulator and the program Script Manager to execute bash scripts on the phone (which is a rooted Nexus One). The normal way to do this in linux would be something like</p> <pre><code>ifconfig eth0 up </cod...
34,693
813,234
2016-07-03 04:23:27
6,463,098
16
2011-06-24 03:43:23
236,465
2011-06-25 04:47:18
https://stackoverflow.com/q/6461769
https://stackoverflow.com/a/6463098
<p>While it doesn't work in my non-rooted phone for obvious reasons, the results I'm obtaining are completely different while wifi is connected:</p> <pre><code>$ ifconfig eth0 eth0: ip 192.168.0.102 mask 255.255.255.0 flags [up broadcast running multicast] $ ifconfig eth0 up error: SIOCSIFFLAGS (Permission denied) </c...
<p>While it doesn't work in my non-rooted phone for obvious reasons, the results I'm obtaining are completely different while wifi is connected:</p> <pre><code>$ ifconfig eth0 eth0: ip 192.168.0.102 mask 255.255.255.0 flags [up broadcast running multicast] $ ifconfig eth0 up error: SIOCSIFFLAGS (Permission denied) </c...
387, 531, 1386, 35600
android, bash, scripting, wifi
<h1>Enable / disable wifi via bash scripting on Android</h1> <p>I am trying to enable / disable the wifi device in my android device in a bash script. I am using the terminal emulator and the program Script Manager to execute bash scripts on the phone (which is a rooted Nexus One). The normal way to do this in linux wo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,929
bash
# Enable / disable wifi via bash scripting on Android I am trying to enable / disable the wifi device in my android device in a bash script. I am using the terminal emulator and the program Script Manager to execute bash scripts on the phone (which is a rooted Nexus One). The normal way to do this in linux would be so...
While it doesn't work in my non-rooted phone for obvious reasons, the results I'm obtaining are completely different while wifi is connected: ``` $ ifconfig eth0 eth0: ip 192.168.0.102 mask 255.255.255.0 flags [up broadcast running multicast] $ ifconfig eth0 up error: SIOCSIFFLAGS (Permission denied) ``` If you just ...
2630812
Get a list of function names in a shell script
9
2010-04-13 15:23:23
<p>I have a Bourne Shell script that has several functions in it, and allows to be called in the following way:</p> <pre><code>my.sh &lt;func_name&gt; &lt;param1&gt; &lt;param2&gt; </code></pre> <p>Inside, <code>func_name()</code> will be called with <code>param1</code> and <code>param2</code>.</p> <p>I want to crea...
16,518
23,420
2019-04-22 12:50:41
2,641,911
16
2010-04-15 00:14:26
459,745
2010-04-16 16:58:06
https://stackoverflow.com/q/2630812
https://stackoverflow.com/a/2641911
<p>You can get a list of functions in your script by using the grep command on your own script. In order for this approach to work, you will need to structure your functions a certain way so grep can find them. Here is a sample:</p> <pre><code>$ cat my.sh #!/bin/sh function func1() # Short description { echo func...
<p>You can get a list of functions in your script by using the grep command on your own script. In order for this approach to work, you will need to structure your functions a certain way so grep can find them. Here is a sample:</p> <pre><code>$ cat my.sh #!/bin/sh function func1() # Short description { echo func...
58, 390, 10327
linux, sh, shell
<h1>Get a list of function names in a shell script</h1> <p>I have a Bourne Shell script that has several functions in it, and allows to be called in the following way:</p> <pre><code>my.sh &lt;func_name&gt; &lt;param1&gt; &lt;param2&gt; </code></pre> <p>Inside, <code>func_name()</code> will be called with <code>param...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,930
bash
# Get a list of function names in a shell script I have a Bourne Shell script that has several functions in it, and allows to be called in the following way: ``` my.sh <func_name> <param1> <param2> ``` Inside, `func_name()` will be called with `param1` and `param2`. I want to create a `help` function that would jus...
You can get a list of functions in your script by using the grep command on your own script. In order for this approach to work, you will need to structure your functions a certain way so grep can find them. Here is a sample: ``` $ cat my.sh #!/bin/sh function func1() # Short description { echo func1 parameters: ...
614785
bash : how to use screen to have a term session used at home after work?
9
2009-03-05 13:40:56
<p>Everything is in the title, I would like to start a session at work and be able to get it when i'm at home.</p>
8,080
65,636
2010-11-02 22:04:28
614,828
16
2009-03-05 13:51:39
219
2009-03-05 13:51:39
https://stackoverflow.com/q/614785
https://stackoverflow.com/a/614828
<p>While at work, start a screen session:</p> <pre><code>$ screen </code></pre> <p>Do whatever work you want on the terminal session, and when you are leaving to go home, <strong>detach</strong> the session by pressing <strong>CTRL-A</strong> then <strong>D</strong>. Your screen session will then disappear. To re-act...
<p>While at work, start a screen session:</p> <pre><code>$ screen </code></pre> <p>Do whatever work you want on the terminal session, and when you are leaving to go home, <strong>detach</strong> the session by pressing <strong>CTRL-A</strong> then <strong>D</strong>. Your screen session will then disappear. To re-act...
387, 5024
bash, gnu-screen
<h1>bash : how to use screen to have a term session used at home after work?</h1> <p>Everything is in the title, I would like to start a session at work and be able to get it when i'm at home.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,931
bash
# bash : how to use screen to have a term session used at home after work? Everything is in the title, I would like to start a session at work and be able to get it when i'm at home.
While at work, start a screen session: ``` $ screen ``` Do whatever work you want on the terminal session, and when you are leaving to go home, **detach** the session by pressing **CTRL-A** then **D**. Your screen session will then disappear. To re-activate it once you are home, **resume** the session with the **-r**...
70535330
Dynamodb local web shell does not load
8
2021-12-30 18:20:42
<p>I am running DynamoDB locally using the instructions <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html" rel="noreferrer">here</a>. To remove potential docker networking issues I am using the &quot;Download Locally&quot; version of the instructions. Bef...
8,827
416,446
2024-08-04 07:17:23
70,722,538
16
2022-01-15 14:55:59
7,909,676
2022-01-15 14:55:59
https://stackoverflow.com/q/70535330
https://stackoverflow.com/a/70722538
<p>DynamoDB Local Web Shell was deprecated with version 1.16.X and is not available any longer from 1.17.X to latest. There are no immediate plans for a new Web Shell to be introduced.</p> <p>You can download an old version of DynamoDB Local &lt; 1.17.X should you wish to use the Web Shell.</p> <p><strong>Available ver...
<p>DynamoDB Local Web Shell was deprecated with version 1.16.X and is not available any longer from 1.17.X to latest. There are no immediate plans for a new Web Shell to be introduced.</p> <p>You can download an old version of DynamoDB Local &lt; 1.17.X should you wish to use the Web Shell.</p> <p><strong>Available ver...
390, 5996, 33388, 76578
amazon-dynamodb, amazon-web-services, localhost, shell
<h1>Dynamodb local web shell does not load</h1> <p>I am running DynamoDB locally using the instructions <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html" rel="noreferrer">here</a>. To remove potential docker networking issues I am using the &quot;Downloa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,932
bash
# Dynamodb local web shell does not load I am running DynamoDB locally using the instructions [here](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html). To remove potential docker networking issues I am using the "Download Locally" version of the instructions. Be...
DynamoDB Local Web Shell was deprecated with version 1.16.X and is not available any longer from 1.17.X to latest. There are no immediate plans for a new Web Shell to be introduced. You can download an old version of DynamoDB Local < 1.17.X should you wish to use the Web Shell. **Available versions:** ``` aws s3 ls ...
65482945
Corrupt PackageManager? Unable to find module providers (PowerShellGet)
8
2020-12-28 19:24:28
<p>This is a common error that is not solved by the common solutions I have found on the internet.</p> <p>Unable to run Get-PsRepository, Install-Module, and related (OneGet?) commands without them throwing the &quot;Unable to find module providers (PowerShellGet)&quot; error. This appears to be an issue with the NuGet...
9,954
9,760,060
2025-04-03 01:36:13
66,422,362
16
2021-03-01 12:42:06
5,064,143
2025-04-03 01:36:13
https://stackoverflow.com/q/65482945
https://stackoverflow.com/a/66422362
<p>We encountered the same problem. Found this thread without a solution. But I dug a bit further and on the computer that had this problem we found version 1.4.7 of PackageManagement installed. After removing this folder everything started working normally. I have not found how this thing got installed. Seems like a l...
<p>We encountered the same problem. Found this thread without a solution. But I dug a bit further and on the computer that had this problem we found version 1.4.7 of PackageManagement installed. After removing this folder everything started working normally. I have not found how this thing got installed. Seems like a l...
64, 526, 115517
oneget, powershell, windows
<h1>Corrupt PackageManager? Unable to find module providers (PowerShellGet)</h1> <p>This is a common error that is not solved by the common solutions I have found on the internet.</p> <p>Unable to run Get-PsRepository, Install-Module, and related (OneGet?) commands without them throwing the &quot;Unable to find module ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,933
bash
# Corrupt PackageManager? Unable to find module providers (PowerShellGet) This is a common error that is not solved by the common solutions I have found on the internet. Unable to run Get-PsRepository, Install-Module, and related (OneGet?) commands without them throwing the "Unable to find module providers (PowerShel...
We encountered the same problem. Found this thread without a solution. But I dug a bit further and on the computer that had this problem we found version 1.4.7 of PackageManagement installed. After removing this folder everything started working normally. I have not found how this thing got installed. Seems like a legi...
58211358
How to automate either PowerShell or PowerShell Core for same machine
8
2019-10-03 01:53:54
<p>With the release of PowerShell Core, how can an application choose which version of Powershell (Powershell 5.x or PowerShell Core) is being called when it using hosting automation library (system.management.automation)? Something about the runspace that should be created? or maybe the connection info?</p>
7,324
1,228,548
2024-09-08 17:45:44
58,211,901
16
2019-10-03 03:24:36
45,375
2024-09-08 17:45:44
https://stackoverflow.com/q/58211358
https://stackoverflow.com/a/58211901
<p>Here's an overview of the <strong>PowerShell SDK-related NuGet packages</strong>:<sup>Adapted from <a href="https://github.com/PowerShell/PowerShell/issues/8625#issuecomment-456515037" rel="nofollow noreferrer">here</a>.</sup></p> <p>Note: <del><code>System.Management.Automation</code></del> is <em>not</em> recommen...
<p>Here's an overview of the <strong>PowerShell SDK-related NuGet packages</strong>:<sup>Adapted from <a href="https://github.com/PowerShell/PowerShell/issues/8625#issuecomment-456515037" rel="nofollow noreferrer">here</a>.</sup></p> <p>Note: <del><code>System.Management.Automation</code></del> is <em>not</em> recommen...
526, 130616
powershell, powershell-core
<h1>How to automate either PowerShell or PowerShell Core for same machine</h1> <p>With the release of PowerShell Core, how can an application choose which version of Powershell (Powershell 5.x or PowerShell Core) is being called when it using hosting automation library (system.management.automation)? Something about th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,934
bash
# How to automate either PowerShell or PowerShell Core for same machine With the release of PowerShell Core, how can an application choose which version of Powershell (Powershell 5.x or PowerShell Core) is being called when it using hosting automation library (system.management.automation)? Something about the runspac...
Here's an overview of the **PowerShell SDK-related NuGet packages**:Adapted from [here](https://github.com/PowerShell/PowerShell/issues/8625#issuecomment-456515037). Note: ~~`System.Management.Automation`~~ is *not* recommended for direct use. - To **create *stand-alone applications*** that **host the PowerShell runt...
54770985
wget recursive/mirror option not following links
8
2019-02-19 16:36:08
<p>I am trying to mirror a website at the moment. <code>wget</code> seems to do the job very well, however it's not working on some pages.</p> <p>Looking at the <a href="https://www.gnu.org/software/wget/manual/html_node/Advanced-Usage.html" rel="nofollow noreferrer">manual</a>, the command</p> <pre><code>wget -r https...
6,766
6,565,273
2021-08-19 06:17:08
54,775,765
16
2019-02-19 22:15:46
952,658
2021-08-19 06:17:08
https://stackoverflow.com/q/54770985
https://stackoverflow.com/a/54775765
<p>Your website uses a relatively less-known form of robots control, through the <code>&lt;meta&gt;</code> tag in HTML. You can read more about it <a href="https://developers.google.com/search/reference/robots_meta_tag" rel="nofollow noreferrer">here</a>. Wget will correctly adhere to the instructions in this robots di...
<p>Your website uses a relatively less-known form of robots control, through the <code>&lt;meta&gt;</code> tag in HTML. You can read more about it <a href="https://developers.google.com/search/reference/robots_meta_tag" rel="nofollow noreferrer">here</a>. Wget will correctly adhere to the instructions in this robots di...
390, 5583
shell, wget
<h1>wget recursive/mirror option not following links</h1> <p>I am trying to mirror a website at the moment. <code>wget</code> seems to do the job very well, however it's not working on some pages.</p> <p>Looking at the <a href="https://www.gnu.org/software/wget/manual/html_node/Advanced-Usage.html" rel="nofollow norefe...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,935
bash
# wget recursive/mirror option not following links I am trying to mirror a website at the moment. `wget` seems to do the job very well, however it's not working on some pages. Looking at the [manual](https://www.gnu.org/software/wget/manual/html_node/Advanced-Usage.html), the command ``` wget -r https://www.gnu.org/...
Your website uses a relatively less-known form of robots control, through the `<meta>` tag in HTML. You can read more about it [here](https://developers.google.com/search/reference/robots_meta_tag). Wget will correctly adhere to the instructions in this robots directive. You can see this happening, if you look a little...
52309625
A parameter cannot be found that matches parameter name 'TokenKind'
8
2018-09-13 08:29:08
<p>I have beautified my Powershell according to <a href="https://coolcode.org/2018/03/16/how-to-make-your-powershell-beautiful/" rel="noreferrer">this blog</a>, but the <code>Operator</code> and <code>Parameter</code> are grey as follows:</p> <p><a href="https://i.sstatic.net/K2xCn.png" rel="noreferrer"><img src="https...
12,823
2,383,766
2020-12-15 06:41:52
52,651,577
16
2018-10-04 16:32:03
3,234,429
2020-12-15 06:41:52
https://stackoverflow.com/q/52309625
https://stackoverflow.com/a/52651577
<p>They made a breaking change PSReadline V2, read about it here: <a href="https://github.com/lzybkr/PSReadLine/issues/738" rel="noreferrer">https://github.com/lzybkr/PSReadLine/issues/738</a></p> <p>So instead of</p> <pre><code>Set-PSReadlineOption -TokenKind String -ForegroundColor Magenta Set-PSReadlineOption -Token...
<p>They made a breaking change PSReadline V2, read about it here: <a href="https://github.com/lzybkr/PSReadLine/issues/738" rel="noreferrer">https://github.com/lzybkr/PSReadLine/issues/738</a></p> <p>So instead of</p> <pre><code>Set-PSReadlineOption -TokenKind String -ForegroundColor Magenta Set-PSReadlineOption -Token...
526, 117507
powershell, psreadline
<h1>A parameter cannot be found that matches parameter name 'TokenKind'</h1> <p>I have beautified my Powershell according to <a href="https://coolcode.org/2018/03/16/how-to-make-your-powershell-beautiful/" rel="noreferrer">this blog</a>, but the <code>Operator</code> and <code>Parameter</code> are grey as follows:</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,936
bash
# A parameter cannot be found that matches parameter name 'TokenKind' I have beautified my Powershell according to [this blog](https://coolcode.org/2018/03/16/how-to-make-your-powershell-beautiful/), but the `Operator` and `Parameter` are grey as follows: [![enter image description here](https://i.sstatic.net/K2xCn.p...
They made a breaking change PSReadline V2, read about it here: <https://github.com/lzybkr/PSReadLine/issues/738> So instead of ``` Set-PSReadlineOption -TokenKind String -ForegroundColor Magenta Set-PSReadlineOption -TokenKind Variable -ForegroundColor Cyan ``` You would do something like ``` $colors = @{} $colors[...
52067816
How to get jq to print valid json after applying a filter
8
2018-08-29 00:20:04
<p>I'm working on jq filtering and output of results to output into another program that accepts a JSON payload. Consider the following example:</p> <p>INPUT:</p> <pre><code>My-MBP:myorg myname$ aws ec2 describe-snapshots --owner-id 12345678 | jq '.Snapshots[] | select(.Description | contains("myorg-database-b"))' </...
2,686
5,004,410
2018-08-29 00:48:41
52,067,905
16
2018-08-29 00:35:06
450,611
2018-08-29 00:48:41
https://stackoverflow.com/q/52067816
https://stackoverflow.com/a/52067905
<p>You can wrap the entire jq expression into square brackets to make it collect the filter output into an array (documented in <a href="https://stedolan.github.io/jq/manual/#Arrayconstruction:[]" rel="noreferrer">Array construction section</a>):</p> <pre><code>'[ .Snapshots[] | select(.Description | contains("myorg-d...
<p>You can wrap the entire jq expression into square brackets to make it collect the filter output into an array (documented in <a href="https://stedolan.github.io/jq/manual/#Arrayconstruction:[]" rel="noreferrer">Array construction section</a>):</p> <pre><code>'[ .Snapshots[] | select(.Description | contains("myorg-d...
387, 390, 1508, 33388, 105170
amazon-web-services, bash, jq, json, shell
<h1>How to get jq to print valid json after applying a filter</h1> <p>I'm working on jq filtering and output of results to output into another program that accepts a JSON payload. Consider the following example:</p> <p>INPUT:</p> <pre><code>My-MBP:myorg myname$ aws ec2 describe-snapshots --owner-id 12345678 | jq '.Sn...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,937
bash
# How to get jq to print valid json after applying a filter I'm working on jq filtering and output of results to output into another program that accepts a JSON payload. Consider the following example: INPUT: ``` My-MBP:myorg myname$ aws ec2 describe-snapshots --owner-id 12345678 | jq '.Snapshots[] | select(.Descrip...
You can wrap the entire jq expression into square brackets to make it collect the filter output into an array (documented in [Array construction section](https://stedolan.github.io/jq/manual/#Arrayconstruction:[])): ``` '[ .Snapshots[] | select(.Description | contains("myorg-database-b")) ]' ``` results in: ``` [ ...
47274532
Difference between () and $()
8
2017-11-13 22:20:27
<p>What's the difference between</p> <pre><code>Write-Host (Get-Date) # just paren </code></pre> <p>and</p> <pre><code>Write-Host $(Get-Date) # dollar-paren </code></pre> <p>Content within the parens could be anything, just going with a simple example. Is there any difference between the two?</p> <p>I consider mys...
4,390
1,580,900
2017-11-14 03:15:38
47,277,087
16
2017-11-14 03:15:38
1,930,135
2017-11-14 03:15:38
https://stackoverflow.com/q/47274532
https://stackoverflow.com/a/47277087
<p>The sub expression (<code>$(...)</code>) contains a <code>StatementBlockAst</code>. It can take <strong>any number</strong> of statements, meaning keywords (<code>if</code>, <code>foreach</code>, etc), pipelines, commands, etc. Parsing is similar to the inside of a named block like <code>begin</code>/<code>process...
<p>The sub expression (<code>$(...)</code>) contains a <code>StatementBlockAst</code>. It can take <strong>any number</strong> of statements, meaning keywords (<code>if</code>, <code>foreach</code>, etc), pipelines, commands, etc. Parsing is similar to the inside of a named block like <code>begin</code>/<code>process...
526
powershell
<h1>Difference between () and $()</h1> <p>What's the difference between</p> <pre><code>Write-Host (Get-Date) # just paren </code></pre> <p>and</p> <pre><code>Write-Host $(Get-Date) # dollar-paren </code></pre> <p>Content within the parens could be anything, just going with a simple example. Is there any difference ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,938
bash
# Difference between () and $() What's the difference between ``` Write-Host (Get-Date) # just paren ``` and ``` Write-Host $(Get-Date) # dollar-paren ``` Content within the parens could be anything, just going with a simple example. Is there any difference between the two? I consider myself reasonably experience...
The sub expression (`$(...)`) contains a `StatementBlockAst`. It can take **any number** of statements, meaning keywords (`if`, `foreach`, etc), pipelines, commands, etc. Parsing is similar to the inside of a named block like `begin`/`process`/`end`. The paren expression (`(...)`) can contain a **single** `ExpressionA...
46959151
bash script complains about file name too long
8
2017-10-26 16:15:52
<p>So I have a script that does this (jq is a command line JSON processor):</p> <pre><code>echo "Getting LB Node IDs" echo $LB_STATUS | jq '.loadBalancer.nodes[] .id' </code></pre> <p>The output of the last line is:</p> <pre><code>1 2 3 </code></pre> <p>But when I try and assign it to an array:</p> <pre><code>echo...
37,018
1,103,655
2017-10-26 16:48:07
46,959,196
16
2017-10-26 16:17:56
14,122
2017-10-26 16:38:15
https://stackoverflow.com/q/46959151
https://stackoverflow.com/a/46959196
<h3>What Went Wrong</h3> <p><code>$variable | something</code> doesn't pass the text in <code>variable</code> as input to <code>something</code> -- instead, it runs the contents of <code>$variable</code> <strong>as a command</strong>. Presumably you wanted <code>echo "$variable" | something</code> instead (but see bel...
<h3>What Went Wrong</h3> <p><code>$variable | something</code> doesn't pass the text in <code>variable</code> as input to <code>something</code> -- instead, it runs the contents of <code>$variable</code> <strong>as a command</strong>. Presumably you wanted <code>echo "$variable" | something</code> instead (but see bel...
387, 1508
bash, json
<h1>bash script complains about file name too long</h1> <p>So I have a script that does this (jq is a command line JSON processor):</p> <pre><code>echo "Getting LB Node IDs" echo $LB_STATUS | jq '.loadBalancer.nodes[] .id' </code></pre> <p>The output of the last line is:</p> <pre><code>1 2 3 </code></pre> <p>But wh...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,939
bash
# bash script complains about file name too long So I have a script that does this (jq is a command line JSON processor): ``` echo "Getting LB Node IDs" echo $LB_STATUS | jq '.loadBalancer.nodes[] .id' ``` The output of the last line is: ``` 1 2 3 ``` But when I try and assign it to an array: ``` echo "Creating a...
### What Went Wrong `$variable | something` doesn't pass the text in `variable` as input to `something` -- instead, it runs the contents of `$variable` **as a command**. Presumably you wanted `echo "$variable" | something` instead (but see below!) Even if that were fixed, the `array=( $(some-command) )` idiom is itse...
46451994
Set Value of Nested Object Property by Name in PowerShell
8
2017-09-27 15:38:39
<p>I want to set value of nested object property using PowerShell. When you are trying to set the value of the first level properties, it's quiet simple:</p> <pre><code>$propertyName = "someProperty" $obj.$propertyName = "someValue" # ← It works </code></pre> <p>For nested properties, it doesn't work:</p> <pre><cod...
7,700
3,110,834
2024-01-23 18:29:35
46,796,446
16
2017-10-17 18:04:23
3,110,834
2021-07-20 23:32:05
https://stackoverflow.com/q/46451994
https://stackoverflow.com/a/46796446
<p>I created <code>SetValue</code> and <code>GetValue</code> functions to let you get and set a nested property of an object (including a json object) dynamically by name and they work perfectly!</p> <p>They are recursive functions which resolve the complex property and get the nested property step by step by splitting...
<p>I created <code>SetValue</code> and <code>GetValue</code> functions to let you get and set a nested property of an object (including a json object) dynamically by name and they work perfectly!</p> <p>They are recursive functions which resolve the complex property and get the nested property step by step by splitting...
526, 7705, 37256, 153947
anonymous-types, object-graph, powershell, powershell-cmdlet
<h1>Set Value of Nested Object Property by Name in PowerShell</h1> <p>I want to set value of nested object property using PowerShell. When you are trying to set the value of the first level properties, it's quiet simple:</p> <pre><code>$propertyName = "someProperty" $obj.$propertyName = "someValue" # ← It works </cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,940
bash
# Set Value of Nested Object Property by Name in PowerShell I want to set value of nested object property using PowerShell. When you are trying to set the value of the first level properties, it's quiet simple: ``` $propertyName = "someProperty" $obj.$propertyName = "someValue" # ← It works ``` For nested propertie...
I created `SetValue` and `GetValue` functions to let you get and set a nested property of an object (including a json object) dynamically by name and they work perfectly! They are recursive functions which resolve the complex property and get the nested property step by step by splitting the nested property name. **G...
46154845
How to add a custom property to a PowerShell array?
8
2017-09-11 11:39:16
<p>Say I have a PowerShell array <code>$Sessions = @()</code> which I am going to fill with PSCustomObjects. How can I add a custom property to the array itself? E.g. so I can have <code>$Sessions.Count</code> which is built-in and <code>$Sessions.Active</code> which I want to set to the active session count.</p> <p>I...
29,269
4,161,937
2017-09-11 13:00:11
46,156,359
16
2017-09-11 12:59:06
3,829,407
2017-09-11 12:59:06
https://stackoverflow.com/q/46154845
https://stackoverflow.com/a/46156359
<p>The answer to your question as stated would be to just use <code>Add-Member</code> on the array object.</p> <pre><code>Add-Member -InputObject $sessions -MemberType NoteProperty -Name &quot;State&quot; -Value &quot;Fabulous&quot; </code></pre> <p>Adding a property to each element <em>after you created the object</em...
<p>The answer to your question as stated would be to just use <code>Add-Member</code> on the array object.</p> <pre><code>Add-Member -InputObject $sessions -MemberType NoteProperty -Name &quot;State&quot; -Value &quot;Fabulous&quot; </code></pre> <p>Adding a property to each element <em>after you created the object</em...
114, 526, 4898, 26280
arrays, powershell, properties, pscustomobject
<h1>How to add a custom property to a PowerShell array?</h1> <p>Say I have a PowerShell array <code>$Sessions = @()</code> which I am going to fill with PSCustomObjects. How can I add a custom property to the array itself? E.g. so I can have <code>$Sessions.Count</code> which is built-in and <code>$Sessions.Active</cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,941
bash
# How to add a custom property to a PowerShell array? Say I have a PowerShell array `$Sessions = @()` which I am going to fill with PSCustomObjects. How can I add a custom property to the array itself? E.g. so I can have `$Sessions.Count` which is built-in and `$Sessions.Active` which I want to set to the active sessi...
The answer to your question as stated would be to just use `Add-Member` on the array object. ``` Add-Member -InputObject $sessions -MemberType NoteProperty -Name "State" -Value "Fabulous" ``` Adding a property to each element *after you created the object* is similar. ``` $sessions | ForEach-Object{ $_ | Add-Mem...
43871278
How to delete all subdirectories with a specific name
8
2017-05-09 13:31:07
<p>I'm working on Linux and there is a folder, which contains lots of sub directories. I need to delete all of sub directories which have a same name. For example,<br></p> <pre><code>dir |---subdir1 |---subdir2 | |-----subdir1 |---file </code></pre> <p>I want to delete all of <code>subdir1</code>. Here is my ...
10,509
3,305,546
2017-05-09 18:16:51
43,871,456
16
2017-05-09 13:40:02
6,372,809
2017-05-09 14:01:28
https://stackoverflow.com/q/43871278
https://stackoverflow.com/a/43871456
<p>If <code>find</code> finds the correct directories at all, these should work:</p> <pre><code>find dir -type d -name "subdir1" -exec echo rm -rf {} \; </code></pre> <p>or</p> <pre><code>find dir -type d -name "subdir1" -exec echo rm -rf {} + </code></pre> <p>(the <code>echo</code> is there for verifying the comm...
<p>If <code>find</code> finds the correct directories at all, these should work:</p> <pre><code>find dir -type d -name "subdir1" -exec echo rm -rf {} \; </code></pre> <p>or</p> <pre><code>find dir -type d -name "subdir1" -exec echo rm -rf {} + </code></pre> <p>(the <code>echo</code> is there for verifying the comm...
58, 387, 390, 100470
bash, gnu-findutils, linux, shell
<h1>How to delete all subdirectories with a specific name</h1> <p>I'm working on Linux and there is a folder, which contains lots of sub directories. I need to delete all of sub directories which have a same name. For example,<br></p> <pre><code>dir |---subdir1 |---subdir2 | |-----subdir1 |---file </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,942
bash
# How to delete all subdirectories with a specific name I'm working on Linux and there is a folder, which contains lots of sub directories. I need to delete all of sub directories which have a same name. For example, ``` dir |---subdir1 |---subdir2 | |-----subdir1 |---file ``` I want to delete all of `subdir...
If `find` finds the correct directories at all, these should work: ``` find dir -type d -name "subdir1" -exec echo rm -rf {} \; ``` or ``` find dir -type d -name "subdir1" -exec echo rm -rf {} + ``` (the `echo` is there for verifying the command hits the files you wanted, remove it to actually run the `rm` and remo...
43794270
Disable or unset specific bash completion
8
2017-05-04 23:31:07
<p>I invoked</p> <pre><code>complete -o default -F _foo foo </code></pre> <p>To enable bash auto-complete for the command <code>foo</code>. Now I want this to go away, while retaining any other completions that bash may know. How do I do this? I want a </p> <pre><code>complete --remove foo </code></pre>
5,884
476,444
2017-05-04 23:50:35
43,794,295
16
2017-05-04 23:33:11
1,255,289
2017-05-04 23:50:35
https://stackoverflow.com/q/43794270
https://stackoverflow.com/a/43794295
<p><code>help complete</code> will tell you:</p> <pre class="lang-none prettyprint-override"><code>-r remove a completion specification for each NAME, or, if no NAMEs are supplied, all completion specifications </code></pre>
<p><code>help complete</code> will tell you:</p> <pre class="lang-none prettyprint-override"><code>-r remove a completion specification for each NAME, or, if no NAMEs are supplied, all completion specifications </code></pre>
387, 4682
autocomplete, bash
<h1>Disable or unset specific bash completion</h1> <p>I invoked</p> <pre><code>complete -o default -F _foo foo </code></pre> <p>To enable bash auto-complete for the command <code>foo</code>. Now I want this to go away, while retaining any other completions that bash may know. How do I do this? I want a </p> <pre><co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,943
bash
# Disable or unset specific bash completion I invoked ``` complete -o default -F _foo foo ``` To enable bash auto-complete for the command `foo`. Now I want this to go away, while retaining any other completions that bash may know. How do I do this? I want a ``` complete --remove foo ```
`help complete` will tell you: ``` -r remove a completion specification for each NAME, or, if no NAMEs are supplied, all completion specifications ```
41997509
Warning: Could not start program with arguments. Warning: Exec format error
8
2017-02-02 08:35:23
<p>Hello I'm trying to make a Shell script in opensuse to create MySqlUsers but when I try to run it I get this error: </p> <blockquote> <p>Warning: Could not start program '/home/thomas/Scripts/MySqlCreateUser.sh' with arguments '/home/thomas/Scripts/MySqlCreateUser.sh'.</p> <p>Warning: Exec format error</p> <...
11,039
7,504,798
2024-09-12 21:10:25
41,997,825
16
2017-02-02 08:53:27
1,072,229
2017-02-02 08:53:27
https://stackoverflow.com/q/41997509
https://stackoverflow.com/a/41997825
<p>I'm guessing you are trying to start this from a KDE menu item.</p> <p>You need to make sure that:</p> <ol> <li>Your script has a proper shebang on the first line (like <code>#!/bin/bash</code>)</li> <li>Your script is executable (<code>chmod +x /home/thomas/Scripts/MySqlCreateUser.sh</code>)</li> </ol>
<p>I'm guessing you are trying to start this from a KDE menu item.</p> <p>You need to make sure that:</p> <ol> <li>Your script has a proper shebang on the first line (like <code>#!/bin/bash</code>)</li> <li>Your script is executable (<code>chmod +x /home/thomas/Scripts/MySqlCreateUser.sh</code>)</li> </ol>
58, 387, 390, 10327, 126216
bash, kde-plasma, linux, sh, shell
<h1>Warning: Could not start program with arguments. Warning: Exec format error</h1> <p>Hello I'm trying to make a Shell script in opensuse to create MySqlUsers but when I try to run it I get this error: </p> <blockquote> <p>Warning: Could not start program '/home/thomas/Scripts/MySqlCreateUser.sh' with arguments '/...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,944
bash
# Warning: Could not start program with arguments. Warning: Exec format error Hello I'm trying to make a Shell script in opensuse to create MySqlUsers but when I try to run it I get this error: > Warning: Could not start program '/home/thomas/Scripts/MySqlCreateUser.sh' with arguments '/home/thomas/Scripts/MySqlCreat...
I'm guessing you are trying to start this from a KDE menu item. You need to make sure that: 1. Your script has a proper shebang on the first line (like `#!/bin/bash`) 2. Your script is executable (`chmod +x /home/thomas/Scripts/MySqlCreateUser.sh`)
41720114
n days ago from a given date on command line
8
2017-01-18 12:59:58
<p>For example, given date is '2016-12-31', n is 2, expected output is '2016-12-29'. <br><br> I survey <code>date</code> command and get n days ago from current date is easy: <br> <code>date -d "2 days ago" +%Y-%m-%d</code></p>
13,503
508,305
2018-11-02 15:09:17
41,720,242
16
2017-01-18 13:06:28
1,983,854
2017-01-18 13:06:28
https://stackoverflow.com/q/41720114
https://stackoverflow.com/a/41720242
<p>Just mention the date you want to extract two days from:</p> <pre><code>$ date -d "2016-12-31 2 days ago" +%Y-%m-%d 2016-12-29 </code></pre> <p>Or a bit better grammatically-wise:</p> <pre><code>$ date -d "2016-12-31 -2 days" +%Y-%m-%d 2016-12-29 </code></pre>
<p>Just mention the date you want to extract two days from:</p> <pre><code>$ date -d "2016-12-31 2 days ago" +%Y-%m-%d 2016-12-29 </code></pre> <p>Or a bit better grammatically-wise:</p> <pre><code>$ date -d "2016-12-31 -2 days" +%Y-%m-%d 2016-12-29 </code></pre>
34, 58, 390, 4072, 5002
date, gnu, linux, shell, unix
<h1>n days ago from a given date on command line</h1> <p>For example, given date is '2016-12-31', n is 2, expected output is '2016-12-29'. <br><br> I survey <code>date</code> command and get n days ago from current date is easy: <br> <code>date -d "2 days ago" +%Y-%m-%d</code></p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,945
bash
# n days ago from a given date on command line For example, given date is '2016-12-31', n is 2, expected output is '2016-12-29'. I survey `date` command and get n days ago from current date is easy: `date -d "2 days ago" +%Y-%m-%d`
Just mention the date you want to extract two days from: ``` $ date -d "2016-12-31 2 days ago" +%Y-%m-%d 2016-12-29 ``` Or a bit better grammatically-wise: ``` $ date -d "2016-12-31 -2 days" +%Y-%m-%d 2016-12-29 ```
40935058
Why can't I use predefined variables in class methods?
8
2016-12-02 14:56:24
<p>I tried to use predefined variables like $PSVersionTable or $PSScriptRoot in a class method. They failed with the error message </p> <blockquote> <p>Variable is not assigned in the method.</p> </blockquote> <p>Example:</p> <pre><code>Class Foo { [String]$Version GetVersion() { If ($PSVersionTab...
4,863
5,222,635
2016-12-02 16:16:05
40,936,584
16
2016-12-02 16:16:05
311,712
2016-12-02 16:16:05
https://stackoverflow.com/q/40935058
https://stackoverflow.com/a/40936584
<pre><code>Class Foo { [String] $Version GetVersion() { if ($global:PSVersionTable) { $this.Version = $global:PSVersionTable.PSVersion } } } $foo = [Foo]::new() $foo.GetVersion() Write-Host $foo.Version </code></pre> <p>For the "why" part, I guess this is related to scope. I...
<pre><code>Class Foo { [String] $Version GetVersion() { if ($global:PSVersionTable) { $this.Version = $global:PSVersionTable.PSVersion } } } $foo = [Foo]::new() $foo.GetVersion() Write-Host $foo.Version </code></pre> <p>For the "why" part, I guess this is related to scope. I...
526, 108010
powershell, powershell-5.0
<h1>Why can't I use predefined variables in class methods?</h1> <p>I tried to use predefined variables like $PSVersionTable or $PSScriptRoot in a class method. They failed with the error message </p> <blockquote> <p>Variable is not assigned in the method.</p> </blockquote> <p>Example:</p> <pre><code>Class Foo { ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,946
bash
# Why can't I use predefined variables in class methods? I tried to use predefined variables like $PSVersionTable or $PSScriptRoot in a class method. They failed with the error message > Variable is not assigned in the method. Example: ``` Class Foo { [String]$Version GetVersion() { If ($PSVersionT...
``` Class Foo { [String] $Version GetVersion() { if ($global:PSVersionTable) { $this.Version = $global:PSVersionTable.PSVersion } } } $foo = [Foo]::new() $foo.GetVersion() Write-Host $foo.Version ``` For the "why" part, I guess this is related to scope. In your class you hav...
40565331
npm view get more items
8
2016-11-12 17:00:04
<p>I am using the following command to look up versions of the packages that I have.</p> <p><code>npm view &lt;packagename&gt; versions</code></p> <p>The result that I get back is as follows</p> <pre><code> '2.4.0-2016-10-06-6743', '2.4.0-2016-10-07-6750', '2.4.0-2016-10-07-6751', '2.4.0-2016-10-07-6754', '...
2,519
4,412,482
2016-11-12 17:25:49
40,565,535
16
2016-11-12 17:20:34
459,517
2016-11-12 17:20:34
https://stackoverflow.com/q/40565331
https://stackoverflow.com/a/40565535
<p>try adding <code>--json</code> to the command</p> <pre><code>npm view &lt;packagename&gt; versions --json </code></pre> <blockquote> <p>This is a change to the behavior of util.inspect() in newer versions of Node.js (I'm guessing – this isn't behavior that the npm CLI team changed). If you want to get the full l...
<p>try adding <code>--json</code> to the command</p> <pre><code>npm view &lt;packagename&gt; versions --json </code></pre> <blockquote> <p>This is a change to the behavior of util.inspect() in newer versions of Node.js (I'm guessing – this isn't behavior that the npm CLI team changed). If you want to get the full l...
2631, 46426, 61387, 61874
cmd, git-bash, node.js, npm
<h1>npm view get more items</h1> <p>I am using the following command to look up versions of the packages that I have.</p> <p><code>npm view &lt;packagename&gt; versions</code></p> <p>The result that I get back is as follows</p> <pre><code> '2.4.0-2016-10-06-6743', '2.4.0-2016-10-07-6750', '2.4.0-2016-10-07-6751...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,947
bash
# npm view get more items I am using the following command to look up versions of the packages that I have. `npm view <packagename> versions` The result that I get back is as follows ``` '2.4.0-2016-10-06-6743', '2.4.0-2016-10-07-6750', '2.4.0-2016-10-07-6751', '2.4.0-2016-10-07-6754', '2.4.0-2016-10-07-6...
try adding `--json` to the command ``` npm view <packagename> versions --json ``` > This is a change to the behavior of util.inspect() in newer versions of Node.js (I'm guessing – this isn't behavior that the npm CLI team changed). If you want to get the full list, and also want to ensure that it's parseable, just ad...
38888149
PowerShell Get-ChildItem how to catch Exception
8
2016-08-11 05:47:44
<p>Im currently programming a visual error GUI that catches any exception while processing and give's the user an "easy to understand" error message. But it seems that I can't catch any exceptions while using the <code>Get-ChildItem</code> cmdlet. Do I have to use a different method than try / catch? </p> <p>Here's th...
20,153
5,723,412
2016-08-11 05:52:33
38,888,207
16
2016-08-11 05:51:25
1,163,423
2016-08-11 05:51:25
https://stackoverflow.com/q/38888149
https://stackoverflow.com/a/38888207
<p>Add <code>-ErrorAction Stop</code> to the <code>Get-ChildItem</code> cmdlet:</p> <pre><code>if ($checkBox1.Checked) { Try{ Get-ChildItem -path "K:\adm_spm_logdb_data\ADP\DATA" -ErrorAction Stop |Rename-Item -newname { $($_.BaseName -split '_provide')[0] + $_.Extension }; }catch [System.Except...
<p>Add <code>-ErrorAction Stop</code> to the <code>Get-ChildItem</code> cmdlet:</p> <pre><code>if ($checkBox1.Checked) { Try{ Get-ChildItem -path "K:\adm_spm_logdb_data\ADP\DATA" -ErrorAction Stop |Rename-Item -newname { $($_.BaseName -split '_provide')[0] + $_.Extension }; }catch [System.Except...
526, 5142, 7436
exception, powershell, try-catch
<h1>PowerShell Get-ChildItem how to catch Exception</h1> <p>Im currently programming a visual error GUI that catches any exception while processing and give's the user an "easy to understand" error message. But it seems that I can't catch any exceptions while using the <code>Get-ChildItem</code> cmdlet. Do I have to us...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,948
bash
# PowerShell Get-ChildItem how to catch Exception Im currently programming a visual error GUI that catches any exception while processing and give's the user an "easy to understand" error message. But it seems that I can't catch any exceptions while using the `Get-ChildItem` cmdlet. Do I have to use a different method...
Add `-ErrorAction Stop` to the `Get-ChildItem` cmdlet: ``` if ($checkBox1.Checked) { Try{ Get-ChildItem -path "K:\adm_spm_logdb_data\ADP\DATA" -ErrorAction Stop |Rename-Item -newname { $($_.BaseName -split '_provide')[0] + $_.Extension }; }catch [System.Exception]{ $listBox1.Items.Add("A...
37582981
How do you create a timespan from milliseconds in powershell?
8
2016-06-02 04:58:11
<p>New-Timespan takes no "MilliSeconds" parameter, how do you create a TimeSpan from milliseconds?</p>
11,446
240,040
2022-11-18 01:28:54
37,583,058
16
2016-06-02 05:04:11
150,605
2022-11-17 23:54:53
https://stackoverflow.com/q/37582981
https://stackoverflow.com/a/37583058
<p>As of <a href="https://learn.microsoft.com/powershell/scripting/whats-new/what-s-new-in-powershell-73" rel="nofollow noreferrer">PowerShell v7.3</a> there is a <a href="https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/new-timespan#-milliseconds" rel="nofollow noreferrer"><code>-Milliseconds...
<p>As of <a href="https://learn.microsoft.com/powershell/scripting/whats-new/what-s-new-in-powershell-73" rel="nofollow noreferrer">PowerShell v7.3</a> there is a <a href="https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/new-timespan#-milliseconds" rel="nofollow noreferrer"><code>-Milliseconds...
526
powershell
<h1>How do you create a timespan from milliseconds in powershell?</h1> <p>New-Timespan takes no "MilliSeconds" parameter, how do you create a TimeSpan from milliseconds?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,949
bash
# How do you create a timespan from milliseconds in powershell? New-Timespan takes no "MilliSeconds" parameter, how do you create a TimeSpan from milliseconds?
As of [PowerShell v7.3](https://learn.microsoft.com/powershell/scripting/whats-new/what-s-new-in-powershell-73) there is a [`-Milliseconds` parameter](https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/new-timespan#-milliseconds) of `New-TimeSpan`... ``` PS> New-TimeSpan -Milliseconds 10 Days ...
21580750
Disconnect and reconnect ttyUSB0 programmatically in Linux
8
2014-02-05 15:01:36
<p>Trying to solve <a href="https://stackoverflow.com/questions/21525654/linux-termios-how-to-handle-negative-result-of-select">this problem</a> (ttyUSB0 that works properly than stop working after about 1hr)I'm thinking on if disconnecting and reconnecting the usb device could be a good fix.</p> <p>So, it is possibil...
27,955
1,215,739
2019-08-27 15:27:59
25,121,189
16
2014-08-04 14:36:08
102,937
2014-08-04 14:36:08
https://stackoverflow.com/q/21580750
https://stackoverflow.com/a/25121189
<p>This is the solution:</p> <ul> <li><p>Find the identity of your usb device.</p> <pre><code># tree /sys/bus/usb/drivers/cp210x/ /sys/bus/usb/drivers/cp210x/ |-- 1-1:1.1 -&gt; ../../../../devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.1 |-- bind |-- module -&gt; ../../../../module/cp210x |-- remove_id ...
<p>This is the solution:</p> <ul> <li><p>Find the identity of your usb device.</p> <pre><code># tree /sys/bus/usb/drivers/cp210x/ /sys/bus/usb/drivers/cp210x/ |-- 1-1:1.1 -&gt; ../../../../devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.1 |-- bind |-- module -&gt; ../../../../module/cp210x |-- remove_id ...
58, 387, 3716, 17165
bash, linux, serial-port, tty
<h1>Disconnect and reconnect ttyUSB0 programmatically in Linux</h1> <p>Trying to solve <a href="https://stackoverflow.com/questions/21525654/linux-termios-how-to-handle-negative-result-of-select">this problem</a> (ttyUSB0 that works properly than stop working after about 1hr)I'm thinking on if disconnecting and reconne...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,950
bash
# Disconnect and reconnect ttyUSB0 programmatically in Linux Trying to solve [this problem](https://stackoverflow.com/questions/21525654/linux-termios-how-to-handle-negative-result-of-select) (ttyUSB0 that works properly than stop working after about 1hr)I'm thinking on if disconnecting and reconnecting the usb device...
This is the solution: - Find the identity of your usb device. ``` # tree /sys/bus/usb/drivers/cp210x/ /sys/bus/usb/drivers/cp210x/ |-- 1-1:1.1 -> ../../../../devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.1 |-- bind |-- module -> ../../../../module/cp210x |-- remove_id |-- uevent -- u...
23630501
How to: Progress bar in bash
8
2014-05-13 11:51:42
<p>I want to show a progress bar during a bash operation in a specific format something similar to the following:</p> <pre><code>[###########](40%) </code></pre> <p>after update it should become </p> <pre><code>[###############](50%) </code></pre> <p>and then similarly reach upto <code>100%</code></p> <p>Is there ...
16,535
1,049,096
2023-03-02 23:10:53
23,634,080
16
2014-05-13 14:28:11
1,983,854
2017-09-06 06:11:53
https://stackoverflow.com/q/23630501
https://stackoverflow.com/a/23634080
<p>Let's use <code>echo -n '...' $'\r'</code> to print a carriage return:</p> <pre><code>for ((k = 0; k &lt;= 10 ; k++)) do echo -n "[ " for ((i = 0 ; i &lt;= k; i++)); do echo -n "###"; done for ((j = i ; j &lt;= 10 ; j++)); do echo -n " "; done v=$((k * 10)) echo -n " ] " echo -n "$v %" $'\...
<p>Let's use <code>echo -n '...' $'\r'</code> to print a carriage return:</p> <pre><code>for ((k = 0; k &lt;= 10 ; k++)) do echo -n "[ " for ((i = 0 ; i &lt;= k; i++)); do echo -n "###"; done for ((j = i ; j &lt;= 10 ; j++)); do echo -n " "; done v=$((k * 10)) echo -n " ] " echo -n "$v %" $'\...
58, 387
bash, linux
<h1>How to: Progress bar in bash</h1> <p>I want to show a progress bar during a bash operation in a specific format something similar to the following:</p> <pre><code>[###########](40%) </code></pre> <p>after update it should become </p> <pre><code>[###############](50%) </code></pre> <p>and then similarly reach up...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,951
bash
# How to: Progress bar in bash I want to show a progress bar during a bash operation in a specific format something similar to the following: ``` [###########](40%) ``` after update it should become ``` [###############](50%) ``` and then similarly reach upto `100%` Is there any way to achieve this I wrote the f...
Let's use `echo -n '...' $'\r'` to print a carriage return: ``` for ((k = 0; k <= 10 ; k++)) do echo -n "[ " for ((i = 0 ; i <= k; i++)); do echo -n "###"; done for ((j = i ; j <= 10 ; j++)); do echo -n " "; done v=$((k * 10)) echo -n " ] " echo -n "$v %" $'\r' sleep 0.05 done echo ``` I...
23415794
How to avoid a shell script exiting on failure for particular commands
8
2014-05-01 20:12:38
<p>The following script runs with the <code>-e</code> option, so it will exit if any of the commands in it fail:</p> <pre><code>#!/bin/sh -e command1 #script should fail if command1 fails command2 #script should NOT fail if command2 fails command3 #script should fail if command3 fails </code></pre> <p>How can I make ...
7,326
2,748,513
2018-04-25 19:31:19
23,415,817
16
2014-05-01 20:14:05
68,587
2014-05-01 20:14:05
https://stackoverflow.com/q/23415794
https://stackoverflow.com/a/23415817
<pre><code>command1 command2 || true command3 </code></pre>
<pre><code>command1 command2 || true command3 </code></pre>
390, 10327
sh, shell
<h1>How to avoid a shell script exiting on failure for particular commands</h1> <p>The following script runs with the <code>-e</code> option, so it will exit if any of the commands in it fail:</p> <pre><code>#!/bin/sh -e command1 #script should fail if command1 fails command2 #script should NOT fail if command2 fails ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,952
bash
# How to avoid a shell script exiting on failure for particular commands The following script runs with the `-e` option, so it will exit if any of the commands in it fail: ``` #!/bin/sh -e command1 #script should fail if command1 fails command2 #script should NOT fail if command2 fails command3 #script should fail if...
``` command1 command2 || true command3 ```
22537699
Cannot use alias while executing a command via SSH
8
2014-03-20 15:29:27
<p>I commented out this line in .bashrc:</p> <pre><code># [ -z "$PS1" ] &amp;&amp; return </code></pre> <p>and now the alias gets read, but I still cannot execute it... :/</p> <p>We can ask the server if the alias has been defined:</p> <pre><code>$ ssh server "cd /tmp &amp;&amp; alias backup_tb" alias backup_tb='pg...
9,168
458,177
2017-05-23 12:03:55
22,540,192
16
2014-03-20 17:03:59
91,813
2014-03-20 19:14:32
https://stackoverflow.com/q/22537699
https://stackoverflow.com/a/22540192
<p>Quoted from the man page of <code>bash</code>: <em>Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt ...</em></p> <p>So the simplest way IMO is to put the following lines at the top of your <code>/home/&lt;user&gt;/.bashrc</code> file:</p> <pre><c...
<p>Quoted from the man page of <code>bash</code>: <em>Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt ...</em></p> <p>So the simplest way IMO is to put the following lines at the top of your <code>/home/&lt;user&gt;/.bashrc</code> file:</p> <pre><c...
386, 387
bash, ssh
<h1>Cannot use alias while executing a command via SSH</h1> <p>I commented out this line in .bashrc:</p> <pre><code># [ -z "$PS1" ] &amp;&amp; return </code></pre> <p>and now the alias gets read, but I still cannot execute it... :/</p> <p>We can ask the server if the alias has been defined:</p> <pre><code>$ ssh ser...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,953
bash
# Cannot use alias while executing a command via SSH I commented out this line in .bashrc: ``` # [ -z "$PS1" ] && return ``` and now the alias gets read, but I still cannot execute it... :/ We can ask the server if the alias has been defined: ``` $ ssh server "cd /tmp && alias backup_tb" alias backup_tb='pg_dump -...
Quoted from the man page of `bash`: *Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt ...* So the simplest way IMO is to put the following lines at the top of your `/home/<user>/.bashrc` file: ``` # comment out the original line # [ -z "$PS1" ] && r...
19880246
Move only files recursively from multiple directories into one directory with mv
8
2013-11-09 18:04:20
<p>I currently have ~40k RAW images that are in a nested directory structure. (Some folders have as many as 100 subfolders filled with files.) I would like to move them all into one master directory, with no subfolders. How could this be accomplished using <code>mv</code>? I know the <code>-r</code> switch will copy re...
11,895
1,067,257
2014-12-01 06:59:40
19,881,331
16
2013-11-09 18:12:09
1,815,797
2014-12-01 06:59:40
https://stackoverflow.com/q/19880246
https://stackoverflow.com/a/19881331
<p>If your photos are in <code>/path/to/photos/</code> and its subdirectories, and you want to move then in <code>/path/to/master/</code>, and you want to select them by extension <code>.jpg</code>, <code>.JPG</code>, <code>.png</code>, <code>.PNG</code>, etc.:</p> <pre><code>find /path/to/photos \( -iname '*.jpg' -o ...
<p>If your photos are in <code>/path/to/photos/</code> and its subdirectories, and you want to move then in <code>/path/to/master/</code>, and you want to select them by extension <code>.jpg</code>, <code>.JPG</code>, <code>.png</code>, <code>.PNG</code>, etc.:</p> <pre><code>find /path/to/photos \( -iname '*.jpg' -o ...
34, 218, 387, 4072, 12668
bash, directory, gnu, mv, unix
<h1>Move only files recursively from multiple directories into one directory with mv</h1> <p>I currently have ~40k RAW images that are in a nested directory structure. (Some folders have as many as 100 subfolders filled with files.) I would like to move them all into one master directory, with no subfolders. How could ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,954
bash
# Move only files recursively from multiple directories into one directory with mv I currently have ~40k RAW images that are in a nested directory structure. (Some folders have as many as 100 subfolders filled with files.) I would like to move them all into one master directory, with no subfolders. How could this be a...
If your photos are in `/path/to/photos/` and its subdirectories, and you want to move then in `/path/to/master/`, and you want to select them by extension `.jpg`, `.JPG`, `.png`, `.PNG`, etc.: ``` find /path/to/photos \( -iname '*.jpg' -o -iname '*.png' \) -type f -exec mv -nv -t '/path/to/master' -- {} + ``` If you ...
18859158
Powershell - Get Data of Registry Value Saved to a Variable
8
2013-09-17 20:19:24
<p>I need to save a single data item in a registry key to a variable. I've tried the following without any luck:</p> <pre><code>$dxVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\DirectX").GetValue("Version",$null) </code></pre> <p>I want JUST the version number saved to the variable, nothing else. Not the name...
32,369
2,784,539
2013-09-17 20:29:11
18,859,213
16
2013-09-17 20:22:37
775,544
2013-09-17 20:29:11
https://stackoverflow.com/q/18859158
https://stackoverflow.com/a/18859213
<p>You almost had it. Try:</p> <pre><code>$dxVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\DirectX").Version </code></pre> <p><a href="http://technet.microsoft.com/en-us/library/hh849851.aspx">Get-ItemProperty</a> returns a PSCustomObject with a number of properties -- Version among them. This sort of dotted ...
<p>You almost had it. Try:</p> <pre><code>$dxVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\DirectX").Version </code></pre> <p><a href="http://technet.microsoft.com/en-us/library/hh849851.aspx">Get-ItemProperty</a> returns a PSCustomObject with a number of properties -- Version among them. This sort of dotted ...
526
powershell
<h1>Powershell - Get Data of Registry Value Saved to a Variable</h1> <p>I need to save a single data item in a registry key to a variable. I've tried the following without any luck:</p> <pre><code>$dxVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\DirectX").GetValue("Version",$null) </code></pre> <p>I want JUST...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,955
bash
# Powershell - Get Data of Registry Value Saved to a Variable I need to save a single data item in a registry key to a variable. I've tried the following without any luck: ``` $dxVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\DirectX").GetValue("Version",$null) ``` I want JUST the version number saved to the ...
You almost had it. Try: ``` $dxVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\DirectX").Version ``` [Get-ItemProperty](http://technet.microsoft.com/en-us/library/hh849851.aspx) returns a PSCustomObject with a number of properties -- Version among them. This sort of dotted notation as I used above allows you to...
18273766
How can I grep in a loop?
8
2013-08-16 12:51:17
<p>I have a file containing text in separate lines. </p> <pre><code>text1 text2 text3 textN </code></pre> <p>I have a directory with many files. I want to grep for each line in the of this specific directory. What is an easy way to do this?</p>
48,385
1,197,249
2014-03-18 20:39:25
18,273,817
16
2013-08-16 12:53:50
1,983,854
2014-03-18 20:39:25
https://stackoverflow.com/q/18273766
https://stackoverflow.com/a/18273817
<p>There is no need to loop, you can do use <code>grep</code> with the <code>-f</code> option to get patterns from a file:</p> <pre><code>grep -f pattern_file files* </code></pre> <p>From <code>man grep</code>:</p> <blockquote> <p><strong>-f FILE, --file=FILE</strong></p> <p>Obtain patterns from FILE, one per...
<p>There is no need to loop, you can do use <code>grep</code> with the <code>-f</code> option to get patterns from a file:</p> <pre><code>grep -f pattern_file files* </code></pre> <p>From <code>man grep</code>:</p> <blockquote> <p><strong>-f FILE, --file=FILE</strong></p> <p>Obtain patterns from FILE, one per...
58, 387, 390, 580, 1271
bash, grep, linux, perl, shell
<h1>How can I grep in a loop?</h1> <p>I have a file containing text in separate lines. </p> <pre><code>text1 text2 text3 textN </code></pre> <p>I have a directory with many files. I want to grep for each line in the of this specific directory. What is an easy way 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
8,956
bash
# How can I grep in a loop? I have a file containing text in separate lines. ``` text1 text2 text3 textN ``` I have a directory with many files. I want to grep for each line in the of this specific directory. What is an easy way to do this?
There is no need to loop, you can do use `grep` with the `-f` option to get patterns from a file: ``` grep -f pattern_file files* ``` From `man grep`: > **-f FILE, --file=FILE** > > Obtain patterns from FILE, one per line. The empty file contains zero > patterns, and therefore matches nothing. (-f is specified by PO...
17575321
how to pass variable from shell script to sqlplus
8
2013-07-10 15:52:32
<p>I have a shell script that calls file.sql</p> <p>I am looking for a way to pass some parameters to my file.sql.</p> <p>If I don't pass a variable with some value to the sql script, I will have to create multiple .sql files with SELECT statement and all that would change is few words.</p> <p>My shell script calls ...
140,931
2,084,209
2013-07-15 13:44:55
17,575,609
16
2013-07-10 16:06:16
266,304
2013-07-15 13:44:55
https://stackoverflow.com/q/17575321
https://stackoverflow.com/a/17575609
<p>You appear to have a <code>heredoc</code> containing a single SQL*Plus command, though it doesn't look right as noted in the comments. You can either pass a value in the <code>heredoc</code>:</p> <pre><code>sqlplus -S user/pass@localhost &lt;&lt; EOF @/opt/D2RQ/file.sql BUILDING exit; EOF </code></pre> <p>or if <c...
<p>You appear to have a <code>heredoc</code> containing a single SQL*Plus command, though it doesn't look right as noted in the comments. You can either pass a value in the <code>heredoc</code>:</p> <pre><code>sqlplus -S user/pass@localhost &lt;&lt; EOF @/opt/D2RQ/file.sql BUILDING exit; EOF </code></pre> <p>or if <c...
22, 390, 4480, 165558
oracle-database, shell, sql, sqlplus
<h1>how to pass variable from shell script to sqlplus</h1> <p>I have a shell script that calls file.sql</p> <p>I am looking for a way to pass some parameters to my file.sql.</p> <p>If I don't pass a variable with some value to the sql script, I will have to create multiple .sql files with SELECT statement and all tha...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,957
bash
# how to pass variable from shell script to sqlplus I have a shell script that calls file.sql I am looking for a way to pass some parameters to my file.sql. If I don't pass a variable with some value to the sql script, I will have to create multiple .sql files with SELECT statement and all that would change is few w...
You appear to have a `heredoc` containing a single SQL*Plus command, though it doesn't look right as noted in the comments. You can either pass a value in the `heredoc`: ``` sqlplus -S user/pass@localhost << EOF @/opt/D2RQ/file.sql BUILDING exit; EOF ``` or if `BUILDING` is `$2` in your script: ``` sqlplus -S user/p...
17450573
How to actually change/set environment variables from within emacs
8
2013-07-03 14:20:39
<p>In my shell I did: <code>export BLA=foo</code> and then I do <code>echo $BLA</code> and I see <code>foo</code> as expected. I then load up emacs and do <code>M-!</code> for a shell command and do <code>echo $BLA</code> and it's set to something else, <code>bar</code>. So then I run <code>M-x setenv</code> and give i...
10,238
970,171
2013-07-04 11:47:48
17,451,828
16
2013-07-03 15:16:13
2,381,823
2013-07-03 15:16:13
https://stackoverflow.com/q/17450573
https://stackoverflow.com/a/17451828
<p><code>setenv</code> will modify the environment for the processes emacs launch <strong>after</strong> you set the value. Running child processes will not be affected.</p> <p>Thus, doing a <code>(setenv "FOO" "bar")</code> and then <code>M-x shell</code> (provides you have not a running shell yet) will produce a sh...
<p><code>setenv</code> will modify the environment for the processes emacs launch <strong>after</strong> you set the value. Running child processes will not be affected.</p> <p>Thus, doing a <code>(setenv "FOO" "bar")</code> and then <code>M-x shell</code> (provides you have not a running shell yet) will produce a sh...
58, 371, 387, 9013
bash, emacs, environment-variables, linux
<h1>How to actually change/set environment variables from within emacs</h1> <p>In my shell I did: <code>export BLA=foo</code> and then I do <code>echo $BLA</code> and I see <code>foo</code> as expected. I then load up emacs and do <code>M-!</code> for a shell command and do <code>echo $BLA</code> and it's set to someth...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,958
bash
# How to actually change/set environment variables from within emacs In my shell I did: `export BLA=foo` and then I do `echo $BLA` and I see `foo` as expected. I then load up emacs and do `M-!` for a shell command and do `echo $BLA` and it's set to something else, `bar`. So then I run `M-x setenv` and give it `BLA` an...
`setenv` will modify the environment for the processes emacs launch **after** you set the value. Running child processes will not be affected. Thus, doing a `(setenv "FOO" "bar")` and then `M-x shell` (provides you have not a running shell yet) will produce a shell with environment variable "FOO" set to "bar".
15992897
How to concatenate strings formatted with printf in bash
8
2013-04-13 21:03:14
<p>I need to concatenate several strings in loop and assign result to variable:</p> <p>Formatted string example:</p> <pre><code>result=$(printf '| %-15s| %-25s| %-15s| %-15s| %-15s\n' $size $name $visits $inbound $outbound); </code></pre> <p>From my view it should work like this:</p> <pre><code>result='' while read...
41,191
947,668
2013-04-14 00:16:17
15,993,143
16
2013-04-13 21:28:11
2,269,219
2013-04-14 00:16:17
https://stackoverflow.com/q/15992897
https://stackoverflow.com/a/15993143
<p>Use double quotes around $result and all other variables that may contain blanks and other special characters if they are to be used as a single argument to a program or built-in function:</p> <pre><code>result=$(printf '%s| %-15s| %-25s| %-15s| %-15s| %-15s\n' "$result" "$size" "$name" "$visits" "$inbound" "$outbo...
<p>Use double quotes around $result and all other variables that may contain blanks and other special characters if they are to be used as a single argument to a program or built-in function:</p> <pre><code>result=$(printf '%s| %-15s| %-25s| %-15s| %-15s| %-15s\n' "$result" "$size" "$name" "$visits" "$inbound" "$outbo...
387, 390, 1156
bash, printf, shell
<h1>How to concatenate strings formatted with printf in bash</h1> <p>I need to concatenate several strings in loop and assign result to variable:</p> <p>Formatted string example:</p> <pre><code>result=$(printf '| %-15s| %-25s| %-15s| %-15s| %-15s\n' $size $name $visits $inbound $outbound); </code></pre> <p>From my v...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,959
bash
# How to concatenate strings formatted with printf in bash I need to concatenate several strings in loop and assign result to variable: Formatted string example: ``` result=$(printf '| %-15s| %-25s| %-15s| %-15s| %-15s\n' $size $name $visits $inbound $outbound); ``` From my view it should work like this: ``` resul...
Use double quotes around $result and all other variables that may contain blanks and other special characters if they are to be used as a single argument to a program or built-in function: ``` result=$(printf '%s| %-15s| %-25s| %-15s| %-15s| %-15s\n' "$result" "$size" "$name" "$visits" "$inbound" "$outbound") ``` If ...
15365307
Why does adding spaces around bash comparison operator change the result?
8
2013-03-12 15:28:23
<p>Could someone explain why spaces around <code>==</code> change the comparison result? The following:</p> <pre><code>if [[ 1 == 2 ]] ; then echo ok ; fi </code></pre> <p>prints nothing, while</p> <pre><code>if [[ 1==2 ]] ; then echo ok ; fi </code></pre> <p>prints <code>ok</code></p>
481
48,461
2013-03-12 15:42:23
15,365,426
16
2013-03-12 15:33:06
1,126,841
2013-03-12 15:42:23
https://stackoverflow.com/q/15365307
https://stackoverflow.com/a/15365426
<p>"1==2" is a single 4-character string, not an expression involving the <code>==</code> operator. Non-empty strings always evaluate to true in the context of the conditional expression <code>[[ ... ]]</code>. Whitespace is mandatory around the <code>==</code> operator.</p> <p>Like everything else in <code>bash</code...
<p>"1==2" is a single 4-character string, not an expression involving the <code>==</code> operator. Non-empty strings always evaluate to true in the context of the conditional expression <code>[[ ... ]]</code>. Whitespace is mandatory around the <code>==</code> operator.</p> <p>Like everything else in <code>bash</code...
387
bash
<h1>Why does adding spaces around bash comparison operator change the result?</h1> <p>Could someone explain why spaces around <code>==</code> change the comparison result? The following:</p> <pre><code>if [[ 1 == 2 ]] ; then echo ok ; fi </code></pre> <p>prints nothing, while</p> <pre><code>if [[ 1==2 ]] ; then echo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,960
bash
# Why does adding spaces around bash comparison operator change the result? Could someone explain why spaces around `==` change the comparison result? The following: ``` if [[ 1 == 2 ]] ; then echo ok ; fi ``` prints nothing, while ``` if [[ 1==2 ]] ; then echo ok ; fi ``` prints `ok`
"1==2" is a single 4-character string, not an expression involving the `==` operator. Non-empty strings always evaluate to true in the context of the conditional expression `[[ ... ]]`. Whitespace is mandatory around the `==` operator. Like everything else in `bash`, the contents of `[[ ... ]]` are simply a white-spac...
11363342
Change DCOM config security settings using Powershell
8
2012-07-06 13:40:38
<p>I have been given the task of writing Powershell scripts to set up a server from scratch to run one of our services as part of a web application, and one of the steps required for setting this server up is changing the DCOM config for the installed service, specifically adding accounts to the "Launch and Activation"...
59,133
771,509
2017-09-27 21:20:50
11,405,503
16
2012-07-10 01:38:04
251,123
2012-07-10 01:38:04
https://stackoverflow.com/q/11363342
https://stackoverflow.com/a/11405503
<p>Looks like you would do it using WMI.</p> <p>Get an instance of: <code>Win32_DCOMApplicationSetting</code> like this:</p> <pre><code>$dcom = Get-WMIObject -Class Win32_DCOMApplicationSetting -Filter 'Description="Something"' </code></pre> <p>Now you have access to the <code>SetAccessSecurityDescriptor</code> and ...
<p>Looks like you would do it using WMI.</p> <p>Get an instance of: <code>Win32_DCOMApplicationSetting</code> like this:</p> <pre><code>$dcom = Get-WMIObject -Class Win32_DCOMApplicationSetting -Filter 'Description="Something"' </code></pre> <p>Now you have access to the <code>SetAccessSecurityDescriptor</code> and ...
526, 2194
dcom, powershell
<h1>Change DCOM config security settings using Powershell</h1> <p>I have been given the task of writing Powershell scripts to set up a server from scratch to run one of our services as part of a web application, and one of the steps required for setting this server up is changing the DCOM config for the installed servi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
8,961
bash
# Change DCOM config security settings using Powershell I have been given the task of writing Powershell scripts to set up a server from scratch to run one of our services as part of a web application, and one of the steps required for setting this server up is changing the DCOM config for the installed service, speci...
Looks like you would do it using WMI. Get an instance of: `Win32_DCOMApplicationSetting` like this: ``` $dcom = Get-WMIObject -Class Win32_DCOMApplicationSetting -Filter 'Description="Something"' ``` Now you have access to the `SetAccessSecurityDescriptor` and `SetLaunchSecurityDescriptor` methods. From: <http://ms...