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
36921658
Save command output on variable and check exit status
28
2016-04-28 17:31:01
<p>The following command will resolve google ip</p> <pre><code>&gt; ip=`dig +short google.com` &gt; echo $ip &gt; 216.58.210.238 </code></pre> <p>Sometimes (especially when internet connection is lost) this command fail with this error</p> <pre><code>&gt; ;; connection timed out; no servers could be reached </code></pr...
28,244
4,849,973
2021-05-31 09:57:45
36,921,714
13
2016-04-28 17:33:40
1,620,779
2021-05-31 09:57:03
https://stackoverflow.com/q/36921658
https://stackoverflow.com/a/36921714
<p>You should use <code>$?</code> instead of <code>$#</code>.</p> <ul> <li><strong>$?</strong> contains the return value from the last script.</li> <li><strong>$#</strong> contains the total number of arguments passed to a script or function.</li> </ul> <p>Do something like below :</p> <pre><code>ip=$(dig +short googl...
<p>You should use <code>$?</code> instead of <code>$#</code>.</p> <ul> <li><strong>$?</strong> contains the return value from the last script.</li> <li><strong>$#</strong> contains the total number of arguments passed to a script or function.</li> </ul> <p>Do something like below :</p> <pre><code>ip=$(dig +short googl...
387
bash
<h1>Save command output on variable and check exit status</h1> <p>The following command will resolve google ip</p> <pre><code>&gt; ip=`dig +short google.com` &gt; echo $ip &gt; 216.58.210.238 </code></pre> <p>Sometimes (especially when internet connection is lost) this command fail with this error</p> <pre><code>&gt; ;...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,068
bash
# Save command output on variable and check exit status The following command will resolve google ip ``` > ip=`dig +short google.com` > echo $ip > 216.58.210.238 ``` Sometimes (especially when internet connection is lost) this command fail with this error ``` > ;; connection timed out; no servers could be reached `...
You should use `$?` instead of `$#`. - **$?** contains the return value from the last script. - **$#** contains the total number of arguments passed to a script or function. Do something like below : ``` ip=$(dig +short google.com) if [ $? -eq 0 ]; then echo "Success" # Do something here else echo "Fail" # Fallb...
26292078
How to grep for lines which contain particular words in a log file?
27
2014-10-10 04:42:22
<p>I have a big log file which I am trying to scan it for a particular words. In general, I will have few words which I need to grep on my big log file and print out the line which contains those words.</p> <p>I know how to do simple grep on a file. Suppose if my file name is <code>abc.log</code> and I need to find a ...
140,391
2,809,564
2018-06-11 20:43:05
26,292,103
13
2014-10-10 04:44:37
1,405,588
2018-06-11 20:43:05
https://stackoverflow.com/q/26292078
https://stackoverflow.com/a/26292103
<p>If you store your patterns in a file, one per line, you can use <code>grep -f file-with-patterns file-to-search.log</code></p> <p>From the man page:</p> <pre><code> -f FILE, --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matc...
<p>If you store your patterns in a file, one per line, you can use <code>grep -f file-with-patterns file-to-search.log</code></p> <p>From the man page:</p> <pre><code> -f FILE, --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matc...
58, 387, 390, 1271
bash, grep, linux, shell
<h1>How to grep for lines which contain particular words in a log file?</h1> <p>I have a big log file which I am trying to scan it for a particular words. In general, I will have few words which I need to grep on my big log file and print out the line which contains those words.</p> <p>I know how to do simple grep on ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,069
bash
# How to grep for lines which contain particular words in a log file? I have a big log file which I am trying to scan it for a particular words. In general, I will have few words which I need to grep on my big log file and print out the line which contains those words. I know how to do simple grep on a file. Suppose ...
If you store your patterns in a file, one per line, you can use `grep -f file-with-patterns file-to-search.log` From the man page: ``` -f FILE, --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is ...
6065446
Executing a shell command from Common Lisp
27
2011-05-19 22:16:25
<p>How can i execute a shell (bash) command within a Common Lisp program and assign the output to a variable?</p>
21,151
481,863
2019-01-18 20:32:58
6,066,206
13
2011-05-20 00:09:55
428,988
2011-05-20 00:09:55
https://stackoverflow.com/q/6065446
https://stackoverflow.com/a/6066206
<p><strong><a href="http://common-lisp.net/project/asdf/" rel="noreferrer">ASDF</a> provides a <code>RUN-SHELL-COMMAND</code> that works with many Common Lisp implementations</strong> including ABCL, Allegro CL, CLISP, Clozure CL, ECL, GCL, LispWorks, SBCL, CMU, XCL and SCL.</p> <p>It takes a control string and a list...
<p><strong><a href="http://common-lisp.net/project/asdf/" rel="noreferrer">ASDF</a> provides a <code>RUN-SHELL-COMMAND</code> that works with many Common Lisp implementations</strong> including ABCL, Allegro CL, CLISP, Clozure CL, ECL, GCL, LispWorks, SBCL, CMU, XCL and SCL.</p> <p>It takes a control string and a list...
14, 387, 390, 7610, 7932
bash, common-lisp, exec, lisp, shell
<h1>Executing a shell command from Common Lisp</h1> <p>How can i execute a shell (bash) command within a Common Lisp program and assign the output to a variable?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,070
bash
# Executing a shell command from Common Lisp How can i execute a shell (bash) command within a Common Lisp program and assign the output to a variable?
**[ASDF](http://common-lisp.net/project/asdf/) provides a `RUN-SHELL-COMMAND` that works with many Common Lisp implementations** including ABCL, Allegro CL, CLISP, Clozure CL, ECL, GCL, LispWorks, SBCL, CMU, XCL and SCL. It takes a control string and a list of arguments like `FORMAT`, and synchronously executes the re...
4384814
How to call batch script from Powershell?
26
2010-12-08 06:38:29
<p>I have one big batch script which sets bunch of environment variables. I want to call that batch script from powershell, that way I can get benefits of both i.e. enviorment variable set by my script and powershell.</p>
44,509
2,302,649
2021-11-15 00:58:26
4,385,011
13
2010-12-08 07:11:54
323,582
2015-05-18 11:06:49
https://stackoverflow.com/q/4384814
https://stackoverflow.com/a/4385011
<p>The idea comes from this blog post: <a href="http://www.leeholmes.com/blog/2006/05/11/nothing-solves-everything-%e2%80%93-powershell-and-other-technologies/" rel="noreferrer">Nothing solves everything – PowerShell and other technologies</a></p> <p>Here is my version of this script. It calls a batch file (or any <em...
<p>The idea comes from this blog post: <a href="http://www.leeholmes.com/blog/2006/05/11/nothing-solves-everything-%e2%80%93-powershell-and-other-technologies/" rel="noreferrer">Nothing solves everything – PowerShell and other technologies</a></p> <p>Here is my version of this script. It calls a batch file (or any <em...
526, 7002
batch-file, powershell
<h1>How to call batch script from Powershell?</h1> <p>I have one big batch script which sets bunch of environment variables. I want to call that batch script from powershell, that way I can get benefits of both i.e. enviorment variable set by my script and powershell.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,071
bash
# How to call batch script from Powershell? I have one big batch script which sets bunch of environment variables. I want to call that batch script from powershell, that way I can get benefits of both i.e. enviorment variable set by my script and powershell.
The idea comes from this blog post: [Nothing solves everything – PowerShell and other technologies](http://www.leeholmes.com/blog/2006/05/11/nothing-solves-everything-%e2%80%93-powershell-and-other-technologies/) Here is my version of this script. It calls a batch file (or any *native* command) and propagates its envi...
4351282
How to generate a sequence of dates given starting and ending dates using AWK of BASH scripts?
26
2010-12-04 00:58:33
<p>I have a data set with the following format</p> <p>The first and second fields denote the dates (M/D/YYYY) of starting and ending of a study. </p> <p>How one expand the data into the desired output format, taking into account the leap years using AWK or BASH scripts?</p> <p>Your help is very much appreciated.</p...
24,766
488,655
2021-01-02 16:41:22
4,351,613
13
2010-12-04 02:32:16
26,428
2017-10-16 22:02:52
https://stackoverflow.com/q/4351282
https://stackoverflow.com/a/4351613
<p>If you have <code>gawk</code>:</p> <pre><code>#!/usr/bin/gawk -f { split($1,s,"/") split($2,e,"/") st=mktime(s[3] " " s[1] " " s[2] " 0 0 0") et=mktime(e[3] " " e[1] " " e[2] " 0 0 0") for (i=et;i&gt;=st;i-=60*60*24) print strftime("%m/%d/%Y",i) } </code></pre> <p>Demonstration:</p> <pre><code...
<p>If you have <code>gawk</code>:</p> <pre><code>#!/usr/bin/gawk -f { split($1,s,"/") split($2,e,"/") st=mktime(s[3] " " s[1] " " s[2] " 0 0 0") et=mktime(e[3] " " e[1] " " e[2] " 0 0 0") for (i=et;i&gt;=st;i-=60*60*24) print strftime("%m/%d/%Y",i) } </code></pre> <p>Demonstration:</p> <pre><code...
34, 387, 990
awk, bash, unix
<h1>How to generate a sequence of dates given starting and ending dates using AWK of BASH scripts?</h1> <p>I have a data set with the following format</p> <p>The first and second fields denote the dates (M/D/YYYY) of starting and ending of a study. </p> <p>How one expand the data into the desired output format, taki...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,072
bash
# How to generate a sequence of dates given starting and ending dates using AWK of BASH scripts? I have a data set with the following format The first and second fields denote the dates (M/D/YYYY) of starting and ending of a study. How one expand the data into the desired output format, taking into account the leap ...
If you have `gawk`: ``` #!/usr/bin/gawk -f { split($1,s,"/") split($2,e,"/") st=mktime(s[3] " " s[1] " " s[2] " 0 0 0") et=mktime(e[3] " " e[1] " " e[2] " 0 0 0") for (i=et;i>=st;i-=60*60*24) print strftime("%m/%d/%Y",i) } ``` Demonstration: ``` ./daterange.awk inputfile ``` Output: ``` 07/07/2...
21759562
Extract lines between two line numbers in shell
25
2014-02-13 16:14:17
<p>How is this possible in shell using <strong>sed</strong> or any other filter</p> <p>Lets say that i have two specific line numbers in two variables <code>$line1</code> and <code>$line2</code> and i want to extract lines between these two lines like this</p> <pre><code>cat my_file_path | command $line1 $line2 </code>...
53,413
2,250,162
2025-08-18 20:42:52
21,759,654
13
2014-02-13 16:18:00
164,835
2014-02-13 16:18:00
https://stackoverflow.com/q/21759562
https://stackoverflow.com/a/21759654
<p>without testing:</p> <pre><code>awk -v s="$line1" -v e="$line2" 'NR&gt;s&amp;&amp;NR&lt;e' file </code></pre> <p>you can control the "inclusive/exclusive" with <code>&gt;= or &lt;=</code></p> <p>if you want to make it safe for leading/trailing spaces in your shell var:</p> <pre><code> awk -v s="$line1" -v e="$li...
<p>without testing:</p> <pre><code>awk -v s="$line1" -v e="$line2" 'NR&gt;s&amp;&amp;NR&lt;e' file </code></pre> <p>you can control the "inclusive/exclusive" with <code>&gt;= or &lt;=</code></p> <p>if you want to make it safe for leading/trailing spaces in your shell var:</p> <pre><code> awk -v s="$line1" -v e="$li...
387, 390, 5282
bash, sed, shell
<h1>Extract lines between two line numbers in shell</h1> <p>How is this possible in shell using <strong>sed</strong> or any other filter</p> <p>Lets say that i have two specific line numbers in two variables <code>$line1</code> and <code>$line2</code> and i want to extract lines between these two lines like this</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,073
bash
# Extract lines between two line numbers in shell How is this possible in shell using **sed** or any other filter Lets say that i have two specific line numbers in two variables `$line1` and `$line2` and i want to extract lines between these two lines like this ``` cat my_file_path | command $line1 $line2 ``` Examp...
without testing: ``` awk -v s="$line1" -v e="$line2" 'NR>s&&NR<e' file ``` you can control the "inclusive/exclusive" with `>= or <=` if you want to make it safe for leading/trailing spaces in your shell var: ``` awk -v s="$line1" -v e="$line2" 'NR>1*s&&NR<1*e' file ```
5734365
Run a command at a specific time
25
2011-04-20 17:40:04
<p>I'm trying to run a command at a specific time. I've looked at the "at" command, but I don't know how to get it working...</p> <p>Here's what I do:</p> <pre><code>at 1843 (Enter) php /run/this/script.php (Ctrl+D) </code></pre> <p>But how do I do this in a bash script? I mean, I need to press enter and "Ctrl+D" to...
57,131
395,974
2014-05-07 09:55:12
5,734,409
13
2011-04-20 17:43:27
182,668
2011-04-20 18:01:58
https://stackoverflow.com/q/5734365
https://stackoverflow.com/a/5734409
<p>You could try this:</p> <pre><code>at 1843 &lt;&lt;_EOF_ php /run/this/script.php _EOF_ </code></pre> <p><em>edit</em> if what you want to do is run Firefox, try this:</p> <pre><code>at 1843 &lt;&lt;_EOF_ DISPLAY=:0.0 /usr/bin/firefox _EOF_ </code></pre>
<p>You could try this:</p> <pre><code>at 1843 &lt;&lt;_EOF_ php /run/this/script.php _EOF_ </code></pre> <p><em>edit</em> if what you want to do is run Firefox, try this:</p> <pre><code>at 1843 &lt;&lt;_EOF_ DISPLAY=:0.0 /usr/bin/firefox _EOF_ </code></pre>
58, 387, 1796, 90171
at-job, bash, command, linux
<h1>Run a command at a specific time</h1> <p>I'm trying to run a command at a specific time. I've looked at the "at" command, but I don't know how to get it working...</p> <p>Here's what I do:</p> <pre><code>at 1843 (Enter) php /run/this/script.php (Ctrl+D) </code></pre> <p>But how do I do this in a bash script? I m...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,074
bash
# Run a command at a specific time I'm trying to run a command at a specific time. I've looked at the "at" command, but I don't know how to get it working... Here's what I do: ``` at 1843 (Enter) php /run/this/script.php (Ctrl+D) ``` But how do I do this in a bash script? I mean, I need to press enter and "Ctrl+D" ...
You could try this: ``` at 1843 <<_EOF_ php /run/this/script.php _EOF_ ``` *edit* if what you want to do is run Firefox, try this: ``` at 1843 <<_EOF_ DISPLAY=:0.0 /usr/bin/firefox _EOF_ ```
63622336
Unable to connect to the server: dial tcp: lookup <Server Location>: no such host
24
2020-08-27 18:41:16
<p>I'm beginning to build out a kubernetes cluster for our applications. We are using Azure for cloud services, so my K8s cluster is built using AKS. The AKs cluster was created using the portal interface for Azure. It has one node, and I am attempting to create a pod with a single container to deploy to the node. Wher...
101,163
13,899,576
2023-04-09 18:40:28
69,208,521
13
2021-09-16 12:33:34
5,545,755
2022-06-22 06:02:41
https://stackoverflow.com/q/63622336
https://stackoverflow.com/a/69208521
<p>As of now, the aks run command adds a <a href="https://learn.microsoft.com/en-gb/azure/aks/private-clusters#options-for-connecting-to-the-private-cluster" rel="nofollow noreferrer">fourth option</a> to connect to private clusters extending <a href="https://stackoverflow.com/users/7001697/darius">@Darius</a>'s <a hre...
<p>As of now, the aks run command adds a <a href="https://learn.microsoft.com/en-gb/azure/aks/private-clusters#options-for-connecting-to-the-private-cluster" rel="nofollow noreferrer">fourth option</a> to connect to private clusters extending <a href="https://stackoverflow.com/users/7001697/darius">@Darius</a>'s <a hre...
526, 14158, 106338, 120010, 131335
azure, azure-aks, kubectl, kubernetes, powershell
<h1>Unable to connect to the server: dial tcp: lookup <Server Location>: no such host</h1> <p>I'm beginning to build out a kubernetes cluster for our applications. We are using Azure for cloud services, so my K8s cluster is built using AKS. The AKs cluster was created using the portal interface for Azure. It has one no...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,075
bash
# Unable to connect to the server: dial tcp: lookup : no such host I'm beginning to build out a kubernetes cluster for our applications. We are using Azure for cloud services, so my K8s cluster is built using AKS. The AKs cluster was created using the portal interface for Azure. It has one node, and I am attempting to...
As of now, the aks run command adds a [fourth option](https://learn.microsoft.com/en-gb/azure/aks/private-clusters#options-for-connecting-to-the-private-cluster) to connect to private clusters extending [@Darius](https://stackoverflow.com/users/7001697/darius)'s [three options](https://stackoverflow.com/a/66002325) pos...
43904684
List files with path and file size only in Command Line
24
2017-05-11 00:35:29
<p><em>Windows Command Line (or maybe PowerShell).</em></p> <p>How can I list all files, recursively, with full path and filesize, but without anything else and export to a .txt file. Much preferably a code that works for whichever current directory I am in with the Command Line (so does not require manual entering of...
94,010
3,026,965
2020-07-10 14:40:15
43,905,575
13
2017-05-11 02:36:39
1,625,308
2017-05-11 02:36:39
https://stackoverflow.com/q/43904684
https://stackoverflow.com/a/43905575
<pre><code>Get-ChildItem -Recurse | select FullName,Length | Format-Table -HideTableHeaders | Out-File filelist.txt </code></pre>
<pre><code>Get-ChildItem -Recurse | select FullName,Length | Format-Table -HideTableHeaders | Out-File filelist.txt </code></pre>
64, 526, 1062, 1231, 9938
command-line, command-prompt, filenames, powershell, windows
<h1>List files with path and file size only in Command Line</h1> <p><em>Windows Command Line (or maybe PowerShell).</em></p> <p>How can I list all files, recursively, with full path and filesize, but without anything else and export to a .txt file. Much preferably a code that works for whichever current directory I am...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,076
bash
# List files with path and file size only in Command Line *Windows Command Line (or maybe PowerShell).* How can I list all files, recursively, with full path and filesize, but without anything else and export to a .txt file. Much preferably a code that works for whichever current directory I am in with the Command Li...
``` Get-ChildItem -Recurse | select FullName,Length | Format-Table -HideTableHeaders | Out-File filelist.txt ```
22233702
How to download the SSL certificate from a website using PowerShell?
24
2014-03-06 19:07:54
<p>I want to download the SSL certificate from, say <a href="https://www.outlook.com" rel="noreferrer">https://www.outlook.com</a>, using PowerShell. Is it possible? Could someone help me?</p>
72,155
3,389,719
2025-10-02 09:57:37
22,236,908
13
2014-03-06 21:56:47
1,105,996
2014-03-06 21:56:47
https://stackoverflow.com/q/22233702
https://stackoverflow.com/a/22236908
<p>You should be able to get the public key by using the <code>ServicePoint</code> property on the <code>HttpWebRequest</code> object. This necessary information will be populated once we have made a http request to the site in question.</p> <p>If the request is made to a site which has an untrusted certificate the Ge...
<p>You should be able to get the public key by using the <code>ServicePoint</code> property on the <code>HttpWebRequest</code> object. This necessary information will be populated once we have made a http request to the site in question.</p> <p>If the request is made to a site which has an untrusted certificate the Ge...
526, 641, 14423
powershell, ssl, ssl-certificate
<h1>How to download the SSL certificate from a website using PowerShell?</h1> <p>I want to download the SSL certificate from, say <a href="https://www.outlook.com" rel="noreferrer">https://www.outlook.com</a>, using PowerShell. Is it possible? Could someone help me?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,077
bash
# How to download the SSL certificate from a website using PowerShell? I want to download the SSL certificate from, say <https://www.outlook.com>, using PowerShell. Is it possible? Could someone help me?
You should be able to get the public key by using the `ServicePoint` property on the `HttpWebRequest` object. This necessary information will be populated once we have made a http request to the site in question. If the request is made to a site which has an untrusted certificate the GetResponse method will throw an e...
3490810
Powershell File Compare
24
2010-08-16 05:30:19
<p>I am using a PowerShell script to move some files around on some servers. I want to test if a file I am going to move already exists in the destination. Not just a file with the same name.</p> <p>I thought</p> <p><code>Compare-Object $File1 $File2</code><br> Should do it but no matter what the files are it always ...
34,004
421,389
2020-03-21 10:08:39
3,496,439
13
2010-08-16 19:10:30
8,718
2010-08-16 19:10:30
https://stackoverflow.com/q/3490810
https://stackoverflow.com/a/3496439
<p>I guess it's going to depend on your definition of "The same"</p> <pre><code>Compare-Object (ls Source\Test.*) (ls Dest\Test.*) -Property Name, Length, LastWriteTime </code></pre> <p>That will compare the actual FILE objects by name, length, and modified date. Adding -IncludeEqual will result in also showing ones...
<p>I guess it's going to depend on your definition of "The same"</p> <pre><code>Compare-Object (ls Source\Test.*) (ls Dest\Test.*) -Property Name, Length, LastWriteTime </code></pre> <p>That will compare the actual FILE objects by name, length, and modified date. Adding -IncludeEqual will result in also showing ones...
526
powershell
<h1>Powershell File Compare</h1> <p>I am using a PowerShell script to move some files around on some servers. I want to test if a file I am going to move already exists in the destination. Not just a file with the same name.</p> <p>I thought</p> <p><code>Compare-Object $File1 $File2</code><br> Should do it but no mat...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,078
bash
# Powershell File Compare I am using a PowerShell script to move some files around on some servers. I want to test if a file I am going to move already exists in the destination. Not just a file with the same name. I thought `Compare-Object $File1 $File2` Should do it but no matter what the files are it always ret...
I guess it's going to depend on your definition of "The same" ``` Compare-Object (ls Source\Test.*) (ls Dest\Test.*) -Property Name, Length, LastWriteTime ``` That will compare the actual FILE objects by name, length, and modified date. Adding -IncludeEqual will result in also showing ones that are the same in both p...
1617724
How to replace newlines with tab characters?
24
2009-10-24 11:23:50
<p>I have pattern like below</p> <pre><code>hi hello hallo greetings salutations no more hello for you </code></pre> <p>I am trying to replace all newlines with tab using the following command</p> <pre><code>sed -e "s_/\n_/\t_g" </code></pre> <p>but it's not working.</p> <p>Could anybody please help? I'm looking f...
53,302
134,713
2025-06-04 12:08:22
1,617,769
13
2009-10-24 11:42:40
131,527
2009-10-24 11:42:40
https://stackoverflow.com/q/1617724
https://stackoverflow.com/a/1617769
<p>not sure about output you want</p> <pre><code># awk -vRS="\n" -vORS="\t" '1' file hi hello hallo greetings salutations no more hello for you </code></pre>
<p>not sure about output you want</p> <pre><code># awk -vRS="\n" -vORS="\t" '1' file hi hello hallo greetings salutations no more hello for you </code></pre>
34, 390, 990, 5282
awk, sed, shell, unix
<h1>How to replace newlines with tab characters?</h1> <p>I have pattern like below</p> <pre><code>hi hello hallo greetings salutations no more hello for you </code></pre> <p>I am trying to replace all newlines with tab using the following command</p> <pre><code>sed -e "s_/\n_/\t_g" </code></pre> <p>but it's not wor...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,079
bash
# How to replace newlines with tab characters? I have pattern like below ``` hi hello hallo greetings salutations no more hello for you ``` I am trying to replace all newlines with tab using the following command ``` sed -e "s_/\n_/\t_g" ``` but it's not working. Could anybody please help? I'm looking for a solut...
not sure about output you want ``` # awk -vRS="\n" -vORS="\t" '1' file hi hello hallo greetings salutations no more hello for you ```
18645759
tail-like continuous ls (file list)
23
2013-09-05 20:52:55
<p>I am monitoring the new files created in a folder in linux. Every now and then I issue an "ls -ltr" in it. But I wish there was a program/script that would automatically print it, and only the latest entries. I did a short while loop to list it, but it would repeat the entries that were not new and it would keep my ...
20,563
2,193,235
2025-11-01 17:12:12
18,645,921
13
2013-09-05 21:03:12
null
2013-09-05 21:03:12
https://stackoverflow.com/q/18645759
https://stackoverflow.com/a/18645921
<p>If you have access to <code>inotifywait</code> (available from the inotify-tools package if you are on Debian/Ubuntu) you could write a script like this:</p> <pre><code>#!/bin/bash WATCH=/tmp inotifywait -q -m -e create --format %f $WATCH | while read event do ls -ltr $WATCH/$event done </code></pre> <p>This...
<p>If you have access to <code>inotifywait</code> (available from the inotify-tools package if you are on Debian/Ubuntu) you could write a script like this:</p> <pre><code>#!/bin/bash WATCH=/tmp inotifywait -q -m -e create --format %f $WATCH | while read event do ls -ltr $WATCH/$event done </code></pre> <p>This...
58, 390, 3589
linux, ls, shell
<h1>tail-like continuous ls (file list)</h1> <p>I am monitoring the new files created in a folder in linux. Every now and then I issue an "ls -ltr" in it. But I wish there was a program/script that would automatically print it, and only the latest entries. I did a short while loop to list it, but it would repeat the en...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,080
bash
# tail-like continuous ls (file list) I am monitoring the new files created in a folder in linux. Every now and then I issue an "ls -ltr" in it. But I wish there was a program/script that would automatically print it, and only the latest entries. I did a short while loop to list it, but it would repeat the entries tha...
If you have access to `inotifywait` (available from the inotify-tools package if you are on Debian/Ubuntu) you could write a script like this: ``` #!/bin/bash WATCH=/tmp inotifywait -q -m -e create --format %f $WATCH | while read event do ls -ltr $WATCH/$event done ``` This is a one-liner that won't give you th...
2732
Shell scripting input redirection oddities
23
2008-08-05 19:26:00
<p>Can anyone explain this behavior? Running:</p> <pre><code>#!/bin/sh echo "hello world" | read var1 var2 echo $var1 echo $var2 </code></pre> <p>results in nothing being ouput, while:</p> <pre><code>#!/bin/sh echo "hello world" &gt; test.file read var1 var2 &lt; test.file echo $var1 echo $var2 </code></pre> <p>pro...
6,748
75
2021-03-27 14:59:27
11,668,996
13
2012-07-26 12:10:13
1,126,841
2012-07-26 12:10:13
https://stackoverflow.com/q/2732
https://stackoverflow.com/a/11668996
<p>A recent addition to <code>bash</code> is the <code>lastpipe</code> option, which allows the last command in a pipeline to run in the current shell, not a subshell, when job control is deactivated.</p> <pre><code>#!/bin/bash set +m # Deactiveate job control shopt -s lastpipe echo "hello world" | read var1 var2...
<p>A recent addition to <code>bash</code> is the <code>lastpipe</code> option, which allows the last command in a pipeline to run in the current shell, not a subshell, when job control is deactivated.</p> <pre><code>#!/bin/bash set +m # Deactiveate job control shopt -s lastpipe echo "hello world" | read var1 var2...
137448
dash-shell
<h1>Shell scripting input redirection oddities</h1> <p>Can anyone explain this behavior? Running:</p> <pre><code>#!/bin/sh echo "hello world" | read var1 var2 echo $var1 echo $var2 </code></pre> <p>results in nothing being ouput, while:</p> <pre><code>#!/bin/sh echo "hello world" &gt; test.file read var1 var2 &lt; t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,081
bash
# Shell scripting input redirection oddities Can anyone explain this behavior? Running: ``` #!/bin/sh echo "hello world" | read var1 var2 echo $var1 echo $var2 ``` results in nothing being ouput, while: ``` #!/bin/sh echo "hello world" > test.file read var1 var2 < test.file echo $var1 echo $var2 ``` produces the e...
A recent addition to `bash` is the `lastpipe` option, which allows the last command in a pipeline to run in the current shell, not a subshell, when job control is deactivated. ``` #!/bin/bash set +m # Deactiveate job control shopt -s lastpipe echo "hello world" | read var1 var2 echo $var1 echo $var2 ``` will ind...
68573901
How do I raise X to the power of Y in Powershell?
22
2021-07-29 10:00:22
<p>I (apparently wrongly) assumed there would be a built-in power <code>operator</code> or <code>function</code> in Powershell, but I it seems there is not, or is there?</p>
20,391
4,898,202
2021-07-29 10:21:29
68,573,939
13
2021-07-29 10:02:46
4,898,202
2021-07-29 10:02:46
https://stackoverflow.com/q/68573901
https://stackoverflow.com/a/68573939
<p>Never mind, I found the answer:</p> <pre><code>[Math]::Pow(256,3) # 256 to the power of 3 (= ~16.7 million) </code></pre>
<p>Never mind, I found the answer:</p> <pre><code>[Math]::Pow(256,3) # 256 to the power of 3 (= ~16.7 million) </code></pre>
259, 526, 14881, 20240
exponent, exponentiation, math, powershell
<h1>How do I raise X to the power of Y in Powershell?</h1> <p>I (apparently wrongly) assumed there would be a built-in power <code>operator</code> or <code>function</code> in Powershell, but I it seems there is not, or is there?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,082
bash
# How do I raise X to the power of Y in Powershell? I (apparently wrongly) assumed there would be a built-in power `operator` or `function` in Powershell, but I it seems there is not, or is there?
Never mind, I found the answer: ``` [Math]::Pow(256,3) # 256 to the power of 3 (= ~16.7 million) ```
35195221
List process for current user
22
2016-02-04 07:43:14
<p>As an administrator I can get a users processes by running this</p> <p><code>Get-Process -IncludeUserName | Where UserName -match test</code></p> <p>But as a non-administrator I can't use <code>-IncludeUserName</code> because &quot;The 'IncludeUserName' parameter requires elevated user rights&quot;.</p> <p>So if I'm...
45,850
2,072,145
2025-11-24 00:05:09
35,195,927
13
2016-02-04 08:25:52
311,712
2016-02-04 08:25:52
https://stackoverflow.com/q/35195221
https://stackoverflow.com/a/35195927
<p>You can do that through WMI. Here is an excerpt of an article you can find <a href="https://p0w3rsh3ll.wordpress.com/2013/10/30/find-the-owner-of-a-process/" rel="noreferrer">here</a>.</p> <pre><code>$View = @( @{l='Handles';e={$_.HandleCount}}, @{l='NPM(K)';e={ (Get-Process -Id $_.ProcessId).NonpagedSystemMemory...
<p>You can do that through WMI. Here is an excerpt of an article you can find <a href="https://p0w3rsh3ll.wordpress.com/2013/10/30/find-the-owner-of-a-process/" rel="noreferrer">here</a>.</p> <pre><code>$View = @( @{l='Handles';e={$_.HandleCount}}, @{l='NPM(K)';e={ (Get-Process -Id $_.ProcessId).NonpagedSystemMemory...
526, 5910
powershell, process
<h1>List process for current user</h1> <p>As an administrator I can get a users processes by running this</p> <p><code>Get-Process -IncludeUserName | Where UserName -match test</code></p> <p>But as a non-administrator I can't use <code>-IncludeUserName</code> because &quot;The 'IncludeUserName' parameter requires eleva...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,083
bash
# List process for current user As an administrator I can get a users processes by running this `Get-Process -IncludeUserName | Where UserName -match test` But as a non-administrator I can't use `-IncludeUserName` because "The 'IncludeUserName' parameter requires elevated user rights". So if I'm logged on as the us...
You can do that through WMI. Here is an excerpt of an article you can find [here](https://p0w3rsh3ll.wordpress.com/2013/10/30/find-the-owner-of-a-process/). ``` $View = @( @{l='Handles';e={$_.HandleCount}}, @{l='NPM(K)';e={ (Get-Process -Id $_.ProcessId).NonpagedSystemMemorySize/1KB -as [int]}}, @{l='PM(K)';e={ $_....
9800989
Copy every file of entire directory structure into base path of another
22
2012-03-21 08:29:44
<p>I have a directory-tree with a lot of files in it. I'd like to copy all of those files into one new directory, but with all files located in the base of the folder.</p> <p>So I have something like this:</p> <pre><code> images ├── avatar.png ├── bg.jpg ├── checkbox.png ├── cross.png ├── datat...
13,851
727,341
2016-03-08 02:10:40
9,801,972
13
2012-03-21 09:43:06
909,233
2016-03-08 02:10:40
https://stackoverflow.com/q/9800989
https://stackoverflow.com/a/9801972
<p>you are looking for ways to flatten the directory</p> <pre><code>find /images -iname '*.jpg' -exec cp --target-directory /newfolder/ {} \; </code></pre> <p><code>find</code> all files <code>iname</code> in case insensitive name mode.<br> <code>cp</code> copy once to <code>--target-directory</code> named <code>/new...
<p>you are looking for ways to flatten the directory</p> <pre><code>find /images -iname '*.jpg' -exec cp --target-directory /newfolder/ {} \; </code></pre> <p><code>find</code> all files <code>iname</code> in case insensitive name mode.<br> <code>cp</code> copy once to <code>--target-directory</code> named <code>/new...
58, 218, 387, 10193, 25299
bash, cp, directory, find, linux
<h1>Copy every file of entire directory structure into base path of another</h1> <p>I have a directory-tree with a lot of files in it. I'd like to copy all of those files into one new directory, but with all files located in the base of the folder.</p> <p>So I have something like this:</p> <pre><code> images ├...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,084
bash
# Copy every file of entire directory structure into base path of another I have a directory-tree with a lot of files in it. I'd like to copy all of those files into one new directory, but with all files located in the base of the folder. So I have something like this: ``` images ├── avatar.png ├── bg.jp...
you are looking for ways to flatten the directory ``` find /images -iname '*.jpg' -exec cp --target-directory /newfolder/ {} \; ``` `find` all files `iname` in case insensitive name mode. `cp` copy once to `--target-directory` named `/newfolder/`. `{}` expand the list from `find` into the form of `/dir/file.jpg /...
6238331
Emacs shell scripts - how to put initial options into the script?
22
2011-06-04 17:34:05
<p>Inspired by Stack&nbsp;Overflow question <a href="https://stackoverflow.com/questions/2879746/idomatic-batch-processing-of-text-in-emacs">Idomatic batch processing of text in Emacs?</a> I tried out an Emacs shell script with the following headline:</p> <pre><code>#!/usr/bin/emacs --script </code></pre> <p>I put s...
4,433
783,306
2022-07-18 02:55:14
6,240,904
13
2011-06-05 03:50:47
324,105
2012-09-13 10:06:02
https://stackoverflow.com/q/6238331
https://stackoverflow.com/a/6240904
<p>You could always change <code>#!/usr/bin/emacs</code> to something like <code>#!/home/thorsten/bin/emacs-no-site-file</code>, and set that up as:</p> <pre><code>#!/bin/sh exec /usr/bin/emacs --no-site-file "$@" </code></pre> <p>If this doesn't work for you, or if you wish your script to be portable, then see <a hr...
<p>You could always change <code>#!/usr/bin/emacs</code> to something like <code>#!/home/thorsten/bin/emacs-no-site-file</code>, and set that up as:</p> <pre><code>#!/bin/sh exec /usr/bin/emacs --no-site-file "$@" </code></pre> <p>If this doesn't work for you, or if you wish your script to be portable, then see <a hr...
371, 390, 3246, 31134
command-line-arguments, elisp, emacs, shell
<h1>Emacs shell scripts - how to put initial options into the script?</h1> <p>Inspired by Stack&nbsp;Overflow question <a href="https://stackoverflow.com/questions/2879746/idomatic-batch-processing-of-text-in-emacs">Idomatic batch processing of text in Emacs?</a> I tried out an Emacs shell script with the following hea...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,085
bash
# Emacs shell scripts - how to put initial options into the script? Inspired by Stack Overflow question [Idomatic batch processing of text in Emacs?](https://stackoverflow.com/questions/2879746/idomatic-batch-processing-of-text-in-emacs) I tried out an Emacs shell script with the following headline: ``` #!/usr/bin/em...
You could always change `#!/usr/bin/emacs` to something like `#!/home/thorsten/bin/emacs-no-site-file`, and set that up as: ``` #!/bin/sh exec /usr/bin/emacs --no-site-file "$@" ``` If this doesn't work for you, or if you wish your script to be portable, then see [Gilles' answer below](https://stackoverflow.com/quest...
1210942
catching return code of a command with "invoke-command" - Powershell 2
22
2009-07-31 06:23:56
<p>I am using "invoke-command" to execute a script on a remote machine.</p> <pre><code>invoke-command -computername &lt;server_name&gt; -scriptblock {command to execute the script} </code></pre> <p>My script returns "-1" when there are any errors. So, I wanted to ensure that script has executed successfully by checki...
53,713
null
2023-04-19 13:08:59
1,211,693
13
2009-07-31 09:57:35
73,070
2011-03-10 20:19:41
https://stackoverflow.com/q/1210942
https://stackoverflow.com/a/1211693
<p>I think if you run a command that way on another server there is no way you can get at the return code of your script there. This is because <code>Invoke-Command</code> simply runs one command on the remote machine, probably within a single temporary session and you can't connect to that session again.</p> <p>What ...
<p>I think if you run a command that way on another server there is no way you can get at the return code of your script there. This is because <code>Invoke-Command</code> simply runs one command on the remote machine, probably within a single temporary session and you can't connect to that session again.</p> <p>What ...
526, 9206
powershell, return-value
<h1>catching return code of a command with "invoke-command" - Powershell 2</h1> <p>I am using "invoke-command" to execute a script on a remote machine.</p> <pre><code>invoke-command -computername &lt;server_name&gt; -scriptblock {command to execute the script} </code></pre> <p>My script returns "-1" when there are an...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,086
bash
# catching return code of a command with "invoke-command" - Powershell 2 I am using "invoke-command" to execute a script on a remote machine. ``` invoke-command -computername <server_name> -scriptblock {command to execute the script} ``` My script returns "-1" when there are any errors. So, I wanted to ensure that s...
I think if you run a command that way on another server there is no way you can get at the return code of your script there. This is because `Invoke-Command` simply runs one command on the remote machine, probably within a single temporary session and you can't connect to that session again. What you *can* do, however...
128853
How do I run a command in a loop until I see some string in stdout?
22
2008-09-24 18:15:11
<p>I'm sure there's some trivial one-liner with perl, ruby, bash whatever that would let me run a command in a loop until I observe some string in stdout, then stop. Ideally, I'd like to capture stdout as well, but if it's going to console, that might be enough. </p> <p>The particular environment in question at the ...
23,004
7,671
2015-04-20 06:11:02
128,905
13
2008-09-24 18:26:22
872
2008-09-24 18:26:22
https://stackoverflow.com/q/128853
https://stackoverflow.com/a/128905
<p>In Perl:</p> <pre><code>#!/usr/local/bin/perl -w if (@ARGV != 2) { print "Usage: watchit.pl &lt;cmd&gt; &lt;str&gt;\n"; exit(1); } $cmd = $ARGV[0]; $str = $ARGV[1]; while (1) { my $output = `$cmd`; print $output; # or dump to file if desired if ($output =~ /$str/) { exit(0); }...
<p>In Perl:</p> <pre><code>#!/usr/local/bin/perl -w if (@ARGV != 2) { print "Usage: watchit.pl &lt;cmd&gt; &lt;str&gt;\n"; exit(1); } $cmd = $ARGV[0]; $str = $ARGV[1]; while (1) { my $output = `$cmd`; print $output; # or dump to file if desired if ($output =~ /$str/) { exit(0); }...
58, 387, 390
bash, linux, shell
<h1>How do I run a command in a loop until I see some string in stdout?</h1> <p>I'm sure there's some trivial one-liner with perl, ruby, bash whatever that would let me run a command in a loop until I observe some string in stdout, then stop. Ideally, I'd like to capture stdout as well, but if it's going to console, t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,087
bash
# How do I run a command in a loop until I see some string in stdout? I'm sure there's some trivial one-liner with perl, ruby, bash whatever that would let me run a command in a loop until I observe some string in stdout, then stop. Ideally, I'd like to capture stdout as well, but if it's going to console, that might ...
In Perl: ``` #!/usr/local/bin/perl -w if (@ARGV != 2) { print "Usage: watchit.pl <cmd> <str>\n"; exit(1); } $cmd = $ARGV[0]; $str = $ARGV[1]; while (1) { my $output = `$cmd`; print $output; # or dump to file if desired if ($output =~ /$str/) { exit(0); } } ``` Example: ``` [bas...
42789273
bash: choose default from case when enter is pressed in a "select" prompt
21
2017-03-14 14:51:45
<p>I'm prompting questions in a bash script like this:</p> <pre><code>optionsAudits=("Yep" "Nope") echo "Include audits?" select opt in "${optionsAudits[@]}"; do case $REPLY in 1) includeAudits=true; break ;; 2) includeAudits=false; break ;; "\n") echo "You pressed e...
14,851
163,341
2025-03-14 11:47:57
42,790,579
13
2017-03-14 15:49:23
45,375
2025-03-14 11:47:57
https://stackoverflow.com/q/42789273
https://stackoverflow.com/a/42790579
<p>To complement <a href="https://stackoverflow.com/a/42790075/45375">Aserre's helpful answer</a>, which explains the problem with your code and offers an effective workaround, with <strong>background information and a generic, reusable custom <code>select</code> implementation that allows empty input</strong>:</p> <hr...
<p>To complement <a href="https://stackoverflow.com/a/42790075/45375">Aserre's helpful answer</a>, which explains the problem with your code and offers an effective workaround, with <strong>background information and a generic, reusable custom <code>select</code> implementation that allows empty input</strong>:</p> <hr...
387, 3222, 4063
bash, interactive, user-input
<h1>bash: choose default from case when enter is pressed in a "select" prompt</h1> <p>I'm prompting questions in a bash script like this:</p> <pre><code>optionsAudits=("Yep" "Nope") echo "Include audits?" select opt in "${optionsAudits[@]}"; do case $REPLY in 1) includeAudits=true; break ;;...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,088
bash
# bash: choose default from case when enter is pressed in a "select" prompt I'm prompting questions in a bash script like this: ``` optionsAudits=("Yep" "Nope") echo "Include audits?" select opt in "${optionsAudits[@]}"; do case $REPLY in 1) includeAudits=true; break ;; 2) incl...
To complement [Aserre's helpful answer](https://stackoverflow.com/a/42790075/45375), which explains the problem with your code and offers an effective workaround, with **background information and a generic, reusable custom `select` implementation that allows empty input**: --- ### Background information To spell it...
42355649
Array Types In Powershell - System.Object[] vs. arrays with specific types
21
2017-02-20 22:53:13
<p>Why does caling <code>GetType().Name</code> on an array of strings return <code>Object[]</code> and not <code>String[]</code>? This seems to happen with any element type, for example <code>Import-Csv</code> will give you an <code>Object[]</code> but each element is a <code>PSCustomObject</code>.</p> <p>Here's an e...
61,888
2,063,755
2023-04-22 21:32:04
42,355,869
13
2017-02-20 23:13:14
2,203,589
2017-02-21 21:20:57
https://stackoverflow.com/q/42355649
https://stackoverflow.com/a/42355869
<p>Because you have not specified the data type of the array explicitly. </p> <p>For instance, assigning an integer to <code>$x[1]</code> would work, because the array's type is <code>Object[]</code>.</p> <p>If you specify a data type while constructing the array, you won't be able to assign values of an incompatible...
<p>Because you have not specified the data type of the array explicitly. </p> <p>For instance, assigning an integer to <code>$x[1]</code> would work, because the array's type is <code>Object[]</code>.</p> <p>If you specify a data type while constructing the array, you won't be able to assign values of an incompatible...
114, 343, 526, 1926, 12095
arrays, coercion, collections, powershell, types
<h1>Array Types In Powershell - System.Object[] vs. arrays with specific types</h1> <p>Why does caling <code>GetType().Name</code> on an array of strings return <code>Object[]</code> and not <code>String[]</code>? This seems to happen with any element type, for example <code>Import-Csv</code> will give you an <code>Ob...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,089
bash
# Array Types In Powershell - System.Object[] vs. arrays with specific types Why does caling `GetType().Name` on an array of strings return `Object[]` and not `String[]`? This seems to happen with any element type, for example `Import-Csv` will give you an `Object[]` but each element is a `PSCustomObject`. Here's an ...
Because you have not specified the data type of the array explicitly. For instance, assigning an integer to `$x[1]` would work, because the array's type is `Object[]`. If you specify a data type while constructing the array, you won't be able to assign values of an incompatible type later: ``` C:\PS> [int[]] $myArra...
12141938
How to detect the last line in awk before END
21
2012-08-27 12:24:33
<p>I am trying to add last line to the file which I am creating. How is it possible to detect the last line of a file in awk before <code>END</code> ? I need to do this because the variables don't work in the <code>END</code> block, so I am trying to avoid using <code>END</code>. </p> <pre><code>awk ' { do some thing...
51,015
903,790
2022-02-06 20:50:01
12,142,183
13
2012-08-27 12:41:26
773,159
2012-08-27 12:41:26
https://stackoverflow.com/q/12141938
https://stackoverflow.com/a/12142183
<p>One option is to use <code>getline</code> function to process the file. It returns <code>1</code> on sucess, <code>0</code> on end of file and <code>-1</code> on an error.</p> <pre><code>awk ' FNR == 1 { ## Process first line. print FNR ": " $0; while ( getline == 1 ) { ## ...
<p>One option is to use <code>getline</code> function to process the file. It returns <code>1</code> on sucess, <code>0</code> on end of file and <code>-1</code> on an error.</p> <pre><code>awk ' FNR == 1 { ## Process first line. print FNR ": " $0; while ( getline == 1 ) { ## ...
390, 990, 9325
awk, line, shell
<h1>How to detect the last line in awk before END</h1> <p>I am trying to add last line to the file which I am creating. How is it possible to detect the last line of a file in awk before <code>END</code> ? I need to do this because the variables don't work in the <code>END</code> block, so I am trying to avoid using <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,090
bash
# How to detect the last line in awk before END I am trying to add last line to the file which I am creating. How is it possible to detect the last line of a file in awk before `END` ? I need to do this because the variables don't work in the `END` block, so I am trying to avoid using `END`. ``` awk ' { do some thing...
One option is to use `getline` function to process the file. It returns `1` on sucess, `0` on end of file and `-1` on an error. ``` awk ' FNR == 1 { ## Process first line. print FNR ": " $0; while ( getline == 1 ) { ## Process from second to last line. print FNR ":...
10031344
Why does this shell pipeline exit?
21
2012-04-05 15:18:00
<p>I have a shell pipeline for generating 10 characters password at random:</p> <pre><code>cat /dev/urandom | base64 | head -c 10 </code></pre> <p>My question is <code>cat /dev/urandom | base64</code> is an infinite output stream which will not exit by itself. But why does appending <code>head -c 10</code> make the w...
2,605
404,264
2024-03-20 08:35:59
10,044,006
13
2012-04-06 13:15:51
844,759
2024-03-20 08:35:59
https://stackoverflow.com/q/10031344
https://stackoverflow.com/a/10044006
<p>After <code>base64</code> outputs 10 bytes, <code>head</code> gets enough inputs and exits. When the former attempts to output more bytes, it will receive <a href="http://en.wikipedia.org/wiki/SIGPIPE" rel="nofollow noreferrer">SIGPIPE signal</a> and hence exits too。For the same reason, <code>cat</code> will exit in...
<p>After <code>base64</code> outputs 10 bytes, <code>head</code> gets enough inputs and exits. When the former attempts to output more bytes, it will receive <a href="http://en.wikipedia.org/wiki/SIGPIPE" rel="nofollow noreferrer">SIGPIPE signal</a> and hence exits too。For the same reason, <code>cat</code> will exit in...
34, 58, 387, 5813
bash, linux, pipe, unix
<h1>Why does this shell pipeline exit?</h1> <p>I have a shell pipeline for generating 10 characters password at random:</p> <pre><code>cat /dev/urandom | base64 | head -c 10 </code></pre> <p>My question is <code>cat /dev/urandom | base64</code> is an infinite output stream which will not exit by itself. But why does ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,091
bash
# Why does this shell pipeline exit? I have a shell pipeline for generating 10 characters password at random: ``` cat /dev/urandom | base64 | head -c 10 ``` My question is `cat /dev/urandom | base64` is an infinite output stream which will not exit by itself. But why does appending `head -c 10` make the whole pipeli...
After `base64` outputs 10 bytes, `head` gets enough inputs and exits. When the former attempts to output more bytes, it will receive [SIGPIPE signal](http://en.wikipedia.org/wiki/SIGPIPE) and hence exits too。For the same reason, `cat` will exit in turn.
2791069
How to use parallel execution in a shell script?
21
2010-05-07 19:09:20
<p>I have a C shell script that does something like this:</p> <pre><code>#!/bin/csh gcc example.c -o ex gcc combine.c -o combine ex file1 r1 &lt;-- 1 ex file2 r2 &lt;-- 2 ex file3 r3 &lt;-- 3 #... many more like the above combine r1 r2 r3 final \rm r1 r2 r3 </code></pre> <p>Is there some way I can make li...
44,401
113,124
2015-03-30 06:57:58
2,791,091
13
2010-05-07 19:13:51
13,422
2010-05-09 16:19:03
https://stackoverflow.com/q/2791069
https://stackoverflow.com/a/2791091
<p>Convert this into a Makefile with proper dependencies. Then you can use <code>make -j</code> to have Make run everything possible in parallel.</p> <p>Note that all the indents in a Makefile <em>must</em> be TABs. TAB shows Make where the commands to run are.</p> <p>Also note that this Makefile is now using GNU Mak...
<p>Convert this into a Makefile with proper dependencies. Then you can use <code>make -j</code> to have Make run everything possible in parallel.</p> <p>Note that all the indents in a Makefile <em>must</em> be TABs. TAB shows Make where the commands to run are.</p> <p>Also note that this Makefile is now using GNU Mak...
34, 353, 390, 2829
csh, parallel-processing, shell, unix
<h1>How to use parallel execution in a shell script?</h1> <p>I have a C shell script that does something like this:</p> <pre><code>#!/bin/csh gcc example.c -o ex gcc combine.c -o combine ex file1 r1 &lt;-- 1 ex file2 r2 &lt;-- 2 ex file3 r3 &lt;-- 3 #... many more like the above combine r1 r2 r3 final \rm ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,092
bash
# How to use parallel execution in a shell script? I have a C shell script that does something like this: ``` #!/bin/csh gcc example.c -o ex gcc combine.c -o combine ex file1 r1 <-- 1 ex file2 r2 <-- 2 ex file3 r3 <-- 3 #... many more like the above combine r1 r2 r3 final \rm r1 r2 r3 ``` Is there some w...
Convert this into a Makefile with proper dependencies. Then you can use `make -j` to have Make run everything possible in parallel. Note that all the indents in a Makefile *must* be TABs. TAB shows Make where the commands to run are. Also note that this Makefile is now using GNU Make extensions (the wildcard and subs...
56872978
Direnv not loading environment when shell starts in a directory with .envrc
20
2019-07-03 14:59:03
<p>Imagine I am in a shell with the working directory set to a directory that contains an <code>.envrc</code> file. When I now open up a new tab in my terminal emulator, a new shell is launched into the same working directory as the original shell.</p> <p>For some reason, the <code>.envrc</code> file is not loaded in ...
25,476
322,863
2022-02-22 08:01:45
56,973,231
13
2019-07-10 14:44:43
9,076,314
2020-03-11 13:01:12
https://stackoverflow.com/q/56872978
https://stackoverflow.com/a/56973231
<p>Under macOS Mojave (and probably older versions), saving a <code>.bashrc</code> has no effect. Instead, use a <code>.bash_profile</code>.</p>
<p>Under macOS Mojave (and probably older versions), saving a <code>.bashrc</code> has no effect. Instead, use a <code>.bash_profile</code>.</p>
369, 387, 9013, 113769, 126992
bash, direnv, environment-variables, macos, terminal.app
<h1>Direnv not loading environment when shell starts in a directory with .envrc</h1> <p>Imagine I am in a shell with the working directory set to a directory that contains an <code>.envrc</code> file. When I now open up a new tab in my terminal emulator, a new shell is launched into the same working directory as the or...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,093
bash
# Direnv not loading environment when shell starts in a directory with .envrc Imagine I am in a shell with the working directory set to a directory that contains an `.envrc` file. When I now open up a new tab in my terminal emulator, a new shell is launched into the same working directory as the original shell. For s...
Under macOS Mojave (and probably older versions), saving a `.bashrc` has no effect. Instead, use a `.bash_profile`.
42481726
how to modify conda 'source activate' ps1 behavior
20
2017-02-27 09:12:37
<p>my current bash ps1 is as follows:</p> <pre><code>bldred='\e[1;31m' # Red bldcyn='\e[1;36m' # Cyan bldwht='\e[1;37m' # White txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed export PS1="\n\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrst\]$ " </code></pre> <p>However, runnin...
14,704
3,943,552
2020-10-03 15:58:36
42,482,979
13
2017-02-27 10:11:11
3,943,552
2020-10-03 15:58:36
https://stackoverflow.com/q/42481726
https://stackoverflow.com/a/42482979
<p>The simplest solution I have found is to move the newline from <code>PS1</code> to <code>PROMPT_COMMAND</code>:</p> <pre><code>PROMPT_COMMAND=&quot;printf '\n'&quot; export PS1=&quot;\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrst\]$ &quot; </code></pre> <p>This allows <code>conda</code> to ...
<p>The simplest solution I have found is to move the newline from <code>PS1</code> to <code>PROMPT_COMMAND</code>:</p> <pre><code>PROMPT_COMMAND=&quot;printf '\n'&quot; export PS1=&quot;\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrst\]$ &quot; </code></pre> <p>This allows <code>conda</code> to ...
387, 53034, 96537
bash, conda, ps1
<h1>how to modify conda 'source activate' ps1 behavior</h1> <p>my current bash ps1 is as follows:</p> <pre><code>bldred='\e[1;31m' # Red bldcyn='\e[1;36m' # Cyan bldwht='\e[1;37m' # White txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed export PS1="\n\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,094
bash
# how to modify conda 'source activate' ps1 behavior my current bash ps1 is as follows: ``` bldred='\e[1;31m' # Red bldcyn='\e[1;36m' # Cyan bldwht='\e[1;37m' # White txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed export PS1="\n\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrs...
The simplest solution I have found is to move the newline from `PS1` to `PROMPT_COMMAND`: ``` PROMPT_COMMAND="printf '\n'" export PS1="\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrst\]$ " ``` This allows `conda` to maintain it's default `PS1` behavior all while separating bash commands with n...
30721317
How to merge two arrays in a zipper like fashion in Bash?
20
2015-06-09 00:46:27
<p>I am trying to merge two arrays into one in a zipper like fashion.</p> <pre><code>array1=(one three five seven) array2=(two four six eight) </code></pre> <p>How do I get this output?</p> <pre><code>one two three four five six seven eight </code></pre> <p>I have tried with nested for-loops but can't figure it out. I ...
12,765
434,533
2025-01-21 15:51:31
30,721,876
13
2015-06-09 02:00:45
2,911,710
2020-07-25 21:59:32
https://stackoverflow.com/q/30721317
https://stackoverflow.com/a/30721876
<p>Assuming both arrays are the same size,</p> <pre><code>unset result for (( i=0; i&lt;${#array1[*]}; ++i)); do result+=( &quot;${array1[$i]}&quot; &quot;${array2[$i]}&quot; ) done </code></pre>
<p>Assuming both arrays are the same size,</p> <pre><code>unset result for (( i=0; i&lt;${#array1[*]}; ++i)); do result+=( &quot;${array1[$i]}&quot; &quot;${array2[$i]}&quot; ) done </code></pre>
114, 387
arrays, bash
<h1>How to merge two arrays in a zipper like fashion in Bash?</h1> <p>I am trying to merge two arrays into one in a zipper like fashion.</p> <pre><code>array1=(one three five seven) array2=(two four six eight) </code></pre> <p>How do I get this output?</p> <pre><code>one two three four five six seven eight </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,095
bash
# How to merge two arrays in a zipper like fashion in Bash? I am trying to merge two arrays into one in a zipper like fashion. ``` array1=(one three five seven) array2=(two four six eight) ``` How do I get this output? ``` one two three four five six seven eight ``` I have tried with nested for-loops but can't fig...
Assuming both arrays are the same size, ``` unset result for (( i=0; i<${#array1[*]}; ++i)); do result+=( "${array1[$i]}" "${array2[$i]}" ) done ```
18779762
Iterating through key names from a PSCustomObject
20
2013-09-13 06:37:50
<p>I am writing a script for my site that utilizes a JSON configuration file. The JSON is similar to the following:</p> <pre><code>"Groups": { "GroupOne": { "NamingFilter": { "Not":"&lt;SITE&gt;-MJ*", "Has":"*WM,*WT" } }, "GroupTwo": { "NamingFilter": { ...
38,815
860,857
2024-07-03 16:32:04
18,780,001
13
2013-09-13 06:51:43
860,857
2018-12-29 08:07:30
https://stackoverflow.com/q/18779762
https://stackoverflow.com/a/18780001
<p>I think I might have just figured it out thanks to the blog post <em><a href="http://blogs.msdn.com/b/timid/archive/2013/03/05/converting-pscustomobject-to-from-hashtables.aspx" rel="noreferrer">Converting PsCustomObject To/From Hashtables</a></em>.</p> <p>Using <code>Get-Member</code> and then <code>-MemberType</co...
<p>I think I might have just figured it out thanks to the blog post <em><a href="http://blogs.msdn.com/b/timid/archive/2013/03/05/converting-pscustomobject-to-from-hashtables.aspx" rel="noreferrer">Converting PsCustomObject To/From Hashtables</a></em>.</p> <p>Using <code>Get-Member</code> and then <code>-MemberType</co...
24067, 37256
object-graph, powershell-2.0
<h1>Iterating through key names from a PSCustomObject</h1> <p>I am writing a script for my site that utilizes a JSON configuration file. The JSON is similar to the following:</p> <pre><code>"Groups": { "GroupOne": { "NamingFilter": { "Not":"&lt;SITE&gt;-MJ*", "Has":"*WM,*WT" ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,096
bash
# Iterating through key names from a PSCustomObject I am writing a script for my site that utilizes a JSON configuration file. The JSON is similar to the following: ``` "Groups": { "GroupOne": { "NamingFilter": { "Not":"<SITE>-MJ*", "Has":"*WM,*WT" } }, "GroupTwo": ...
I think I might have just figured it out thanks to the blog post *[Converting PsCustomObject To/From Hashtables](http://blogs.msdn.com/b/timid/archive/2013/03/05/converting-pscustomobject-to-from-hashtables.aspx)*. Using `Get-Member` and then `-MemberType` exposes each Group and then you just pull the: ``` foreach ($...
11239466
How to check whether a background job is alive? (bash)
20
2012-06-28 06:55:50
<p>I have the following bash script, we can call it <code>script1.sh</code>:</p> <pre><code>#!/bin/bash exec ./script2.sh &amp; sleep 5 if job1 is alive then #&lt;--- this line is pseudo-code! exec ./script3.sh &amp; wait fi </code></pre> <p>As can be seen, the script executes <code>script2.sh</code> as a ...
35,342
963,396
2020-07-23 06:01:07
11,239,622
13
2012-06-28 07:06:53
1,301,972
2012-06-28 07:06:53
https://stackoverflow.com/q/11239466
https://stackoverflow.com/a/11239622
<p>You can get the PID of the most recent background job with <code>$!</code>. You could then check the exit status of <em>ps</em> to determine if that particular PID is still in the process list. For example:</p> <pre><code>sleep 30 &amp; if ps -p $! &gt;&amp;-; then wait $! else jobs fi </code></pre>
<p>You can get the PID of the most recent background job with <code>$!</code>. You could then check the exit status of <em>ps</em> to determine if that particular PID is still in the process list. For example:</p> <pre><code>sleep 30 &amp; if ps -p $! &gt;&amp;-; then wait $! else jobs fi </code></pre>
387, 390, 955, 2827, 5910
background, bash, jobs, process, shell
<h1>How to check whether a background job is alive? (bash)</h1> <p>I have the following bash script, we can call it <code>script1.sh</code>:</p> <pre><code>#!/bin/bash exec ./script2.sh &amp; sleep 5 if job1 is alive then #&lt;--- this line is pseudo-code! exec ./script3.sh &amp; wait fi </code></pre> <p>A...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,097
bash
# How to check whether a background job is alive? (bash) I have the following bash script, we can call it `script1.sh`: ``` #!/bin/bash exec ./script2.sh & sleep 5 if job1 is alive then #<--- this line is pseudo-code! exec ./script3.sh & wait fi ``` As can be seen, the script executes `script2.sh` as a ba...
You can get the PID of the most recent background job with `$!`. You could then check the exit status of *ps* to determine if that particular PID is still in the process list. For example: ``` sleep 30 & if ps -p $! >&-; then wait $! else jobs fi ```
11206233
What does the "=~" operator do in shell scripts?
20
2012-06-26 11:20:54
<p>It seems that it is sort of comparison operator, but what exactly it does in e.g. the following code (taken from <a href="https://github.com/lvv/git-prompt/blob/master/git-prompt.sh#L154">https://github.com/lvv/git-prompt/blob/master/git-prompt.sh#L154</a>)?</p> <pre><code> if [[ $LC_CTYPE =~ "UTF" &amp;&amp; $T...
27,248
831,314
2017-03-30 08:17:01
11,206,353
13
2012-06-26 11:27:52
385,571
2017-03-30 08:17:01
https://stackoverflow.com/q/11206233
https://stackoverflow.com/a/11206353
<p>It's a bash-only addition to the built-in <code>[[</code> command, performing regexp matching. Since it doesn't have to be an exact match of the full string, the symbol is waved, to indicate an "inexact" match.</p> <p>In this case, if <code>$LC_CTYPE</code> <em>CONTAINS</em> the string "UTF".</p> <p>More portable ...
<p>It's a bash-only addition to the built-in <code>[[</code> command, performing regexp matching. Since it doesn't have to be an exact match of the full string, the symbol is waved, to indicate an "inexact" match.</p> <p>In this case, if <code>$LC_CTYPE</code> <em>CONTAINS</em> the string "UTF".</p> <p>More portable ...
387, 390
bash, shell
<h1>What does the "=~" operator do in shell scripts?</h1> <p>It seems that it is sort of comparison operator, but what exactly it does in e.g. the following code (taken from <a href="https://github.com/lvv/git-prompt/blob/master/git-prompt.sh#L154">https://github.com/lvv/git-prompt/blob/master/git-prompt.sh#L154</a>)?<...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,098
bash
# What does the "=~" operator do in shell scripts? It seems that it is sort of comparison operator, but what exactly it does in e.g. the following code (taken from <https://github.com/lvv/git-prompt/blob/master/git-prompt.sh#L154>)? ``` if [[ $LC_CTYPE =~ "UTF" && $TERM != "linux" ]]; then elipses_ma...
It's a bash-only addition to the built-in `[[` command, performing regexp matching. Since it doesn't have to be an exact match of the full string, the symbol is waved, to indicate an "inexact" match. In this case, if `$LC_CTYPE` *CONTAINS* the string "UTF". More portable version: ``` if test `echo $LC_CTYPE | grep -...
31224368
How do I escape a series of backslashes in a bash printf?
19
2015-07-04 19:22:11
<p>The following script yielded an unexpected output:</p> <pre><code>printf "escaped slash: \\ \n" printf "2 escaped slashes: \\\\ \n" printf "3 escaped slashes: \\\\\\ \n" printf "4 escaped slashes: \\\\\\\\ \n" </code></pre> <p>Run as a bash script under Ubuntu 14, I see:</p> <pre><code>escaped slash: \ 2 escaped ...
46,268
1,335,245
2022-04-25 03:21:06
31,224,667
13
2015-07-04 20:00:48
2,381,750
2015-07-04 20:07:43
https://stackoverflow.com/q/31224368
https://stackoverflow.com/a/31224667
<p>Assuming that <code>printf</code> <code>FORMAT</code> string is surrounded by double quotes, <code>printf</code> takes one additional level of expansion, compared to e.g. <code>echo</code> (both being shell builtin commands).</p> <p>What you expect from <code>printf</code> can actually be achieved using single quot...
<p>Assuming that <code>printf</code> <code>FORMAT</code> string is surrounded by double quotes, <code>printf</code> takes one additional level of expansion, compared to e.g. <code>echo</code> (both being shell builtin commands).</p> <p>What you expect from <code>printf</code> can actually be achieved using single quot...
139, 387, 4804, 17891
backslash, bash, escaping, string
<h1>How do I escape a series of backslashes in a bash printf?</h1> <p>The following script yielded an unexpected output:</p> <pre><code>printf "escaped slash: \\ \n" printf "2 escaped slashes: \\\\ \n" printf "3 escaped slashes: \\\\\\ \n" printf "4 escaped slashes: \\\\\\\\ \n" </code></pre> <p>Run as a bash script ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,099
bash
# How do I escape a series of backslashes in a bash printf? The following script yielded an unexpected output: ``` printf "escaped slash: \\ \n" printf "2 escaped slashes: \\\\ \n" printf "3 escaped slashes: \\\\\\ \n" printf "4 escaped slashes: \\\\\\\\ \n" ``` Run as a bash script under Ubuntu 14, I see: ``` esca...
Assuming that `printf` `FORMAT` string is surrounded by double quotes, `printf` takes one additional level of expansion, compared to e.g. `echo` (both being shell builtin commands). What you expect from `printf` can actually be achieved using single quotes: ``` printf '1 escaped slash: \\ \n' printf '2 escaped slas...
27590276
"permission denied" while removing git directory
19
2014-12-21 14:28:38
<p>I'm trying to remove a .git directory while using win7 and git-bash. here's my attempt:</p> <pre><code>$ rm -rf .git rm: cannot remove directory `.git/objects/5e': Permission denied rm: cannot remove directory `.git/objects': Directory not empty rm: cannot remove directory `.git': Directory not empty $ rmdir ....
41,645
1,592,380
2023-01-14 17:43:38
27,590,363
13
2014-12-21 14:36:58
41,782
2014-12-21 14:36:58
https://stackoverflow.com/q/27590276
https://stackoverflow.com/a/27590363
<p>Windows 7 - Git-bash</p> <pre><code>$ sudo sh.exe": sudo: command not found </code></pre> <p>git-bash in windows does not have sudo command. </p> <p>Most probably, you used some git commands in command shell with elevated privileges. In windows 7 , your normal user and your user with elevated privileges have diff...
<p>Windows 7 - Git-bash</p> <pre><code>$ sudo sh.exe": sudo: command not found </code></pre> <p>git-bash in windows does not have sudo command. </p> <p>Most probably, you used some git commands in command shell with elevated privileges. In windows 7 , your normal user and your user with elevated privileges have diff...
64, 119, 61874
git, git-bash, windows
<h1>"permission denied" while removing git directory</h1> <p>I'm trying to remove a .git directory while using win7 and git-bash. here's my attempt:</p> <pre><code>$ rm -rf .git rm: cannot remove directory `.git/objects/5e': Permission denied rm: cannot remove directory `.git/objects': Directory not empty rm: cannot r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,100
bash
# "permission denied" while removing git directory I'm trying to remove a .git directory while using win7 and git-bash. here's my attempt: ``` $ rm -rf .git rm: cannot remove directory `.git/objects/5e': Permission denied rm: cannot remove directory `.git/objects': Directory not empty rm: cannot remove directory `.gi...
Windows 7 - Git-bash ``` $ sudo sh.exe": sudo: command not found ``` git-bash in windows does not have sudo command. Most probably, you used some git commands in command shell with elevated privileges. In windows 7 , your normal user and your user with elevated privileges have different powers. Try to do one of the ...
16197021
How to Write-Verbose from Invoke-Command?
19
2013-04-24 16:11:04
<p>In powershell</p> <p><code>Write-Verbose</code> and the <code>-Verbose</code> flag are used to provide verbose information when commands are run in verbose mode. I am running some scripts remotely and would like to capture the verbose output output. However, <code>Invoke-Command</code> seems to not capture the verb...
11,688
5,056
2020-03-27 08:17:30
16,197,390
13
2013-04-24 16:31:04
574,168
2013-04-24 16:31:04
https://stackoverflow.com/q/16197021
https://stackoverflow.com/a/16197390
<p>Try it this way:</p> <pre><code>Invoke-Command -ComputerName MY-COMPUTERNAME {$VerbosePreference='Continue'; Write-Verbose "blah" } </code></pre>
<p>Try it this way:</p> <pre><code>Invoke-Command -ComputerName MY-COMPUTERNAME {$VerbosePreference='Continue'; Write-Verbose "blah" } </code></pre>
526, 63177
powershell, powershell-remoting
<h1>How to Write-Verbose from Invoke-Command?</h1> <p>In powershell</p> <p><code>Write-Verbose</code> and the <code>-Verbose</code> flag are used to provide verbose information when commands are run in verbose mode. I am running some scripts remotely and would like to capture the verbose output output. However, <code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,101
bash
# How to Write-Verbose from Invoke-Command? In powershell `Write-Verbose` and the `-Verbose` flag are used to provide verbose information when commands are run in verbose mode. I am running some scripts remotely and would like to capture the verbose output output. However, `Invoke-Command` seems to not capture the ve...
Try it this way: ``` Invoke-Command -ComputerName MY-COMPUTERNAME {$VerbosePreference='Continue'; Write-Verbose "blah" } ```
2746707
using bash: write bit representation of integer to file
19
2010-04-30 18:18:12
<p>I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the offset and show me that it found the place I want:</p> <pre><code>dd bs=1 if=file iseek=24 conv=block cbs=2 | hexdump </code></pre> <p>Now, to use "file" as the output:</p> ...
20,489
219,324
2023-04-06 23:04:32
2,746,789
13
2010-04-30 18:32:06
329,892
2014-03-01 12:07:55
https://stackoverflow.com/q/2746707
https://stackoverflow.com/a/2746789
<p>You can use echo to emit specific bytes using hex or octal. For example:</p> <pre><code>echo -n -e \\x30 </code></pre> <p>will print ascii 0 (0x30) </p> <p>(-n remove trailing newline)</p>
<p>You can use echo to emit specific bytes using hex or octal. For example:</p> <pre><code>echo -n -e \\x30 </code></pre> <p>will print ascii 0 (0x30) </p> <p>(-n remove trailing newline)</p>
34, 387, 4867, 5004
bash, binaryfiles, stdout, unix
<h1>using bash: write bit representation of integer to file</h1> <p>I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the offset and show me that it found the place I want:</p> <pre><code>dd bs=1 if=file iseek=24 conv=block cbs=2 |...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,102
bash
# using bash: write bit representation of integer to file I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the offset and show me that it found the place I want: ``` dd bs=1 if=file iseek=24 conv=block cbs=2 | hexdump ``` Now, t...
You can use echo to emit specific bytes using hex or octal. For example: ``` echo -n -e \\x30 ``` will print ascii 0 (0x30) (-n remove trailing newline)
1720673
Parse xml in powershell
19
2009-11-12 08:09:14
<p>I have the following xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;sections&gt; &lt;section name="Options"&gt; &lt;item key="HLVersionControlWebServiceURL" value="http://www.personec.no/webservices/HLVersionControl/HLVersionControl.asmx" /&gt; &lt;item key="AltinnWebServiceURL" valu...
30,645
82,834
2014-08-28 05:43:23
1,726,700
13
2009-11-13 02:12:02
153,982
2009-11-13 02:12:02
https://stackoverflow.com/q/1720673
https://stackoverflow.com/a/1726700
<p>This version uses a bit more PowerShell and handles the case of mulitple items with WorkDir keys:</p> <pre><code>$xml = [xml](Get-Content foo.xml) $xpath = "/sections/section/item[@key='WorkDir']" Microsoft.PowerShell.Utility\Select-Xml $xml -XPath $xpath | Foreach {$_.Node.SetAttribute('value', $pwd)} $xml.Sa...
<p>This version uses a bit more PowerShell and handles the case of mulitple items with WorkDir keys:</p> <pre><code>$xml = [xml](Get-Content foo.xml) $xpath = "/sections/section/item[@key='WorkDir']" Microsoft.PowerShell.Utility\Select-Xml $xml -XPath $xpath | Foreach {$_.Node.SetAttribute('value', $pwd)} $xml.Sa...
19, 526
powershell, xml
<h1>Parse xml in powershell</h1> <p>I have the following xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;sections&gt; &lt;section name="Options"&gt; &lt;item key="HLVersionControlWebServiceURL" value="http://www.personec.no/webservices/HLVersionControl/HLVersionControl.asmx" /&gt; &lt;it...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,103
bash
# Parse xml in powershell I have the following xml: ``` <?xml version="1.0" encoding="UTF-8"?> <sections> <section name="Options"> <item key="HLVersionControlWebServiceURL" value="http://www.personec.no/webservices/HLVersionControl/HLVersionControl.asmx" /> <item key="AltinnWebServiceURL" value="https://www...
This version uses a bit more PowerShell and handles the case of mulitple items with WorkDir keys: ``` $xml = [xml](Get-Content foo.xml) $xpath = "/sections/section/item[@key='WorkDir']" Microsoft.PowerShell.Utility\Select-Xml $xml -XPath $xpath | Foreach {$_.Node.SetAttribute('value', $pwd)} $xml.Save("$pwd\bar.x...
71514564
Git : reload .gitconfig file from the bash console
18
2022-03-17 15:01:19
<p>I want to quickly test my changes in my user <code>.gitconfig</code> file without closing and reopening the console. Is there a way to load it again, much like <code>source .bashrc</code> would reload the bash config ?</p> <p>EDIT : <code>source ~/.gitconfig</code> didn't work, not that this surprises me, but just s...
24,129
1,419,127
2024-02-28 16:43:58
78,076,213
13
2024-02-28 16:43:58
1,019,234
2024-02-28 16:43:58
https://stackoverflow.com/q/71514564
https://stackoverflow.com/a/78076213
<p>Git automatically reads the <code>.gitconfig</code> file each time you run a Git command. Therefore, any changes you make to the file will take effect immediately without needing to reload or restart anything. Just save your changes, and the next time you run a Git command, the updated configuration will be used.</p...
<p>Git automatically reads the <code>.gitconfig</code> file each time you run a Git command. Therefore, any changes you make to the file will take effect immediately without needing to reload or restart anything. Just save your changes, and the next time you run a Git command, the updated configuration will be used.</p...
119, 387, 488, 32868, 61874
bash, console, git, git-bash, git-config
<h1>Git : reload .gitconfig file from the bash console</h1> <p>I want to quickly test my changes in my user <code>.gitconfig</code> file without closing and reopening the console. Is there a way to load it again, much like <code>source .bashrc</code> would reload the bash config ?</p> <p>EDIT : <code>source ~/.gitconfi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,104
bash
# Git : reload .gitconfig file from the bash console I want to quickly test my changes in my user `.gitconfig` file without closing and reopening the console. Is there a way to load it again, much like `source .bashrc` would reload the bash config ? EDIT : `source ~/.gitconfig` didn't work, not that this surprises me...
Git automatically reads the `.gitconfig` file each time you run a Git command. Therefore, any changes you make to the file will take effect immediately without needing to reload or restart anything. Just save your changes, and the next time you run a Git command, the updated configuration will be used.
56589188
Test postgresql connection string using psql at bash command line?
18
2019-06-13 22:14:40
<p>If I have a postgresql connection string:</p> <pre><code>export my_conn='postgresql://vadmin:Gimme5br@platform-prod.clfk51eo.us-west-2.rds.amazonaws.com/prod' </code></pre> <p>how can I test this connection? I tried:</p> <pre><code>pqsl "$my_conn" </code></pre> <p>and it just hangs</p>
27,684
null
2020-03-19 23:51:22
56,592,545
13
2019-06-14 06:24:25
6,464,308
2019-06-14 06:24:25
https://stackoverflow.com/q/56589188
https://stackoverflow.com/a/56592545
<p>The best tool for the purpose is <a href="https://www.postgresql.org/docs/current/app-pg-isready.html" rel="noreferrer"><code>pg_isready</code></a>.</p> <p>Simply run</p> <pre><code>pg_isready -d "$my_conn" </code></pre> <p>and check the return code.</p>
<p>The best tool for the purpose is <a href="https://www.postgresql.org/docs/current/app-pg-isready.html" rel="noreferrer"><code>pg_isready</code></a>.</p> <p>Simply run</p> <pre><code>pg_isready -d "$my_conn" </code></pre> <p>and check the return code.</p>
256, 387, 390, 82549
bash, postgresql, psql, shell
<h1>Test postgresql connection string using psql at bash command line?</h1> <p>If I have a postgresql connection string:</p> <pre><code>export my_conn='postgresql://vadmin:Gimme5br@platform-prod.clfk51eo.us-west-2.rds.amazonaws.com/prod' </code></pre> <p>how can I test this connection? I tried:</p> <pre><code>pqsl "...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,105
bash
# Test postgresql connection string using psql at bash command line? If I have a postgresql connection string: ``` export my_conn='postgresql://vadmin:Gimme5br@platform-prod.clfk51eo.us-west-2.rds.amazonaws.com/prod' ``` how can I test this connection? I tried: ``` pqsl "$my_conn" ``` and it just hangs
The best tool for the purpose is [`pg_isready`](https://www.postgresql.org/docs/current/app-pg-isready.html). Simply run ``` pg_isready -d "$my_conn" ``` and check the return code.
38519643
Failed to load native library 'libnative-platform.so' for Linux amd64
18
2016-07-22 06:30:13
<p>First off, if this belongs on Ask Ubuntu, my apologies...I'm not really sure what forum this falls under.</p> <p>I'm attempting to fork and build an Android project from Github using PHP and a shell script. Basically, I'm printing out some output from a shell script I wrote into a website. When you visit the page, ...
32,533
2,844,992
2022-10-25 22:47:51
38,558,668
13
2016-07-25 01:50:19
706,466
2016-07-25 01:54:10
https://stackoverflow.com/q/38519643
https://stackoverflow.com/a/38558668
<p>If forking and building script working fine when is executed under your user account in the terminal then a problem is most likely with environment variables and files permissions. </p> <p>1 <strong>It could be that path defined in GRADLE_USER_HOME is not writable by www-data user</strong>. To change home dir you ...
<p>If forking and building script working fine when is executed under your user account in the terminal then a problem is most likely with environment variables and files permissions. </p> <p>1 <strong>It could be that path defined in GRADLE_USER_HOME is not writable by www-data user</strong>. To change home dir you ...
5, 390, 549, 1386, 32307
android, gradle, php, shell, ubuntu
<h1>Failed to load native library 'libnative-platform.so' for Linux amd64</h1> <p>First off, if this belongs on Ask Ubuntu, my apologies...I'm not really sure what forum this falls under.</p> <p>I'm attempting to fork and build an Android project from Github using PHP and a shell script. Basically, I'm printing out so...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,106
bash
# Failed to load native library 'libnative-platform.so' for Linux amd64 First off, if this belongs on Ask Ubuntu, my apologies...I'm not really sure what forum this falls under. I'm attempting to fork and build an Android project from Github using PHP and a shell script. Basically, I'm printing out some output from a...
If forking and building script working fine when is executed under your user account in the terminal then a problem is most likely with environment variables and files permissions. 1 **It could be that path defined in GRADLE_USER_HOME is not writable by www-data user**. To change home dir you could execute `gradle -g ...
31537204
Execute several .sql files in a single transaction using PostgreSQL and bash
18
2015-07-21 10:59:25
<p>Say I have the files:</p> <pre><code>file1.sql file2.sql file3.sql </code></pre> <p>I need all three files to be executed in a single transaction. I'm looking for a bash script like:</p> <pre><code>psql -h hostname -U username dbname -c " begin; \i file1.sql \i file2.sql \i file3.sql commit;" </code></pre> <p>Th...
20,362
2,728,797
2019-06-29 19:27:22
31,537,928
13
2015-07-21 11:34:21
2,235,885
2015-07-21 11:34:21
https://stackoverflow.com/q/31537204
https://stackoverflow.com/a/31537928
<p>Either use a sub-shell:</p> <pre><code>#!/bin/sh (echo "BEGIN;"; cat file1.sql; cat file2.sql; echo "COMMIT;") \ | psql -U the_user the_database #eof </code></pre> <p>or use a here-document:</p> <pre><code>#!/bin/sh psql -U the_user the_database &lt;&lt;OMG BEGIN; \i file1.sql \i file2.sql COMMIT; OMG #eof...
<p>Either use a sub-shell:</p> <pre><code>#!/bin/sh (echo "BEGIN;"; cat file1.sql; cat file2.sql; echo "COMMIT;") \ | psql -U the_user the_database #eof </code></pre> <p>or use a here-document:</p> <pre><code>#!/bin/sh psql -U the_user the_database &lt;&lt;OMG BEGIN; \i file1.sql \i file2.sql COMMIT; OMG #eof...
256, 387, 3550
bash, postgresql, transactions
<h1>Execute several .sql files in a single transaction using PostgreSQL and bash</h1> <p>Say I have the files:</p> <pre><code>file1.sql file2.sql file3.sql </code></pre> <p>I need all three files to be executed in a single transaction. I'm looking for a bash script like:</p> <pre><code>psql -h hostname -U username d...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,107
bash
# Execute several .sql files in a single transaction using PostgreSQL and bash Say I have the files: ``` file1.sql file2.sql file3.sql ``` I need all three files to be executed in a single transaction. I'm looking for a bash script like: ``` psql -h hostname -U username dbname -c " begin; \i file1.sql \i file2.sql ...
Either use a sub-shell: ``` #!/bin/sh (echo "BEGIN;"; cat file1.sql; cat file2.sql; echo "COMMIT;") \ | psql -U the_user the_database #eof ``` or use a here-document: ``` #!/bin/sh psql -U the_user the_database <<OMG BEGIN; \i file1.sql \i file2.sql COMMIT; OMG #eof ``` NOTE: in HERE-documents there will be ...
19619490
How to read stdin when no arguments are passed?
18
2013-10-27 14:59:46
<p>Script doesn't work when I want to use standard input when there are no arguments (files) passed. Is there any way how to use stdin instead of a file in this code?</p> <p>I tried this:</p> <pre><code>if [ ! -n $1 ] # check if argument exists then $1=$(&lt;/dev/stdin) # if not use stdin as an argument fi ...
14,070
2,203,012
2015-07-24 05:31:56
19,619,634
13
2013-10-27 15:15:22
132,382
2015-02-28 21:29:55
https://stackoverflow.com/q/19619490
https://stackoverflow.com/a/19619634
<p>Just substitute bash's specially interpreted <code>/dev/stdin</code> as the filename:</p> <pre><code>VAR=$1 while read blah; do ... done &lt; "${VAR:-/dev/stdin}" </code></pre> <p>(Note that bash will actually use that special <em>file</em> <code>/dev/stdin</code> <a href="https://unix.stackexchange.com/a/38580/...
<p>Just substitute bash's specially interpreted <code>/dev/stdin</code> as the filename:</p> <pre><code>VAR=$1 while read blah; do ... done &lt; "${VAR:-/dev/stdin}" </code></pre> <p>(Note that bash will actually use that special <em>file</em> <code>/dev/stdin</code> <a href="https://unix.stackexchange.com/a/38580/...
387, 1701
bash, stdin
<h1>How to read stdin when no arguments are passed?</h1> <p>Script doesn't work when I want to use standard input when there are no arguments (files) passed. Is there any way how to use stdin instead of a file in this code?</p> <p>I tried this:</p> <pre><code>if [ ! -n $1 ] # check if argument exists then $1=$(...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,108
bash
# How to read stdin when no arguments are passed? Script doesn't work when I want to use standard input when there are no arguments (files) passed. Is there any way how to use stdin instead of a file in this code? I tried this: ``` if [ ! -n $1 ] # check if argument exists then $1=$(</dev/stdin) # if not use ...
Just substitute bash's specially interpreted `/dev/stdin` as the filename: ``` VAR=$1 while read blah; do ... done < "${VAR:-/dev/stdin}" ``` (Note that bash will actually use that special *file* `/dev/stdin` [if built for an OS that offers it](https://unix.stackexchange.com/a/38580/7703), but since bash 2.04 will ...
9554544
Python, running command line tools in parallel
18
2012-03-04 11:35:47
<p>I am using Python as a script language to do some data processing and call command-line tools for number crunching. I wish to run command-line tools in parallel since they are independent with each other. When one command-line tool is finished, I can collect its results from the output file. So I also need some sync...
35,847
183,828
2019-01-08 09:46:08
9,555,046
13
2012-03-04 13:00:14
1,219,295
2012-11-08 07:31:54
https://stackoverflow.com/q/9554544
https://stackoverflow.com/a/9555046
<p>Use the <code>Pool</code> object from the <code>multiprocessing</code> module. You can then use e.g. <code>Pool.map()</code> to do parallel processing. An example would be my markphotos script (see below), where a function is called multiple times in parallel to each process a picture.</p> <pre><code>#! /usr/bin/en...
<p>Use the <code>Pool</code> object from the <code>multiprocessing</code> module. You can then use e.g. <code>Pool.map()</code> to do parallel processing. An example would be my markphotos script (see below), where a function is called multiple times in parallel to each process a picture.</p> <pre><code>#! /usr/bin/en...
16, 353, 390, 1231
command-line, parallel-processing, python, shell
<h1>Python, running command line tools in parallel</h1> <p>I am using Python as a script language to do some data processing and call command-line tools for number crunching. I wish to run command-line tools in parallel since they are independent with each other. When one command-line tool is finished, I can collect it...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,109
bash
# Python, running command line tools in parallel I am using Python as a script language to do some data processing and call command-line tools for number crunching. I wish to run command-line tools in parallel since they are independent with each other. When one command-line tool is finished, I can collect its results...
Use the `Pool` object from the `multiprocessing` module. You can then use e.g. `Pool.map()` to do parallel processing. An example would be my markphotos script (see below), where a function is called multiple times in parallel to each process a picture. ``` #! /usr/bin/env python # -*- coding: utf-8 -*- # Adds my copy...
5530522
Provide a .NET method as a delegate callback
18
2011-04-03 15:30:04
<p>What is the syntax to pass .NET method as a delegate callback to a .NET object in PowerShell.</p> <p>For example:</p> <p>C#:</p> <pre><code>public class Class1 { public static void MyMethod(Action&lt;object&gt; obj) { obj("Hey!"); } } public class Class2 { public static void Callback(obj...
4,991
13,688
2012-09-02 00:01:15
5,531,492
13
2011-04-03 18:14:23
110,865
2011-04-03 18:14:23
https://stackoverflow.com/q/5530522
https://stackoverflow.com/a/5531492
<p>Working code via Adam's and Oisin's chat.</p> <pre><code>Add-Type -Language CSharpVersion3 -TypeDefinition @" using System; public class Class1 { public static void MyMethod(Action&lt;object&gt; obj) { obj("Hey!"); } } public class Class2 { public static void Callback(object obj) { ...
<p>Working code via Adam's and Oisin's chat.</p> <pre><code>Add-Type -Language CSharpVersion3 -TypeDefinition @" using System; public class Class1 { public static void MyMethod(Action&lt;object&gt; obj) { obj("Hey!"); } } public class Class2 { public static void Callback(object obj) { ...
1, 9, 526, 1533, 24067
.net, c#, delegates, powershell, powershell-2.0
<h1>Provide a .NET method as a delegate callback</h1> <p>What is the syntax to pass .NET method as a delegate callback to a .NET object in PowerShell.</p> <p>For example:</p> <p>C#:</p> <pre><code>public class Class1 { public static void MyMethod(Action&lt;object&gt; obj) { obj("Hey!"); } } pub...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,110
bash
# Provide a .NET method as a delegate callback What is the syntax to pass .NET method as a delegate callback to a .NET object in PowerShell. For example: C#: ``` public class Class1 { public static void MyMethod(Action<object> obj) { obj("Hey!"); } } public class Class2 { public static voi...
Working code via Adam's and Oisin's chat. ``` Add-Type -Language CSharpVersion3 -TypeDefinition @" using System; public class Class1 { public static void MyMethod(Action<object> obj) { obj("Hey!"); } } public class Class2 { public static void Callback(object obj) { Console.Write...
43260052
Bash move * to subfolder fail: cannot move to a subdirectory of itself
17
2017-04-06 15:51:36
<p>I have a folder with several files that I want to move to a subfolder:</p> <pre><code>mkdir subfolder mv ./* subfolder </code></pre> <p>But when I do this, I get: </p> <p><code>mv: cannot move 'subfolder' to a subdirectory of itself</code></p> <p>How can I simply avoid this?</p>
28,376
1,620,081
2021-07-25 12:05:42
43,260,121
13
2017-04-06 15:54:24
548,225
2017-04-06 15:54:24
https://stackoverflow.com/q/43260052
https://stackoverflow.com/a/43260121
<p>Using <code>extglob</code> you can do this:</p> <pre><code>shopt -s extglob mv !(subfolder) subfolder </code></pre> <p>Glob expression <code>!(subfolder)</code> will match everything except <code>subfolder</code>.</p>
<p>Using <code>extglob</code> you can do this:</p> <pre><code>shopt -s extglob mv !(subfolder) subfolder </code></pre> <p>Glob expression <code>!(subfolder)</code> will match everything except <code>subfolder</code>.</p>
387
bash
<h1>Bash move * to subfolder fail: cannot move to a subdirectory of itself</h1> <p>I have a folder with several files that I want to move to a subfolder:</p> <pre><code>mkdir subfolder mv ./* subfolder </code></pre> <p>But when I do this, I get: </p> <p><code>mv: cannot move 'subfolder' to a subdirectory of itself</...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,111
bash
# Bash move * to subfolder fail: cannot move to a subdirectory of itself I have a folder with several files that I want to move to a subfolder: ``` mkdir subfolder mv ./* subfolder ``` But when I do this, I get: `mv: cannot move 'subfolder' to a subdirectory of itself` How can I simply avoid this?
Using `extglob` you can do this: ``` shopt -s extglob mv !(subfolder) subfolder ``` Glob expression `!(subfolder)` will match everything except `subfolder`.
26464103
How to export env variable in node.js
17
2014-10-20 11:04:15
<p>I like my <code>node.js</code> so much, that I want to use it is my <code>bash</code> start up script <code>~/.bashrc</code>, but I do not know how to export variable.</p> <p>Currently I have to use this approach:</p> <pre><code>export PS1=`node ~/PS1.js` export PS2=`node ~/PS2.js` export PATH=`node ~/PATH.js` </c...
30,732
1,968,972
2025-11-17 17:27:44
26,464,645
13
2014-10-20 11:32:00
1,195,752
2014-10-21 05:28:20
https://stackoverflow.com/q/26464103
https://stackoverflow.com/a/26464645
<p>Node.js will run in an separate process which gets a copy of the environment. You cannot change the environment of you parent process (the one executing .bashrc).</p> <p>But the following question has an answer for you: <a href="https://stackoverflow.com/questions/496702/can-a-shell-script-set-environment-variables...
<p>Node.js will run in an separate process which gets a copy of the environment. You cannot change the environment of you parent process (the one executing .bashrc).</p> <p>But the following question has an answer for you: <a href="https://stackoverflow.com/questions/496702/can-a-shell-script-set-environment-variables...
3, 387, 9013, 46426
bash, environment-variables, javascript, node.js
<h1>How to export env variable in node.js</h1> <p>I like my <code>node.js</code> so much, that I want to use it is my <code>bash</code> start up script <code>~/.bashrc</code>, but I do not know how to export variable.</p> <p>Currently I have to use this approach:</p> <pre><code>export PS1=`node ~/PS1.js` export PS2=`...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,112
bash
# How to export env variable in node.js I like my `node.js` so much, that I want to use it is my `bash` start up script `~/.bashrc`, but I do not know how to export variable. Currently I have to use this approach: ``` export PS1=`node ~/PS1.js` export PS2=`node ~/PS2.js` export PATH=`node ~/PATH.js` ``` instead I w...
Node.js will run in an separate process which gets a copy of the environment. You cannot change the environment of you parent process (the one executing .bashrc). But the following question has an answer for you: [Can a shell script set environment variables of the calling shell?](https://stackoverflow.com/questions/4...
23417755
Simulate a crashing bash script
17
2014-05-01 22:30:03
<p>I'm trying to test a bash script that restarts it's child process when the child process has crashed.<br> How do I make a bash script crash on purpose? </p> <p>(I'm trying to test the script that restarts the process)</p>
9,552
155,638
2017-05-22 23:00:16
23,418,012
13
2014-05-01 22:50:52
3,030,305
2014-05-01 22:50:52
https://stackoverflow.com/q/23417755
https://stackoverflow.com/a/23418012
<p>To exit a script while signaling an error, use:</p> <pre><code>exit 1 </code></pre> <p>That exits with exit code <code>1</code>, indicating failure. Other non-zero numbers can be used to signal different failure conditions. <code>exit 0</code> signals success.</p> <p>To throw an exception, use <code>kill</code>...
<p>To exit a script while signaling an error, use:</p> <pre><code>exit 1 </code></pre> <p>That exits with exit code <code>1</code>, indicating failure. Other non-zero numbers can be used to signal different failure conditions. <code>exit 0</code> signals success.</p> <p>To throw an exception, use <code>kill</code>...
387, 5142
bash, exception
<h1>Simulate a crashing bash script</h1> <p>I'm trying to test a bash script that restarts it's child process when the child process has crashed.<br> How do I make a bash script crash on purpose? </p> <p>(I'm trying to test the script that restarts the process)</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,113
bash
# Simulate a crashing bash script I'm trying to test a bash script that restarts it's child process when the child process has crashed. How do I make a bash script crash on purpose? (I'm trying to test the script that restarts the process)
To exit a script while signaling an error, use: ``` exit 1 ``` That exits with exit code `1`, indicating failure. Other non-zero numbers can be used to signal different failure conditions. `exit 0` signals success. To throw an exception, use `kill`. To issue the hangup signal, for example, from within a script, run:...
15897276
Extracting part of a string to a variable in bash
17
2013-04-09 08:45:43
<p>noob here, sorry if a repost. I am extracting a string from a file, and end up with a line, something like:</p> <pre><code>abcdefg:12345:67890:abcde:12345:abcde </code></pre> <p>Let's say it's in a variable named testString the length of the values between the colons is not constant, but I want to save the number,...
62,051
2,260,834
2013-04-09 16:18:06
15,904,021
13
2013-04-09 14:01:18
2,005,672
2013-04-09 14:12:48
https://stackoverflow.com/q/15897276
https://stackoverflow.com/a/15904021
<p>Here's another pure bash way. Works fine when your input is reasonably consistent and you don't need much flexibility in which section you pick out.</p> <pre><code>extractedNum="${testString#*:}" # Remove through first : extractedNum="${extractedNum#*:}" # Remove through second : extractedNum="${extractedNum%...
<p>Here's another pure bash way. Works fine when your input is reasonably consistent and you don't need much flexibility in which section you pick out.</p> <pre><code>extractedNum="${testString#*:}" # Remove through first : extractedNum="${extractedNum#*:}" # Remove through second : extractedNum="${extractedNum%...
139, 387, 5282, 5352, 10193
bash, extract, find, sed, string
<h1>Extracting part of a string to a variable in bash</h1> <p>noob here, sorry if a repost. I am extracting a string from a file, and end up with a line, something like:</p> <pre><code>abcdefg:12345:67890:abcde:12345:abcde </code></pre> <p>Let's say it's in a variable named testString the length of the values between...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,114
bash
# Extracting part of a string to a variable in bash noob here, sorry if a repost. I am extracting a string from a file, and end up with a line, something like: ``` abcdefg:12345:67890:abcde:12345:abcde ``` Let's say it's in a variable named testString the length of the values between the colons is not constant, but ...
Here's another pure bash way. Works fine when your input is reasonably consistent and you don't need much flexibility in which section you pick out. ``` extractedNum="${testString#*:}" # Remove through first : extractedNum="${extractedNum#*:}" # Remove through second : extractedNum="${extractedNum%%:*}" # Remov...
13381746
tr [:upper:] [:lower:] with Cyrillic text
17
2012-11-14 15:25:07
<p>I'm trying to extract a word list from a Russian short story.</p> <pre><code>#!/bin/sh export LC_ALL=ru_RU.utf8 sed -re 's/\s+/\n/g' | \ sed 's/[\.!,—()«»;:?]//g' | \ tr '[:upper:]' '[:lower:]' | \ sort | uniq </code></pre> <p>However the <code>tr</code> step is not lowercasing the Cyrillic capital letters. I th...
23,701
7,512
2021-05-19 10:29:41
13,383,175
13
2012-11-14 16:40:14
1,258,041
2012-11-14 16:56:39
https://stackoverflow.com/q/13381746
https://stackoverflow.com/a/13383175
<p>This is what I found at <a href="http://en.wikipedia.org/wiki/Tr_%28Unix%29" rel="noreferrer">Wikipedia</a> (without any reference, though):</p> <blockquote> <p>Most versions of <code>tr</code>, including <code>GNU tr</code> and classic Unix <code>tr</code>, operate on single-byte characters and are not Unicode c...
<p>This is what I found at <a href="http://en.wikipedia.org/wiki/Tr_%28Unix%29" rel="noreferrer">Wikipedia</a> (without any reference, though):</p> <blockquote> <p>Most versions of <code>tr</code>, including <code>GNU tr</code> and classic Unix <code>tr</code>, operate on single-byte characters and are not Unicode c...
279, 390, 18990
shell, tr, unicode
<h1>tr [:upper:] [:lower:] with Cyrillic text</h1> <p>I'm trying to extract a word list from a Russian short story.</p> <pre><code>#!/bin/sh export LC_ALL=ru_RU.utf8 sed -re 's/\s+/\n/g' | \ sed 's/[\.!,—()«»;:?]//g' | \ tr '[:upper:]' '[:lower:]' | \ sort | uniq </code></pre> <p>However the <code>tr</code> step is...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,115
bash
# tr [:upper:] [:lower:] with Cyrillic text I'm trying to extract a word list from a Russian short story. ``` #!/bin/sh export LC_ALL=ru_RU.utf8 sed -re 's/\s+/\n/g' | \ sed 's/[\.!,—()«»;:?]//g' | \ tr '[:upper:]' '[:lower:]' | \ sort | uniq ``` However the `tr` step is not lowercasing the Cyrillic capital letter...
This is what I found at [Wikipedia](http://en.wikipedia.org/wiki/Tr_%28Unix%29) (without any reference, though): > Most versions of `tr`, including `GNU tr` and classic Unix `tr`, operate on single-byte characters and are not Unicode compliant. An exception is the [Heirloom Toolchest](http://en.wikipedia.org/wiki/Heir...
10620507
How can I get powershell to return the correct exit code when called with the -File argument?
17
2012-05-16 14:17:24
<p>Powershell is returning a 0 exit code, when an error has occurred, if called with the -File argument. Which means my build is green when it shouldn't be :(</p> <p>For example:</p> <p>(in wtf.ps1) </p> <pre><code>$ErrorActionPreference = "Stop"; $null.split() </code></pre> <p>(cmd) </p> <pre><code>powershel...
18,981
275,095
2017-05-17 18:50:23
10,620,837
13
2012-05-16 14:35:57
9,833
2012-05-16 15:19:16
https://stackoverflow.com/q/10620507
https://stackoverflow.com/a/10620837
<p>In the script, use the exit keyword with a number of your choice:</p> <pre><code>exit 34 </code></pre> <p>Here's the script I used to test this:</p> <pre><code>## D:\Scripts\Temp\exit.ps1 ## try{ $null.split() } catch { exit 34 } exit 2 ############################# # launch powershell from cmd C:\&gt;...
<p>In the script, use the exit keyword with a number of your choice:</p> <pre><code>exit 34 </code></pre> <p>Here's the script I used to test this:</p> <pre><code>## D:\Scripts\Temp\exit.ps1 ## try{ $null.split() } catch { exit 34 } exit 2 ############################# # launch powershell from cmd C:\&gt;...
526, 10021
exit-code, powershell
<h1>How can I get powershell to return the correct exit code when called with the -File argument?</h1> <p>Powershell is returning a 0 exit code, when an error has occurred, if called with the -File argument. Which means my build is green when it shouldn't be :(</p> <p>For example:</p> <p>(in wtf.ps1) </p> <pre><cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,116
bash
# How can I get powershell to return the correct exit code when called with the -File argument? Powershell is returning a 0 exit code, when an error has occurred, if called with the -File argument. Which means my build is green when it shouldn't be :( For example: (in wtf.ps1) ``` $ErrorActionPreference = "Stop"; ...
In the script, use the exit keyword with a number of your choice: ``` exit 34 ``` Here's the script I used to test this: ``` ## D:\Scripts\Temp\exit.ps1 ## try{ $null.split() } catch { exit 34 } exit 2 ############################# # launch powershell from cmd C:\> powershell -noprofile -file D:\Scripts\T...
7824946
How to enable User Account SMB sharing from terminal on Mac OS X?
17
2011-10-08 20:16:39
<p>I'm trying to enable <strong>Account Sharing</strong> from terminal. I can't figure out how to do that.</p> <p>This will be used from inside an application I'm currently programming. The application creates a hidden user, then should enable SMB sharing for this user. Later, I need to connect to this share via anoth...
10,867
963,718
2016-03-04 07:42:28
7,841,485
13
2011-10-20 19:55:32
963,718
2011-10-21 11:37:52
https://stackoverflow.com/q/7824946
https://stackoverflow.com/a/7841485
<p><strong>THIS WORKS FOR OS X 10.5, 10.6, 10.7</strong></p> <p>First type this in terminal</p> <pre><code>pwpolicy -u SomeUser -sethashtypes SMB-NT on </code></pre> <p><code>SomeUser</code> can also be hidden, it doesn't matter. This gives the same effect like enabling that checkbox as shown in the picture above.</...
<p><strong>THIS WORKS FOR OS X 10.5, 10.6, 10.7</strong></p> <p>First type this in terminal</p> <pre><code>pwpolicy -u SomeUser -sethashtypes SMB-NT on </code></pre> <p><code>SomeUser</code> can also be hidden, it doesn't matter. This gives the same effect like enabling that checkbox as shown in the picture above.</...
369, 387, 391, 994
bash, cocoa, macos, terminal
<h1>How to enable User Account SMB sharing from terminal on Mac OS X?</h1> <p>I'm trying to enable <strong>Account Sharing</strong> from terminal. I can't figure out how to do that.</p> <p>This will be used from inside an application I'm currently programming. The application creates a hidden user, then should enable ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,117
bash
# How to enable User Account SMB sharing from terminal on Mac OS X? I'm trying to enable **Account Sharing** from terminal. I can't figure out how to do that. This will be used from inside an application I'm currently programming. The application creates a hidden user, then should enable SMB sharing for this user. La...
**THIS WORKS FOR OS X 10.5, 10.6, 10.7** First type this in terminal ``` pwpolicy -u SomeUser -sethashtypes SMB-NT on ``` `SomeUser` can also be hidden, it doesn't matter. This gives the same effect like enabling that checkbox as shown in the picture above. After that: ``` dscl . -passwd /Users/SomeUser "UserPassw...
7136899
How does grep work?
17
2011-08-21 07:04:38
<p>I am trying to understand how <code>grep</code> works. </p> <p>When I say <code>grep "hello" *.*</code>, does <code>grep</code> get 2 arguments &mdash; (1) string to be searched i.e. "hello" and (2) path <code>*.*</code>? Or does the shell convert <code>*.*</code> into something that <code>grep</code> can understan...
20,800
358,892
2014-11-04 21:16:15
7,136,917
13
2011-08-21 07:10:39
200,291
2011-08-21 07:10:39
https://stackoverflow.com/q/7136899
https://stackoverflow.com/a/7136917
<p>The shell does the globbing (conversion from <code>*</code> form to filenames). You can see this by if you have a simple C program:</p> <pre><code>#include &lt;stdio.h&gt; int main(int argc, char **argv) { for(int i=1; i&lt;argc; i++) { printf("%s\n", argv[i]); } return 0; } </code></pre> <p>A...
<p>The shell does the globbing (conversion from <code>*</code> form to filenames). You can see this by if you have a simple C program:</p> <pre><code>#include &lt;stdio.h&gt; int main(int argc, char **argv) { for(int i=1; i&lt;argc; i++) { printf("%s\n", argv[i]); } return 0; } </code></pre> <p>A...
8, 34, 390, 1271, 4072
c, gnu, grep, shell, unix
<h1>How does grep work?</h1> <p>I am trying to understand how <code>grep</code> works. </p> <p>When I say <code>grep "hello" *.*</code>, does <code>grep</code> get 2 arguments &mdash; (1) string to be searched i.e. "hello" and (2) path <code>*.*</code>? Or does the shell convert <code>*.*</code> into something that <c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,118
bash
# How does grep work? I am trying to understand how `grep` works. When I say `grep "hello" *.*`, does `grep` get 2 arguments — (1) string to be searched i.e. "hello" and (2) path `*.*`? Or does the shell convert `*.*` into something that `grep` can understand? Where can I get source code of `grep`? I came across thi...
The shell does the globbing (conversion from `*` form to filenames). You can see this by if you have a simple C program: ``` #include <stdio.h> int main(int argc, char **argv) { for(int i=1; i<argc; i++) { printf("%s\n", argv[i]); } return 0; } ``` And then run it like this: ``` ./print_args * `...
1176386
Automatically timing every executed command and show in Bash prompt?
17
2009-07-24 08:21:52
<p>I often happen to forget to explicitly prefix executions with the "time" command, ideally I would see in the next shell prompt how much real time the last command took (on every command).</p> <p>I already scoured through the bash documentation, but couldn't find anything related.</p>
9,594
47,573
2010-04-28 21:23:11
1,177,511
13
2009-07-24 13:06:05
26,428
2009-07-24 13:06:05
https://stackoverflow.com/q/1176386
https://stackoverflow.com/a/1177511
<p>You could do this:</p> <pre><code>$ bind '"\C-j": "\C-atime \C-m"' </code></pre> <p>Or put this in your <code>~/.inputrc</code>:</p> <pre><code>"\C-j": "\C-atime \C-m" </code></pre> <p>Then when you want to do <code>time sleep 1</code> you'd type <code>sleep 1</code> and press <kbd>Ctrl</kbd>+<kbd>J</kbd> instea...
<p>You could do this:</p> <pre><code>$ bind '"\C-j": "\C-atime \C-m"' </code></pre> <p>Or put this in your <code>~/.inputrc</code>:</p> <pre><code>"\C-j": "\C-atime \C-m" </code></pre> <p>Then when you want to do <code>time sleep 1</code> you'd type <code>sleep 1</code> and press <kbd>Ctrl</kbd>+<kbd>J</kbd> instea...
387, 603, 5003
bash, prompt, time
<h1>Automatically timing every executed command and show in Bash prompt?</h1> <p>I often happen to forget to explicitly prefix executions with the "time" command, ideally I would see in the next shell prompt how much real time the last command took (on every command).</p> <p>I already scoured through the bash document...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,119
bash
# Automatically timing every executed command and show in Bash prompt? I often happen to forget to explicitly prefix executions with the "time" command, ideally I would see in the next shell prompt how much real time the last command took (on every command). I already scoured through the bash documentation, but could...
You could do this: ``` $ bind '"\C-j": "\C-atime \C-m"' ``` Or put this in your `~/.inputrc`: ``` "\C-j": "\C-atime \C-m" ``` Then when you want to do `time sleep 1` you'd type `sleep 1` and press `Ctrl`+`J` instead of `Enter`. I would not recommend swapping the `j` and `m` in the bind command (or in the .inputrc ...
66970902
Getting the error: bash: (program): cannot execute binary file: Exec format error, on both 32-bit and 64-bit Windows
16
2021-04-06 14:45:10
<p>There is a program developed for linguistic research (<a href="http://people.csail.mit.edu/mcollins/code.html" rel="noreferrer">http://people.csail.mit.edu/mcollins/code.html</a>). When I try to run the parser using Git bash terminal on Windows, I get the error:</p> <pre><code>bash: cannot execute binary file: Exec ...
167,548
11,926,527
2024-06-04 08:43:44
66,971,306
13
2021-04-06 15:07:48
995,714
2022-05-02 22:43:22
https://stackoverflow.com/q/66970902
https://stackoverflow.com/a/66971306
<p>As indicated by <code>file</code>, your program is a <strong>Linux application</strong> so you can't run it on Windows. See</p> <ul> <li><a href="https://stackoverflow.com/q/32117572/995714">Why does a linux compiled program not work on Windows</a></li> <li><a href="https://superuser.com/q/209703/241386">Why won't W...
<p>As indicated by <code>file</code>, your program is a <strong>Linux application</strong> so you can't run it on Windows. See</p> <ul> <li><a href="https://stackoverflow.com/q/32117572/995714">Why does a linux compiled program not work on Windows</a></li> <li><a href="https://superuser.com/q/209703/241386">Why won't W...
34, 64, 387, 1135, 10059
bash, elf, executable, unix, windows
<h1>Getting the error: bash: (program): cannot execute binary file: Exec format error, on both 32-bit and 64-bit Windows</h1> <p>There is a program developed for linguistic research (<a href="http://people.csail.mit.edu/mcollins/code.html" rel="noreferrer">http://people.csail.mit.edu/mcollins/code.html</a>). When I try...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,120
bash
# Getting the error: bash: (program): cannot execute binary file: Exec format error, on both 32-bit and 64-bit Windows There is a program developed for linguistic research (<http://people.csail.mit.edu/mcollins/code.html>). When I try to run the parser using Git bash terminal on Windows, I get the error: ``` bash: ca...
As indicated by `file`, your program is a **Linux application** so you can't run it on Windows. See - [Why does a linux compiled program not work on Windows](https://stackoverflow.com/q/32117572/995714) - [Why won't Windows EXE files work on Linux?](https://superuser.com/q/209703/241386) - [Why do you need to recompil...
51972474
Override bash completion for git clone
16
2018-08-22 17:46:15
<h2>builtin completion</h2> <p>The default <a href="https://github.com/git/git/blob/7e8bfb0412581daf8f3c89909f1d37844e8610dd/contrib/completion/git-completion.bash#L1387-L1395" rel="noreferrer">completion for git clone</a> (reproduced below) gives tab completion for <code>--*</code> options:</p> <pre><code>_git_clone...
1,620
812,183
2021-08-08 02:03:43
54,305,694
13
2019-01-22 10:03:16
10,524,205
2019-01-23 18:20:47
https://stackoverflow.com/q/51972474
https://stackoverflow.com/a/54305694
<p>The <a href="https://github.com/scop/bash-completion#faq" rel="noreferrer">official FAQ</a> of bash-completion contains very interesting information.</p> <p>First, if you are 100% sure your <code>$BASH_COMPLETION_USER_DIR</code> and <code>$XDG_DATA_HOME</code> environment variable are empty, what you specified in y...
<p>The <a href="https://github.com/scop/bash-completion#faq" rel="noreferrer">official FAQ</a> of bash-completion contains very interesting information.</p> <p>First, if you are 100% sure your <code>$BASH_COMPLETION_USER_DIR</code> and <code>$XDG_DATA_HOME</code> environment variable are empty, what you specified in y...
119, 387, 59778
bash, bash-completion, git
<h1>Override bash completion for git clone</h1> <h2>builtin completion</h2> <p>The default <a href="https://github.com/git/git/blob/7e8bfb0412581daf8f3c89909f1d37844e8610dd/contrib/completion/git-completion.bash#L1387-L1395" rel="noreferrer">completion for git clone</a> (reproduced below) gives tab completion for <cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,121
bash
# Override bash completion for git clone ## builtin completion The default [completion for git clone](https://github.com/git/git/blob/7e8bfb0412581daf8f3c89909f1d37844e8610dd/contrib/completion/git-completion.bash#L1387-L1395) (reproduced below) gives tab completion for `--*` options: ``` _git_clone () { case "$...
The [official FAQ](https://github.com/scop/bash-completion#faq) of bash-completion contains very interesting information. First, if you are 100% sure your `$BASH_COMPLETION_USER_DIR` and `$XDG_DATA_HOME` environment variable are empty, what you specified in your original question is a good place to add your own bash-c...
50954038
How to retrieve only enabled users from the Active Directory
16
2018-06-20 17:36:26
<p>I'm trying to retrieve only enabled users in the AD. When I run this code line it returns the error. I tried using a filter as well to filter only enabled users for the requested info but it returns ALL users from every domain instead of just the single id.</p> <pre><code>Get-ADUser : A positional parameter cannot ...
228,199
9,772,081
2021-05-21 11:23:14
50,954,775
13
2018-06-20 18:23:15
2,734,259
2018-06-20 18:23:15
https://stackoverflow.com/q/50954038
https://stackoverflow.com/a/50954775
<pre><code>Get-ADUser -Filter * -Properties mail | Where { $_.Enabled -eq $True} | Select Name,samaccountname,mail </code></pre> <p>That will get all enabled users in your target domain that are enabled and display the name, username, and mail properties</p>
<pre><code>Get-ADUser -Filter * -Properties mail | Where { $_.Enabled -eq $True} | Select Name,samaccountname,mail </code></pre> <p>That will get all enabled users in your target domain that are enabled and display the name, username, and mail properties</p>
526, 10401
active-directory, powershell
<h1>How to retrieve only enabled users from the Active Directory</h1> <p>I'm trying to retrieve only enabled users in the AD. When I run this code line it returns the error. I tried using a filter as well to filter only enabled users for the requested info but it returns ALL users from every domain instead of just the ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,122
bash
# How to retrieve only enabled users from the Active Directory I'm trying to retrieve only enabled users in the AD. When I run this code line it returns the error. I tried using a filter as well to filter only enabled users for the requested info but it returns ALL users from every domain instead of just the single id...
``` Get-ADUser -Filter * -Properties mail | Where { $_.Enabled -eq $True} | Select Name,samaccountname,mail ``` That will get all enabled users in your target domain that are enabled and display the name, username, and mail properties
43015262
Change color of first input word in PowerShell
16
2017-03-25 10:28:55
<p>I want to change color of first console statement from yellow to some another color because it looks bad on a white background. How can i do this ? <a href="https://i.sstatic.net/XDnlJ.png" rel="noreferrer"><img src="https://i.sstatic.net/XDnlJ.png" alt="enter image description here"></a></p> <p><a href="https://i....
8,834
2,726,561
2022-05-26 15:40:38
43,015,533
13
2017-03-25 10:59:21
712,649
2017-03-25 10:59:21
https://stackoverflow.com/q/43015262
https://stackoverflow.com/a/43015533
<p>The syntax highlighting comes from <code>PSReadLine</code>. To set the foreground color for <code>Command</code> tokens (which shows in yellow by default), use <code>Set-PSReadLineOption</code>:</p> <pre><code>Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkGreen </code></pre> <p>Place that statement ...
<p>The syntax highlighting comes from <code>PSReadLine</code>. To set the foreground color for <code>Command</code> tokens (which shows in yellow by default), use <code>Set-PSReadLineOption</code>:</p> <pre><code>Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkGreen </code></pre> <p>Place that statement ...
526
powershell
<h1>Change color of first input word in PowerShell</h1> <p>I want to change color of first console statement from yellow to some another color because it looks bad on a white background. How can i do this ? <a href="https://i.sstatic.net/XDnlJ.png" rel="noreferrer"><img src="https://i.sstatic.net/XDnlJ.png" alt="enter ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,123
bash
# Change color of first input word in PowerShell I want to change color of first console statement from yellow to some another color because it looks bad on a white background. How can i do this ? [![enter image description here](https://i.sstatic.net/XDnlJ.png)](https://i.sstatic.net/XDnlJ.png) [![enter image descri...
The syntax highlighting comes from `PSReadLine`. To set the foreground color for `Command` tokens (which shows in yellow by default), use `Set-PSReadLineOption`: ``` Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkGreen ``` Place that statement in your `$profile` to have it run every time you launch Powe...
36305861
How to install Ruby on docker?
16
2016-03-30 10:15:56
<p>I am trying to install ruby on docker. I could install the 1.9 versions but it is not possible to install the latest version such as 2.2.0 and above. I am actually trying to set up calabash on docker. Have tried <a href="https://stackoverflow.com/questions/16222738/how-do-i-install-ruby-2-0-0-correctly-on-ubuntu-12-...
43,923
5,023,800
2023-11-02 16:38:40
36,306,240
13
2016-03-30 10:32:35
6,309
2020-12-09 10:21:44
https://stackoverflow.com/q/36305861
https://stackoverflow.com/a/36306240
<p>You could start view a dockerfile starting with:</p> <pre><code># 2016 FROM ruby:2.3.0 # 2020 # Import your ruby version FROM ruby:2.7.1 # Install bundler gem RUN gem install bundler # Assign a work directory WORKDIR /work </code></pre> <p>That would use the <a href="https://hub.docker.com/_/ruby/" rel="nofollow no...
<p>You could start view a dockerfile starting with:</p> <pre><code># 2016 FROM ruby:2.3.0 # 2020 # Import your ruby version FROM ruby:2.7.1 # Install bundler gem RUN gem install bundler # Assign a work directory WORKDIR /work </code></pre> <p>That would use the <a href="https://hub.docker.com/_/ruby/" rel="nofollow no...
12, 4984, 90304, 105995, 111862
calabash-android, docker, docker-machine, ruby, ruby-on-rails
<h1>How to install Ruby on docker?</h1> <p>I am trying to install ruby on docker. I could install the 1.9 versions but it is not possible to install the latest version such as 2.2.0 and above. I am actually trying to set up calabash on docker. Have tried <a href="https://stackoverflow.com/questions/16222738/how-do-i-in...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,124
bash
# How to install Ruby on docker? I am trying to install ruby on docker. I could install the 1.9 versions but it is not possible to install the latest version such as 2.2.0 and above. I am actually trying to set up calabash on docker. Have tried [this](https://stackoverflow.com/questions/16222738/how-do-i-install-ruby-...
You could start view a dockerfile starting with: ``` # 2016 FROM ruby:2.3.0 # 2020 # Import your ruby version FROM ruby:2.7.1 # Install bundler gem RUN gem install bundler # Assign a work directory WORKDIR /work ``` That would use the [docker image ruby](https://hub.docker.com/_/ruby/), with ruby already installed. ...
28096697
how to get current terminal color pair in bash
16
2015-01-22 19:04:10
<p>I would like to query and store the current terminal color pair in BASH e.g.:</p> <pre><code>#!/bin/bash #some ANSI colour escape sequences red="\033[0;31m" grn="\033[0;32m" blu="\033[0;34m" def="\033[0;00m" # default echo -e "Change to ${red} red to ${def} default to ${blu} blue." # now store the current color...
8,937
4,483,909
2022-03-03 07:12:31
28,334,701
13
2015-02-05 01:27:28
4,518,274
2015-02-05 01:27:28
https://stackoverflow.com/q/28096697
https://stackoverflow.com/a/28334701
<p>The question was about the current <em>color</em>, not the cursor <em>position</em>.</p> <p>Both are "nonstandard" (though the latter, cursor position report is implemented by anything which has a valid claim to "VT100 emulator").</p> <p>However, xterm implements a set of escape sequences referred to as <em>dynami...
<p>The question was about the current <em>color</em>, not the cursor <em>position</em>.</p> <p>Both are "nonstandard" (though the latter, cursor position report is implemented by anything which has a valid claim to "VT100 emulator").</p> <p>However, xterm implements a set of escape sequences referred to as <em>dynami...
387, 46328
ansi-colors, bash
<h1>how to get current terminal color pair in bash</h1> <p>I would like to query and store the current terminal color pair in BASH e.g.:</p> <pre><code>#!/bin/bash #some ANSI colour escape sequences red="\033[0;31m" grn="\033[0;32m" blu="\033[0;34m" def="\033[0;00m" # default echo -e "Change to ${red} red to ${def}...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,125
bash
# how to get current terminal color pair in bash I would like to query and store the current terminal color pair in BASH e.g.: ``` #!/bin/bash #some ANSI colour escape sequences red="\033[0;31m" grn="\033[0;32m" blu="\033[0;34m" def="\033[0;00m" # default echo -e "Change to ${red} red to ${def} default to ${blu} b...
The question was about the current *color*, not the cursor *position*. Both are "nonstandard" (though the latter, cursor position report is implemented by anything which has a valid claim to "VT100 emulator"). However, xterm implements a set of escape sequences referred to as *dynamic colors*, which predate the ANSI ...
6919403
Set clipboard to image - pbcopy
16
2011-08-02 22:20:06
<p>How do you set an image as the clipboard with pbcopy?</p> <p>This doesn't work:</p> <pre><code>cat image.png | pbcopy </code></pre>
7,879
640,584
2024-01-17 23:02:19
21,352,303
13
2014-01-25 15:16:07
148,668
2014-01-25 15:16:07
https://stackoverflow.com/q/6919403
https://stackoverflow.com/a/21352303
<p>As stated, this won't work with <code>pbcopy</code>, but you can write a little objective-c program to do this: <a href="http://www.alecjacobson.com/weblog/?p=3816" rel="noreferrer">http://www.alecjacobson.com/weblog/?p=3816</a> . Then you can issue:</p> <pre><code>cat image.png | impbcopy - </code></pre>
<p>As stated, this won't work with <code>pbcopy</code>, but you can write a little objective-c program to do this: <a href="http://www.alecjacobson.com/weblog/?p=3816" rel="noreferrer">http://www.alecjacobson.com/weblog/?p=3816</a> . Then you can issue:</p> <pre><code>cat image.png | impbcopy - </code></pre>
369, 387, 524, 26252
bash, clipboard, macos, pbcopy
<h1>Set clipboard to image - pbcopy</h1> <p>How do you set an image as the clipboard with pbcopy?</p> <p>This doesn't work:</p> <pre><code>cat image.png | pbcopy </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,126
bash
# Set clipboard to image - pbcopy How do you set an image as the clipboard with pbcopy? This doesn't work: ``` cat image.png | pbcopy ```
As stated, this won't work with `pbcopy`, but you can write a little objective-c program to do this: <http://www.alecjacobson.com/weblog/?p=3816> . Then you can issue: ``` cat image.png | impbcopy - ```
20161140
How to make rsync read SRC from STDIN?
16
2013-11-23 10:23:03
<p>I want to dump my MySQL database and make daily backups with <code>rsync</code>.</p> <p>First approach I came up with is something like <code>mysqldump -ufoo -pbar baz &gt; /var/tmp/baz.sql &amp;&amp; rsync /var/tmp/baz.sql /backup/ &amp;&amp; rm /var/tmp/baz.sql</code>.</p> <p>Then I started to wonder if it is po...
12,843
1,659,619
2015-11-06 15:59:28
20,161,267
13
2013-11-23 10:36:44
296,974
2015-11-06 06:35:55
https://stackoverflow.com/q/20161140
https://stackoverflow.com/a/20161267
<p>This is right, it doesn't work this way. It is because <code>rsync</code> is made to transfer complete file trees from <code>A</code> to <code>B</code>.</p> <p>Because of the way <code>rsync</code> works, it cannot work, because <code>rsync</code> calculates several checksums before choosing to transfer a particula...
<p>This is right, it doesn't work this way. It is because <code>rsync</code> is made to transfer complete file trees from <code>A</code> to <code>B</code>.</p> <p>Because of the way <code>rsync</code> works, it cannot work, because <code>rsync</code> calculates several checksums before choosing to transfer a particula...
58, 390, 1159, 5813
linux, pipe, rsync, shell
<h1>How to make rsync read SRC from STDIN?</h1> <p>I want to dump my MySQL database and make daily backups with <code>rsync</code>.</p> <p>First approach I came up with is something like <code>mysqldump -ufoo -pbar baz &gt; /var/tmp/baz.sql &amp;&amp; rsync /var/tmp/baz.sql /backup/ &amp;&amp; rm /var/tmp/baz.sql</cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,127
bash
# How to make rsync read SRC from STDIN? I want to dump my MySQL database and make daily backups with `rsync`. First approach I came up with is something like `mysqldump -ufoo -pbar baz > /var/tmp/baz.sql && rsync /var/tmp/baz.sql /backup/ && rm /var/tmp/baz.sql`. Then I started to wonder if it is possible not to us...
This is right, it doesn't work this way. It is because `rsync` is made to transfer complete file trees from `A` to `B`. Because of the way `rsync` works, it cannot work, because `rsync` calculates several checksums before choosing to transfer a particular file (or parts of it), and doing so in only 2 iterations (ping-...
17997214
Why does the redirection symbol change the behavior of ls?
16
2013-08-01 14:44:54
<p>So, I have always had doubts about how redirection works in the following situations:</p> <ol> <li><p>I type "ls" and all the filenames are separated by white spaces:</p> <pre><code>test$ touch a b c test$ ls a b c </code></pre></li> <li><p>I use a ">" to redirect STDOUT to a file:</p> <pre><code>test$ ls &gt; ls...
654
1,337,629
2013-08-03 06:28:12
17,997,277
13
2013-08-01 14:47:02
298,225
2013-08-01 14:54:00
https://stackoverflow.com/q/17997214
https://stackoverflow.com/a/17997277
<p><code>ls</code> tests its output stream to see whether it is a terminal, and it modifies its behavior depending on that.</p> <p>This is documented; the <code>man</code> page for <code>ls</code> documents several things that depend on whether the output is a terminal:</p> <ul> <li>If the output is a terminal, <code...
<p><code>ls</code> tests its output stream to see whether it is a terminal, and it modifies its behavior depending on that.</p> <p>This is documented; the <code>man</code> page for <code>ls</code> documents several things that depend on whether the output is a terminal:</p> <ul> <li>If the output is a terminal, <code...
34, 58, 387
bash, linux, unix
<h1>Why does the redirection symbol change the behavior of ls?</h1> <p>So, I have always had doubts about how redirection works in the following situations:</p> <ol> <li><p>I type "ls" and all the filenames are separated by white spaces:</p> <pre><code>test$ touch a b c test$ ls a b c </code></pre></li> <li><p>I use ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,128
bash
# Why does the redirection symbol change the behavior of ls? So, I have always had doubts about how redirection works in the following situations: 1. I type "ls" and all the filenames are separated by white spaces: ``` test$ touch a b c test$ ls a b c ``` 2. I use a ">" to redirect STDOUT to a file: ...
`ls` tests its output stream to see whether it is a terminal, and it modifies its behavior depending on that. This is documented; the `man` page for `ls` documents several things that depend on whether the output is a terminal: - If the output is a terminal, `-C` (for multi-column output) is a default, otherwise `-1`...
17100244
How do I change the order in which grep looks at files/prints results?
16
2013-06-14 02:32:34
<p>I have a directory with a bunch of files with numerical filenames. They don't have leading zeroes, so if I do something like <code>grep hello *</code> in that directory I might get something like this:</p> <pre><code>22:hello, world! 6:hello 62:"Say hello to them for me." </code></pre> <p>I'd rather have the resul...
15,976
1,945,088
2022-04-04 17:53:45
17,100,283
13
2013-06-14 02:37:14
68,587
2013-06-14 02:37:14
https://stackoverflow.com/q/17100244
https://stackoverflow.com/a/17100283
<pre><code>ls * | sort -n | xargs -d '\n' grep hello </code></pre>
<pre><code>ls * | sort -n | xargs -d '\n' grep hello </code></pre>
58, 387, 1271, 4072
bash, gnu, grep, linux
<h1>How do I change the order in which grep looks at files/prints results?</h1> <p>I have a directory with a bunch of files with numerical filenames. They don't have leading zeroes, so if I do something like <code>grep hello *</code> in that directory I might get something like this:</p> <pre><code>22:hello, world! 6:...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,129
bash
# How do I change the order in which grep looks at files/prints results? I have a directory with a bunch of files with numerical filenames. They don't have leading zeroes, so if I do something like `grep hello *` in that directory I might get something like this: ``` 22:hello, world! 6:hello 62:"Say hello to them for...
``` ls * | sort -n | xargs -d '\n' grep hello ```
15343561
Bash: Running the same program over multiple cores
16
2013-03-11 16:24:12
<p>I have access to a machine where I have access to 10 of the cores -- and I would like to actually use them. What I am used to doing on my own machine would be something like this:</p> <pre><code>for f in *.fa; do myProgram (options) "./$f" "./$f.tmp" done </code></pre> <p>I have 10 files I'd like to do this on -...
35,782
1,689,624
2015-02-11 11:52:36
15,344,181
13
2013-03-11 16:55:08
1,126,841
2013-03-11 17:22:46
https://stackoverflow.com/q/15343561
https://stackoverflow.com/a/15344181
<p>You could use</p> <pre><code>for f in *.fa; do myProgram (options) "./$f" "./$f.tmp" &amp; done wait </code></pre> <p>which would start all of you jobs in parallel, then wait until they <em>all</em> complete before moving on. In the case where you have more jobs than cores, you would start all of them and let ...
<p>You could use</p> <pre><code>for f in *.fa; do myProgram (options) "./$f" "./$f.tmp" &amp; done wait </code></pre> <p>which would start all of you jobs in parallel, then wait until they <em>all</em> complete before moving on. In the case where you have more jobs than cores, you would start all of them and let ...
58, 353, 387, 15475
bash, linux, multiprocessing, parallel-processing
<h1>Bash: Running the same program over multiple cores</h1> <p>I have access to a machine where I have access to 10 of the cores -- and I would like to actually use them. What I am used to doing on my own machine would be something like this:</p> <pre><code>for f in *.fa; do myProgram (options) "./$f" "./$f.tmp" don...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,130
bash
# Bash: Running the same program over multiple cores I have access to a machine where I have access to 10 of the cores -- and I would like to actually use them. What I am used to doing on my own machine would be something like this: ``` for f in *.fa; do myProgram (options) "./$f" "./$f.tmp" done ``` I have 10 fil...
You could use ``` for f in *.fa; do myProgram (options) "./$f" "./$f.tmp" & done wait ``` which would start all of you jobs in parallel, then wait until they *all* complete before moving on. In the case where you have more jobs than cores, you would start all of them and let your OS scheduler worry about swapping...
14552466
Why do long results from Git commands kill my PowerShell prompt?
16
2013-01-27 21:23:36
<p>I am using Git Shell (the module for PowerShell) on Windows. It's the one that got installed when I installed Git for Windows. When I run a command that results in a lot of text such as <code>git log</code> I get a page of results and then a ":" at the bottom of the screen. I guess it's a continuation prompt becau...
1,364
1,499,273
2017-04-25 20:36:16
14,554,035
13
2013-01-28 00:47:42
413,399
2013-01-28 05:02:12
https://stackoverflow.com/q/14552466
https://stackoverflow.com/a/14554035
<p>Several of the git commands use a pager to allow you to view one screen full of information at a time. The one that come with git is usually <code>less</code> (<a href="http://en.wikipedia.org/wiki/Less_%28Unix%29" rel="noreferrer">more info</a>). You can visit the link for common commands, but as you've found the...
<p>Several of the git commands use a pager to allow you to view one screen full of information at a time. The one that come with git is usually <code>less</code> (<a href="http://en.wikipedia.org/wiki/Less_%28Unix%29" rel="noreferrer">more info</a>). You can visit the link for common commands, but as you've found the...
64, 119, 526
git, powershell, windows
<h1>Why do long results from Git commands kill my PowerShell prompt?</h1> <p>I am using Git Shell (the module for PowerShell) on Windows. It's the one that got installed when I installed Git for Windows. When I run a command that results in a lot of text such as <code>git log</code> I get a page of results and then a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,131
bash
# Why do long results from Git commands kill my PowerShell prompt? I am using Git Shell (the module for PowerShell) on Windows. It's the one that got installed when I installed Git for Windows. When I run a command that results in a lot of text such as `git log` I get a page of results and then a ":" at the bottom of ...
Several of the git commands use a pager to allow you to view one screen full of information at a time. The one that come with git is usually `less` ([more info](http://en.wikipedia.org/wiki/Less_%28Unix%29)). You can visit the link for common commands, but as you've found the most important is `q` to quit to get back t...
9506437
Python subprocess call returns "command not found", Terminal executes correctly
16
2012-02-29 20:53:06
<p>I am trying to run gphoto2 from python but, with no succes. It just returns command not found. gphoto is installed correctly, as in, the commands work fine in Terminal.</p> <pre><code>p = subprocess.Popen(['gphoto2'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, executable='/bin/bash') for lin...
37,498
1,143,155
2012-02-29 22:32:15
9,506,481
13
2012-02-29 20:56:02
190,597
2012-02-29 20:57:07
https://stackoverflow.com/q/9506437
https://stackoverflow.com/a/9506481
<p>When using <code>shell = True</code>, the first argument to <code>subprocess.Popen</code> should be a string, not a list:</p> <pre><code>p = subprocess.Popen('gphoto2', shell=True, ...) </code></pre> <p>However, using <code>shell = True</code> should be avoided if possible since it can be a <a href="http://docs.py...
<p>When using <code>shell = True</code>, the first argument to <code>subprocess.Popen</code> should be a string, not a list:</p> <pre><code>p = subprocess.Popen('gphoto2', shell=True, ...) </code></pre> <p>However, using <code>shell = True</code> should be avoided if possible since it can be a <a href="http://docs.py...
16, 390, 391, 2348
python, shell, subprocess, terminal
<h1>Python subprocess call returns "command not found", Terminal executes correctly</h1> <p>I am trying to run gphoto2 from python but, with no succes. It just returns command not found. gphoto is installed correctly, as in, the commands work fine in Terminal.</p> <pre><code>p = subprocess.Popen(['gphoto2'], shell=Tru...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,132
bash
# Python subprocess call returns "command not found", Terminal executes correctly I am trying to run gphoto2 from python but, with no succes. It just returns command not found. gphoto is installed correctly, as in, the commands work fine in Terminal. ``` p = subprocess.Popen(['gphoto2'], shell=True, stdout=subprocess...
When using `shell = True`, the first argument to `subprocess.Popen` should be a string, not a list: ``` p = subprocess.Popen('gphoto2', shell=True, ...) ``` However, using `shell = True` should be avoided if possible since it can be a [security risk](http://docs.python.org/library/subprocess.html#frequently-used-argu...
9337489
Brace expansion with a Bash variable - {0..$foo}
16
2012-02-18 00:56:39
<pre><code>WEEKS_TO_SAVE=4 mkdir -p weekly.{0..$WEEKS_TO_SAVE} </code></pre> <p>gives me a folder called weekly.{0..4}</p> <p>Is there a secret to curly brace expansion while creating folders I'm missing?</p>
6,734
1,107,232
2024-04-21 09:35:46
9,338,515
13
2012-02-18 04:21:37
348,785
2024-04-21 09:35:46
https://stackoverflow.com/q/9337489
https://stackoverflow.com/a/9338515
<p><code>bash</code> does <em>brace expansion</em> before <em>variable expansion,</em> so you get <code>weekly.{0..4}</code>.<br /> Because the result is predictable and safe (<strong>don't trust user input</strong>), you can use <code>eval</code> in your case:</p> <pre><code>$ WEEKS_TO_SAVE=4 $ eval &quot;mkdir -p wee...
<p><code>bash</code> does <em>brace expansion</em> before <em>variable expansion,</em> so you get <code>weekly.{0..4}</code>.<br /> Because the result is predictable and safe (<strong>don't trust user input</strong>), you can use <code>eval</code> in your case:</p> <pre><code>$ WEEKS_TO_SAVE=4 $ eval &quot;mkdir -p wee...
387, 41340
bash, brace-expansion
<h1>Brace expansion with a Bash variable - {0..$foo}</h1> <pre><code>WEEKS_TO_SAVE=4 mkdir -p weekly.{0..$WEEKS_TO_SAVE} </code></pre> <p>gives me a folder called weekly.{0..4}</p> <p>Is there a secret to curly brace expansion while creating folders I'm missing?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,133
bash
# Brace expansion with a Bash variable - {0..$foo} ``` WEEKS_TO_SAVE=4 mkdir -p weekly.{0..$WEEKS_TO_SAVE} ``` gives me a folder called weekly.{0..4} Is there a secret to curly brace expansion while creating folders I'm missing?
`bash` does *brace expansion* before *variable expansion,* so you get `weekly.{0..4}`. Because the result is predictable and safe (**don't trust user input**), you can use `eval` in your case: ``` $ WEEKS_TO_SAVE=4 $ eval "mkdir -p weekly.{0..$((WEEKS_TO_SAVE))}" ``` **note**: 1. `eval` is evil 2. use `eval` caref...
7767447
How can I force PHP Version for Command Line?
16
2011-10-14 12:18:07
<p>I am hosted with 1and1.com, and I have setup my files to be parsed with php5 using <code>.htaccess</code>.</p> <p>But that only works in apache, and not in command line, which defaults to the server default php4.</p> <p>So currently I can not setup <em>cron jobs</em> to run my code as php5. Any ideas?</p>
41,089
510,785
2020-08-15 18:10:09
7,767,484
13
2011-10-14 12:21:21
889,949
2011-10-14 12:21:21
https://stackoverflow.com/q/7767447
https://stackoverflow.com/a/7767484
<p>If both are installed, all you need to do is run the script using the relevant PHP binary.</p> <p>So for example:</p> <pre><code> // Runs using the PHP binary located at /usr/bin/php * * * * * root /usr/bin/php -n "/path/to/script.php" </code></pre> <p>or</p> <pre><code> // Runs using the PHP binary located at ...
<p>If both are installed, all you need to do is run the script using the relevant PHP binary.</p> <p>So for example:</p> <pre><code> // Runs using the PHP binary located at /usr/bin/php * * * * * root /usr/bin/php -n "/path/to/script.php" </code></pre> <p>or</p> <pre><code> // Runs using the PHP binary located at ...
5, 390, 601, 11225
command-line-interface, cron, php, shell
<h1>How can I force PHP Version for Command Line?</h1> <p>I am hosted with 1and1.com, and I have setup my files to be parsed with php5 using <code>.htaccess</code>.</p> <p>But that only works in apache, and not in command line, which defaults to the server default php4.</p> <p>So currently I can not setup <em>cron jo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,134
bash
# How can I force PHP Version for Command Line? I am hosted with 1and1.com, and I have setup my files to be parsed with php5 using `.htaccess`. But that only works in apache, and not in command line, which defaults to the server default php4. So currently I can not setup *cron jobs* to run my code as php5. Any ideas...
If both are installed, all you need to do is run the script using the relevant PHP binary. So for example: ``` // Runs using the PHP binary located at /usr/bin/php * * * * * root /usr/bin/php -n "/path/to/script.php" ``` or ``` // Runs using the PHP binary located at /var/php5 * * * * * root /var/php5 -n "/path...
3704549
Visual Studio - Post Build Event - Throwing Errors
16
2010-09-13 21:26:16
<p>I've got a nice power-shell driven post-build script that does some magic mumbo-jumbo for pulling all our plugins into the correct location after they're compiled and sorting out thier dependencies with the master-project of the solution.</p> <p>My problem is, occasionally when I do something stupid, I can end up i...
7,641
317,975
2016-02-09 10:16:17
3,704,584
13
2010-09-13 21:32:11
404,854
2010-09-14 05:55:02
https://stackoverflow.com/q/3704549
https://stackoverflow.com/a/3704584
<p>Here are two approaches for interrupting the build when a PowerShell script errors.</p> <h2>Use <code>exit()</code> to terminate the PowerShell process</h2> <p>To return a status code from the script which, if non-zero, will show up in the error list, use the following:</p> <pre><code>exit(45) # or any other non-...
<p>Here are two approaches for interrupting the build when a PowerShell script errors.</p> <h2>Use <code>exit()</code> to terminate the PowerShell process</h2> <p>To return a status code from the script which, if non-zero, will show up in the error list, use the following:</p> <pre><code>exit(45) # or any other non-...
526, 31225, 33953
post-build-event, powershell, visual-studio
<h1>Visual Studio - Post Build Event - Throwing Errors</h1> <p>I've got a nice power-shell driven post-build script that does some magic mumbo-jumbo for pulling all our plugins into the correct location after they're compiled and sorting out thier dependencies with the master-project of the solution.</p> <p>My problem...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,135
bash
# Visual Studio - Post Build Event - Throwing Errors I've got a nice power-shell driven post-build script that does some magic mumbo-jumbo for pulling all our plugins into the correct location after they're compiled and sorting out thier dependencies with the master-project of the solution. My problem is, occasionall...
Here are two approaches for interrupting the build when a PowerShell script errors. ## Use `exit()` to terminate the PowerShell process To return a status code from the script which, if non-zero, will show up in the error list, use the following: ``` exit(45) # or any other non-zero number, for that matter. ``` Thi...
911816
Detecting the output stream type of a shell script
16
2009-05-26 17:26:12
<p>I'm writing a shell script that uses ANSI color characters on the command line.</p> <p>Example: <strong>example.sh</strong></p> <pre><code>#!/bin/tcsh printf "\033[31m Success Color is awesome!\033[0m" </code></pre> <p>My problem is when doing:</p> <pre><code>$ ./example.sh &gt; out </code></pre> <p>or </p> <p...
6,741
3,415
2009-05-27 21:48:26
911,854
13
2009-05-26 17:39:22
57,301
2009-05-26 18:00:49
https://stackoverflow.com/q/911816
https://stackoverflow.com/a/911854
<p>See this <a href="https://stackoverflow.com/questions/911168/detect-if-shell-script-is-running-through-a-pipe">previous SO question</a>, which covers bash. Tcsh provides the same functionality with <code>filetest -t 1</code> to see if standard output is a terminal. If it is, then print the color stuff, else leave it...
<p>See this <a href="https://stackoverflow.com/questions/911168/detect-if-shell-script-is-running-through-a-pipe">previous SO question</a>, which covers bash. Tcsh provides the same functionality with <code>filetest -t 1</code> to see if standard output is a terminal. If it is, then print the color stuff, else leave it...
34, 58, 390, 531
linux, scripting, shell, unix
<h1>Detecting the output stream type of a shell script</h1> <p>I'm writing a shell script that uses ANSI color characters on the command line.</p> <p>Example: <strong>example.sh</strong></p> <pre><code>#!/bin/tcsh printf "\033[31m Success Color is awesome!\033[0m" </code></pre> <p>My problem is when doing:</p> <pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,136
bash
# Detecting the output stream type of a shell script I'm writing a shell script that uses ANSI color characters on the command line. Example: **example.sh** ``` #!/bin/tcsh printf "\033[31m Success Color is awesome!\033[0m" ``` My problem is when doing: ``` $ ./example.sh > out ``` or ``` $./example.sh | grep ``...
See this [previous SO question](https://stackoverflow.com/questions/911168/detect-if-shell-script-is-running-through-a-pipe), which covers bash. Tcsh provides the same functionality with `filetest -t 1` to see if standard output is a terminal. If it is, then print the color stuff, else leave it out. Here's tcsh: ``` #...
67836594
How to get size of hidden files with "du"
15
2021-06-04 11:40:09
<p>I've been using &quot;du -hs ~/&quot; to get the size of my total home directory with outputs 20GB, and I've been trying to where large files that I can delete to free up some space. However, when using &quot;du -hs ~/*&quot; I get numerous outputted files <em>but</em> they don't sum to 20GB. There are a few hidden ...
32,323
6,300,467
2024-04-10 17:26:43
67,836,667
13
2021-06-04 11:46:01
261,142
2021-06-04 11:46:01
https://stackoverflow.com/q/67836594
https://stackoverflow.com/a/67836667
<p>The problem lies not with <code>du</code> but with how the shell resolves <code>*</code> - it does not include files that start with a period. To remedy, just mention those files explicitly:</p> <pre><code>du -hs ~/* ~/.* </code></pre> <p>In order to find the largest of those files, simply pipe the output to a <code...
<p>The problem lies not with <code>du</code> but with how the shell resolves <code>*</code> - it does not include files that start with a period. To remedy, just mention those files explicitly:</p> <pre><code>du -hs ~/* ~/.* </code></pre> <p>In order to find the largest of those files, simply pipe the output to a <code...
387, 390, 3039, 26163
bash, diskspace, du, shell
<h1>How to get size of hidden files with "du"</h1> <p>I've been using &quot;du -hs ~/&quot; to get the size of my total home directory with outputs 20GB, and I've been trying to where large files that I can delete to free up some space. However, when using &quot;du -hs ~/*&quot; I get numerous outputted files <em>but</...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,137
bash
# How to get size of hidden files with "du" I've been using "du -hs ~/" to get the size of my total home directory with outputs 20GB, and I've been trying to where large files that I can delete to free up some space. However, when using "du -hs ~/*" I get numerous outputted files *but* they don't sum to 20GB. There ar...
The problem lies not with `du` but with how the shell resolves `*` - it does not include files that start with a period. To remedy, just mention those files explicitly: ``` du -hs ~/* ~/.* ``` In order to find the largest of those files, simply pipe the output to a `sort` command, with an optional `tail` appended: `...
55637169
Invoke-Sqlcmd with AAD authentication
15
2019-04-11 16:24:26
<p>In an Azure DevOps 'release pipeline', I provision Azure resources - including SQLServer databases - and try to configure access to databases using managed identities.</p> <p>After ensuring the DevOps service principal is a member of the AAD group defined as AAD administrator for the database server, I need to run ...
21,586
295,203
2025-07-23 13:29:43
66,880,422
13
2021-03-31 01:25:27
30,809
2025-07-23 13:29:43
https://stackoverflow.com/q/55637169
https://stackoverflow.com/a/66880422
<p>To authenticate with AAD, you'll need the following:</p> <ul> <li>An Azure Service principal</li> <li>A database where the Service Principal is either the Azure AD Administrator, or assigned to the database</li> <li>An Azure DevOps Service Connection that uses this Service Principal</li> </ul> <p>In your Azure DevOp...
<p>To authenticate with AAD, you'll need the following:</p> <ul> <li>An Azure Service principal</li> <li>A database where the Service Principal is either the Azure AD Administrator, or assigned to the database</li> <li>An Azure DevOps Service Connection that uses this Service Principal</li> </ul> <p>In your Azure DevOp...
526, 81879, 93887, 115169, 116537
azure-active-directory, azure-devops, azure-powershell, azure-sql-database, powershell
<h1>Invoke-Sqlcmd with AAD authentication</h1> <p>In an Azure DevOps 'release pipeline', I provision Azure resources - including SQLServer databases - and try to configure access to databases using managed identities.</p> <p>After ensuring the DevOps service principal is a member of the AAD group defined as AAD admini...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,138
bash
# Invoke-Sqlcmd with AAD authentication In an Azure DevOps 'release pipeline', I provision Azure resources - including SQLServer databases - and try to configure access to databases using managed identities. After ensuring the DevOps service principal is a member of the AAD group defined as AAD administrator for the ...
To authenticate with AAD, you'll need the following: - An Azure Service principal - A database where the Service Principal is either the Azure AD Administrator, or assigned to the database - An Azure DevOps Service Connection that uses this Service Principal In your Azure DevOps pipeline, use an Azure PowerShell Task...
41619629
Exit code of traps in Bash
15
2017-01-12 17:39:45
<p>This is <code>myscript.sh</code>:</p> <pre><code>#!/bin/bash function mytrap { echo "Trapped!" } trap mytrap EXIT exit 3 </code></pre> <p>And when I run it:</p> <pre><code>&gt; ./myscript.sh echo $? 3 </code></pre> <p>Why is the exit code of the script the exit code with the trap the same as without it? Us...
10,713
647,991
2018-10-15 23:32:40
41,619,743
13
2017-01-12 17:47:03
5,291,015
2017-01-12 18:01:25
https://stackoverflow.com/q/41619629
https://stackoverflow.com/a/41619743
<p>Look the reference from the below <code>man bash</code> page,</p> <blockquote> <p>exit [n] Cause the shell to exit with a status of n. If n is omitted, the exit status is that of the last command executed. A trap on <strong>EXIT</strong> is executed <strong><em>before</em></strong> the shell terminates.</p> </b...
<p>Look the reference from the below <code>man bash</code> page,</p> <blockquote> <p>exit [n] Cause the shell to exit with a status of n. If n is omitted, the exit status is that of the last command executed. A trap on <strong>EXIT</strong> is executed <strong><em>before</em></strong> the shell terminates.</p> </b...
387, 2481, 10021, 124485
bash, bash-trap, exit-code, signals
<h1>Exit code of traps in Bash</h1> <p>This is <code>myscript.sh</code>:</p> <pre><code>#!/bin/bash function mytrap { echo "Trapped!" } trap mytrap EXIT exit 3 </code></pre> <p>And when I run it:</p> <pre><code>&gt; ./myscript.sh echo $? 3 </code></pre> <p>Why is the exit code of the script the exit code with...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,139
bash
# Exit code of traps in Bash This is `myscript.sh`: ``` #!/bin/bash function mytrap { echo "Trapped!" } trap mytrap EXIT exit 3 ``` And when I run it: ``` > ./myscript.sh echo $? 3 ``` Why is the exit code of the script the exit code with the trap the same as without it? Usually, a function returns implicitl...
Look the reference from the below `man bash` page, > exit [n] > Cause the shell to exit with a status of n. If n is omitted, the exit status is that of the last command executed. A trap on **EXIT** is executed ***before*** the shell terminates. You have the debug version of the script to prove that, ``` + trap mytra...
31142363
Unix: What does cat by itself do?
15
2015-06-30 15:24:24
<p>I saw the line <code>data=$(cat)</code> in a bash script (just declaring an empty variable) and am mystified as to what that could possibly do. </p> <p>I read the man pages, but it doesn't have an example or explanation of this. Does this capture stdin or something? Any documentation on this?</p> <p>EDIT: Speci...
2,546
3,845,747
2017-06-23 23:54:47
31,142,432
13
2015-06-30 15:27:21
874,188
2015-06-30 15:41:49
https://stackoverflow.com/q/31142363
https://stackoverflow.com/a/31142432
<p><code>cat</code> will catenate its input to its output.</p> <p>In the context of the variable capture you posted, the effect is to assign the statement's (or containing script's) standard input to the variable.</p> <p>The command substitution <code>$(command)</code> will return the command's output; the assignment...
<p><code>cat</code> will catenate its input to its output.</p> <p>In the context of the variable capture you posted, the effect is to assign the statement's (or containing script's) standard input to the variable.</p> <p>The command substitution <code>$(command)</code> will return the command's output; the assignment...
34, 58, 387, 390
bash, linux, shell, unix
<h1>Unix: What does cat by itself do?</h1> <p>I saw the line <code>data=$(cat)</code> in a bash script (just declaring an empty variable) and am mystified as to what that could possibly do. </p> <p>I read the man pages, but it doesn't have an example or explanation of this. Does this capture stdin or something? Any...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,140
bash
# Unix: What does cat by itself do? I saw the line `data=$(cat)` in a bash script (just declaring an empty variable) and am mystified as to what that could possibly do. I read the man pages, but it doesn't have an example or explanation of this. Does this capture stdin or something? Any documentation on this? EDIT: ...
`cat` will catenate its input to its output. In the context of the variable capture you posted, the effect is to assign the statement's (or containing script's) standard input to the variable. The command substitution `$(command)` will return the command's output; the assignment will assign the substituted string to ...
27768082
How can I list and print files in a directory?
15
2015-01-04 17:08:24
<p>I'm trying this but it doesn't print anything:</p> <pre><code>Dir -Recurse "C:\temp" | Select Fullname </code></pre> <p>Looks like this command just selects file names. I want to see them in console.</p>
25,460
4,395,371
2020-01-15 19:52:31
27,768,126
13
2015-01-04 17:12:33
166,712
2015-01-04 17:12:33
https://stackoverflow.com/q/27768082
https://stackoverflow.com/a/27768126
<p>Take a look at <a href="http://technet.microsoft.com/en-us/library/hh849800.aspx" rel="noreferrer"><code>Get-Childitem</code></a></p> <pre><code>Dir -Recurse c:\path\ | Get-Childitem </code></pre>
<p>Take a look at <a href="http://technet.microsoft.com/en-us/library/hh849800.aspx" rel="noreferrer"><code>Get-Childitem</code></a></p> <pre><code>Dir -Recurse c:\path\ | Get-Childitem </code></pre>
526
powershell
<h1>How can I list and print files in a directory?</h1> <p>I'm trying this but it doesn't print anything:</p> <pre><code>Dir -Recurse "C:\temp" | Select Fullname </code></pre> <p>Looks like this command just selects file names. I want to see them in console.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,141
bash
# How can I list and print files in a directory? I'm trying this but it doesn't print anything: ``` Dir -Recurse "C:\temp" | Select Fullname ``` Looks like this command just selects file names. I want to see them in console.
Take a look at [`Get-Childitem`](http://technet.microsoft.com/en-us/library/hh849800.aspx) ``` Dir -Recurse c:\path\ | Get-Childitem ```
26934506
Uploading files to s3 using s3cmd in parallel
15
2014-11-14 16:26:19
<p>I've got a whole heap of files on a server, and I want to upload these onto S3. The files are stored with a .data extension, but really they're just a bunch of jpegs,pngs,zips or pdfs.</p> <p>I've already written a short script which finds the mime type and uploads them onto S3 and that works but it's slow. Is ther...
12,826
346,271
2018-05-02 10:39:57
26,939,884
13
2014-11-14 22:25:51
363,028
2014-11-14 22:25:51
https://stackoverflow.com/q/26934506
https://stackoverflow.com/a/26939884
<p>You are clearly skilled in writing shell, and extremely close to a solution:</p> <pre><code>s3upload_single() { n=$1 data=".data" extension=`file $n | cut -d ' ' -f2 | awk '{print tolower($0)}'` mimetype=`file --mime-type $n | cut -d ' ' -f2` fullpath=`readlink -f $n` changed="${fullpath/...
<p>You are clearly skilled in writing shell, and extremely close to a solution:</p> <pre><code>s3upload_single() { n=$1 data=".data" extension=`file $n | cut -d ' ' -f2 | awk '{print tolower($0)}'` mimetype=`file --mime-type $n | cut -d ' ' -f2` fullpath=`readlink -f $n` changed="${fullpath/...
353, 387, 11444, 70637, 82247
amazon-s3, bash, gnu-parallel, parallel-processing, s3cmd
<h1>Uploading files to s3 using s3cmd in parallel</h1> <p>I've got a whole heap of files on a server, and I want to upload these onto S3. The files are stored with a .data extension, but really they're just a bunch of jpegs,pngs,zips or pdfs.</p> <p>I've already written a short script which finds the mime type and upl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,142
bash
# Uploading files to s3 using s3cmd in parallel I've got a whole heap of files on a server, and I want to upload these onto S3. The files are stored with a .data extension, but really they're just a bunch of jpegs,pngs,zips or pdfs. I've already written a short script which finds the mime type and uploads them onto S...
You are clearly skilled in writing shell, and extremely close to a solution: ``` s3upload_single() { n=$1 data=".data" extension=`file $n | cut -d ' ' -f2 | awk '{print tolower($0)}'` mimetype=`file --mime-type $n | cut -d ' ' -f2` fullpath=`readlink -f $n` changed="${fullpath/.data/.$extens...
22663484
get "ERROR: Can't get master address from ZooKeeper; znode data == null" when using Hbase shell
15
2014-03-26 14:06:06
<p>I installed Hadoop2.2.0 and Hbase0.98.0 and here is what I do :</p> <pre><code>$ ./bin/start-hbase.sh $ ./bin/hbase shell 2.0.0-p353 :001 &gt; list </code></pre> <p>then I got this:</p> <pre><code>ERROR: Can't get master address from ZooKeeper; znode data == null </code></pre> <p>Why am I getting this error ?...
65,531
3,463,279
2019-04-07 07:29:45
22,670,992
13
2014-03-26 19:17:17
1,183,167
2016-12-16 21:48:53
https://stackoverflow.com/q/22663484
https://stackoverflow.com/a/22670992
<p>If you just want to run HBase without going into Zookeeper management for standalone HBase, then remove all the <code>property</code> blocks from <code>hbase-site.xml</code> except the property block named <code>hbase.rootdir</code>. </p> <p>Now run <code>/bin/start-hbase.sh</code>. HBase comes with its own Zookeep...
<p>If you just want to run HBase without going into Zookeeper management for standalone HBase, then remove all the <code>property</code> blocks from <code>hbase-site.xml</code> except the property block named <code>hbase.rootdir</code>. </p> <p>Now run <code>/bin/start-hbase.sh</code>. HBase comes with its own Zookeep...
390, 1995, 2394
hadoop, hbase, shell
<h1>get "ERROR: Can't get master address from ZooKeeper; znode data == null" when using Hbase shell</h1> <p>I installed Hadoop2.2.0 and Hbase0.98.0 and here is what I do :</p> <pre><code>$ ./bin/start-hbase.sh $ ./bin/hbase shell 2.0.0-p353 :001 &gt; list </code></pre> <p>then I got this:</p> <pre><code>ERROR: Ca...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,143
bash
# get "ERROR: Can't get master address from ZooKeeper; znode data == null" when using Hbase shell I installed Hadoop2.2.0 and Hbase0.98.0 and here is what I do : ``` $ ./bin/start-hbase.sh $ ./bin/hbase shell 2.0.0-p353 :001 > list ``` then I got this: ``` ERROR: Can't get master address from ZooKeeper; znode da...
If you just want to run HBase without going into Zookeeper management for standalone HBase, then remove all the `property` blocks from `hbase-site.xml` except the property block named `hbase.rootdir`. Now run `/bin/start-hbase.sh`. HBase comes with its own Zookeeper, which gets started when you run `/bin/start-hbase.s...
9120760
cURL Simple File Upload - 417 Expectation Failed
15
2012-02-02 22:09:54
<p>I have a problem with a simple file upload post with cURL... I did it so many times but in this case I always get "417 Expectation Failed" from server. When I try to post with my browser it works 100% but with cURL not. </p> <p>That's my configuration:</p> <p>My simple test form that works:</p> <pre><code>&lt;fo...
18,624
870,412
2017-10-30 09:40:07
19,250,636
13
2013-10-08 14:34:11
2,681,246
2013-10-08 14:34:11
https://stackoverflow.com/q/9120760
https://stackoverflow.com/a/19250636
<p>Can also be fixed using set opt header setting:</p> <pre><code>curl_setopt($curl,CURLOPT_HTTPHEADER,array("Expect: ")); </code></pre> <p><a href="http://www.khattam.info/417-expectation-failed-in-php-curl-while-submitting-multi-part-forms-2011-04-14.html">http://www.khattam.info/417-expectation-failed-in-php-curl...
<p>Can also be fixed using set opt header setting:</p> <pre><code>curl_setopt($curl,CURLOPT_HTTPHEADER,array("Expect: ")); </code></pre> <p><a href="http://www.khattam.info/417-expectation-failed-in-php-curl-while-submitting-multi-part-forms-2011-04-14.html">http://www.khattam.info/417-expectation-failed-in-php-curl...
58, 387, 1554
bash, curl, linux
<h1>cURL Simple File Upload - 417 Expectation Failed</h1> <p>I have a problem with a simple file upload post with cURL... I did it so many times but in this case I always get "417 Expectation Failed" from server. When I try to post with my browser it works 100% but with cURL not. </p> <p>That's my configuration:</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,144
bash
# cURL Simple File Upload - 417 Expectation Failed I have a problem with a simple file upload post with cURL... I did it so many times but in this case I always get "417 Expectation Failed" from server. When I try to post with my browser it works 100% but with cURL not. That's my configuration: My simple test form t...
Can also be fixed using set opt header setting: ``` curl_setopt($curl,CURLOPT_HTTPHEADER,array("Expect: ")); ``` <http://www.khattam.info/417-expectation-failed-in-php-curl-while-submitting-multi-part-forms-2011-04-14.html>
17014478
What is the meaning of ". filename" (period space filename) in Bash?
15
2013-06-09 21:43:45
<p>What does a command with format [period][space][filename] mean?</p> <p>Example:</p> <pre><code>. ./setup.sh </code></pre> <p>Also in the <code>.bashrc</code> file, we have a line like that:</p> <pre><code>. "$HOME/.bashrc" </code></pre> <p>What does this mean?</p>
7,423
2,446,466
2021-07-06 11:39:08
17,014,479
13
2013-06-09 21:43:45
2,446,466
2019-01-25 15:21:17
https://stackoverflow.com/q/17014478
https://stackoverflow.com/a/17014479
<p>The <code>.</code> operator is also known as <code>source</code>.</p> <p>According to <a href="http://www.unix.com/shell-programming-scripting/177636-dot-operator-space-parameter-not-set.html" rel="nofollow noreferrer">this forum thread</a>, the first <code>.</code> is the command <code>source</code> to read and ex...
<p>The <code>.</code> operator is also known as <code>source</code>.</p> <p>According to <a href="http://www.unix.com/shell-programming-scripting/177636-dot-operator-space-parameter-not-set.html" rel="nofollow noreferrer">this forum thread</a>, the first <code>.</code> is the command <code>source</code> to read and ex...
387, 18271
bash, period
<h1>What is the meaning of ". filename" (period space filename) in Bash?</h1> <p>What does a command with format [period][space][filename] mean?</p> <p>Example:</p> <pre><code>. ./setup.sh </code></pre> <p>Also in the <code>.bashrc</code> file, we have a line like that:</p> <pre><code>. "$HOME/.bashrc" </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,145
bash
# What is the meaning of ". filename" (period space filename) in Bash? What does a command with format [period][space][filename] mean? Example: ``` . ./setup.sh ``` Also in the `.bashrc` file, we have a line like that: ``` . "$HOME/.bashrc" ``` What does this mean?
The `.` operator is also known as `source`. According to [this forum thread](http://www.unix.com/shell-programming-scripting/177636-dot-operator-space-parameter-not-set.html), the first `.` is the command `source` to read and execute commands from the filename given as argument. The second `.` is the current directory...
16157279
"dynamic operations can only be performed in homogenous appdomain" error while launching PowerShell
15
2013-04-22 21:44:32
<p>I have a powershell script that I am trying to execute from WCF REST service.I am using the <code>System.Management.Automation</code> and <code>System.Management.Automation.Runspaces</code> assemblies.</p> <p>The C# code looks like this:</p> <pre class="lang-cs prettyprint-override"><code>Command command = new Com...
31,460
1,019,042
2015-12-23 10:30:25
16,159,661
13
2013-04-23 02:01:20
251,123
2013-04-23 02:01:20
https://stackoverflow.com/q/16157279
https://stackoverflow.com/a/16159661
<p>I just googled that error and it seemed to be related to <code>legacyCasPolicy</code> being set to true as discussed <a href="https://stackoverflow.com/questions/8761113/dynamic-operations-can-only-be-performed-in-homogenous-appdomain-error">here</a> and <a href="https://stackoverflow.com/questions/5541143/legacycas...
<p>I just googled that error and it seemed to be related to <code>legacyCasPolicy</code> being set to true as discussed <a href="https://stackoverflow.com/questions/8761113/dynamic-operations-can-only-be-performed-in-homogenous-appdomain-error">here</a> and <a href="https://stackoverflow.com/questions/5541143/legacycas...
526, 1362, 11750
automation, code-access-security, powershell
<h1>"dynamic operations can only be performed in homogenous appdomain" error while launching PowerShell</h1> <p>I have a powershell script that I am trying to execute from WCF REST service.I am using the <code>System.Management.Automation</code> and <code>System.Management.Automation.Runspaces</code> assemblies.</p> <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,146
bash
# "dynamic operations can only be performed in homogenous appdomain" error while launching PowerShell I have a powershell script that I am trying to execute from WCF REST service.I am using the `System.Management.Automation` and `System.Management.Automation.Runspaces` assemblies. The C# code looks like this: ``` Co...
I just googled that error and it seemed to be related to `legacyCasPolicy` being set to true as discussed [here](https://stackoverflow.com/questions/8761113/dynamic-operations-can-only-be-performed-in-homogenous-appdomain-error) and [here](https://stackoverflow.com/questions/5541143/legacycasmodel-true-and-dynamic-data...
14598753
running bash script in cygwin on windows 7
15
2013-01-30 07:29:54
<p>I am trying to run the below bash script in cygwin on windows 7</p> <pre><code>REPEATTIMES="$1" if [ $# = 0 ]; then echo "Usage: fetch topN repeatTimes" exit 1 fi for (( i=1; i&lt;=$REPEATTIMES; i++ )) do echo "ITERATION: $i" echo "GENERATING" log=thelogs/log bin/nutch generate crawl/s...
26,336
328,836
2013-05-10 16:51:49
14,598,831
13
2013-01-30 07:36:29
1,072,150
2013-01-30 07:36:29
https://stackoverflow.com/q/14598753
https://stackoverflow.com/a/14598831
<p>The latest version of Cygwin seems to only support files in Unix format (i.e. with \n for newlines as opposed to the DOS/Windows \r\n newline).</p> <p>To fix this, run the /bin/dos2unix.exe utility, giving your script as the argument to the command:</p> <pre><code>e.g. /bin/dos2unix.exe myScript.sh </code></pre> ...
<p>The latest version of Cygwin seems to only support files in Unix format (i.e. with \n for newlines as opposed to the DOS/Windows \r\n newline).</p> <p>To fix this, run the /bin/dos2unix.exe utility, giving your script as the argument to the command:</p> <pre><code>e.g. /bin/dos2unix.exe myScript.sh </code></pre> ...
387, 1731, 34595
bash, cygwin, windows-7
<h1>running bash script in cygwin on windows 7</h1> <p>I am trying to run the below bash script in cygwin on windows 7</p> <pre><code>REPEATTIMES="$1" if [ $# = 0 ]; then echo "Usage: fetch topN repeatTimes" exit 1 fi for (( i=1; i&lt;=$REPEATTIMES; i++ )) do echo "ITERATION: $i" echo "GENERATING" ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,147
bash
# running bash script in cygwin on windows 7 I am trying to run the below bash script in cygwin on windows 7 ``` REPEATTIMES="$1" if [ $# = 0 ]; then echo "Usage: fetch topN repeatTimes" exit 1 fi for (( i=1; i<=$REPEATTIMES; i++ )) do echo "ITERATION: $i" echo "GENERATING" log=thelogs/log ...
The latest version of Cygwin seems to only support files in Unix format (i.e. with \n for newlines as opposed to the DOS/Windows \r\n newline). To fix this, run the /bin/dos2unix.exe utility, giving your script as the argument to the command: ``` e.g. /bin/dos2unix.exe myScript.sh ``` This will convert it to Unix fo...
13631173
Adding a path to the .bashrc file?
15
2012-11-29 17:17:25
<p>At the moment I am trying to add a path for ns-2 to my .bashrc file, I have installed the ns-allinone-2.34 but the command ns gives the result: command not found when entered into the shell.</p> <p>Here is what my .bashrc file currently looks like, I edited it using gedit:</p> <pre><code># .bashrc # Source global...
90,342
1,825,241
2016-11-08 20:04:47
13,631,374
13
2012-11-29 17:29:27
12,960
2016-11-08 20:04:47
https://stackoverflow.com/q/13631173
https://stackoverflow.com/a/13631374
<p>The <code>PATH</code> should contain the <em>directory</em> for the binaries, not the binaries themselves.</p> <p>For example, in the above:</p> <pre><code>export PATH=/home/michael/ns-allinone-2.34/bin/ns:.. </code></pre> <p>should actually be:</p> <pre><code>export PATH=/home/michael/ns-allinone-2.34/bin:... <...
<p>The <code>PATH</code> should contain the <em>directory</em> for the binaries, not the binaries themselves.</p> <p>For example, in the above:</p> <pre><code>export PATH=/home/michael/ns-allinone-2.34/bin/ns:.. </code></pre> <p>should actually be:</p> <pre><code>export PATH=/home/michael/ns-allinone-2.34/bin:... <...
387, 5430, 5826, 6268
bash, edit, fedora, path
<h1>Adding a path to the .bashrc file?</h1> <p>At the moment I am trying to add a path for ns-2 to my .bashrc file, I have installed the ns-allinone-2.34 but the command ns gives the result: command not found when entered into the shell.</p> <p>Here is what my .bashrc file currently looks like, I edited it using gedit...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,148
bash
# Adding a path to the .bashrc file? At the moment I am trying to add a path for ns-2 to my .bashrc file, I have installed the ns-allinone-2.34 but the command ns gives the result: command not found when entered into the shell. Here is what my .bashrc file currently looks like, I edited it using gedit: ``` # .bashrc...
The `PATH` should contain the *directory* for the binaries, not the binaries themselves. For example, in the above: ``` export PATH=/home/michael/ns-allinone-2.34/bin/ns:.. ``` should actually be: ``` export PATH=/home/michael/ns-allinone-2.34/bin:... ```
11051064
Execute php script from bash , assign output to a bash variable
15
2012-06-15 12:55:38
<p>I have a bash script which need to execute some php scripts and to get back the results e.g</p> <pre><code>#!/bin/bash /usr/bin/php -f $HOME/lib/get_fifobuild.php </code></pre> <p>The script get_fifobuild.php returns an integer which I need to assign into a bash variable. I ll appreciate if someone help me out. <...
14,682
416,100
2024-06-08 19:01:28
11,051,138
13
2012-06-15 12:59:47
1,437,581
2012-06-15 14:49:50
https://stackoverflow.com/q/11051064
https://stackoverflow.com/a/11051138
<pre><code>myvariable=$(/usr/bin/php -f $HOME/lib/get_fifobuild.php) </code></pre> <p>Will assign the output from your php script to a variable called "myvariable".</p> <p><strong>Update</strong>:</p> <p>This will assign the output of the command to the variable, but as you are still having problems I can perhaps su...
<pre><code>myvariable=$(/usr/bin/php -f $HOME/lib/get_fifobuild.php) </code></pre> <p>Will assign the output from your php script to a variable called "myvariable".</p> <p><strong>Update</strong>:</p> <p>This will assign the output of the command to the variable, but as you are still having problems I can perhaps su...
5, 387
bash, php
<h1>Execute php script from bash , assign output to a bash variable</h1> <p>I have a bash script which need to execute some php scripts and to get back the results e.g</p> <pre><code>#!/bin/bash /usr/bin/php -f $HOME/lib/get_fifobuild.php </code></pre> <p>The script get_fifobuild.php returns an integer which I need ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,149
bash
# Execute php script from bash , assign output to a bash variable I have a bash script which need to execute some php scripts and to get back the results e.g ``` #!/bin/bash /usr/bin/php -f $HOME/lib/get_fifobuild.php ``` The script get_fifobuild.php returns an integer which I need to assign into a bash variable. I ...
``` myvariable=$(/usr/bin/php -f $HOME/lib/get_fifobuild.php) ``` Will assign the output from your php script to a variable called "myvariable". **Update**: This will assign the output of the command to the variable, but as you are still having problems I can perhaps suggest a few things: 1. you have 'get_builds.ph...
8903180
How to use SED without a file with an env var?
15
2012-01-17 23:31:25
<p>Is it possible to substitute a thing in env var with SED?</p> <pre><code>$ a='aoeua' $ sed 's@a@o@g' &lt;$a bash: aoeua: No such file or directory $ env|grep "SHELL" SHELL=/bin/bash </code></pre> <p>The output I want is</p> <pre><code>ooeuo </code></pre> <p>replacing each <code>a</code> in <code>'aoeua'</code> w...
12,487
164,148
2012-01-18 01:24:58
8,903,202
13
2012-01-17 23:34:02
90,848
2012-01-17 23:34:02
https://stackoverflow.com/q/8903180
https://stackoverflow.com/a/8903202
<p>Use echo:</p> <pre><code>$ echo "$a" | sed 's@a@o@g' </code></pre> <p>In bash you can also do simple substitutions with the <code>${parameter/pattern/string}</code> syntax. For example:</p> <pre><code>$ v='aoeua' $ echo ${v/a/o} ooeua </code></pre> <p>Note that this only replaces the first occurrence of the patt...
<p>Use echo:</p> <pre><code>$ echo "$a" | sed 's@a@o@g' </code></pre> <p>In bash you can also do simple substitutions with the <code>${parameter/pattern/string}</code> syntax. For example:</p> <pre><code>$ v='aoeua' $ echo ${v/a/o} ooeua </code></pre> <p>Note that this only replaces the first occurrence of the patt...
387, 390, 5282, 9013
bash, environment-variables, sed, shell
<h1>How to use SED without a file with an env var?</h1> <p>Is it possible to substitute a thing in env var with SED?</p> <pre><code>$ a='aoeua' $ sed 's@a@o@g' &lt;$a bash: aoeua: No such file or directory $ env|grep "SHELL" SHELL=/bin/bash </code></pre> <p>The output I want is</p> <pre><code>ooeuo </code></pre> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,150
bash
# How to use SED without a file with an env var? Is it possible to substitute a thing in env var with SED? ``` $ a='aoeua' $ sed 's@a@o@g' <$a bash: aoeua: No such file or directory $ env|grep "SHELL" SHELL=/bin/bash ``` The output I want is ``` ooeuo ``` replacing each `a` in `'aoeua'` with `o`.
Use echo: ``` $ echo "$a" | sed 's@a@o@g' ``` In bash you can also do simple substitutions with the `${parameter/pattern/string}` syntax. For example: ``` $ v='aoeua' $ echo ${v/a/o} ooeua ``` Note that this only replaces the first occurrence of the pattern.
8666954
How to set up a proxy via bash shell?
15
2011-12-29 10:53:03
<p>I set up a proxy on Mac via <code>System Preferences -&gt; Network -&gt; Advanced -&gt; Proxies</code>.</p> <p>Is that possible to do the same programatically via bash shell?</p>
54,303
247,243
2013-11-17 12:36:20
8,670,655
13
2011-12-29 16:46:10
89,817
2011-12-29 16:46:10
https://stackoverflow.com/q/8666954
https://stackoverflow.com/a/8670655
<p>Yes, using the <code>networksetup</code> command. There are separate options for setting different types of proxies (e.g. <code>-setwebproxy</code>, <code>-setsocksfirewallproxy</code>, etc), and you need to know the name of the primary network "service" (e.g. Ethernet, Airport... basically, the names listed in the...
<p>Yes, using the <code>networksetup</code> command. There are separate options for setting different types of proxies (e.g. <code>-setwebproxy</code>, <code>-setsocksfirewallproxy</code>, etc), and you need to know the name of the primary network "service" (e.g. Ethernet, Airport... basically, the names listed in the...
369, 387, 390, 760
bash, macos, proxy, shell
<h1>How to set up a proxy via bash shell?</h1> <p>I set up a proxy on Mac via <code>System Preferences -&gt; Network -&gt; Advanced -&gt; Proxies</code>.</p> <p>Is that possible to do the same programatically via bash shell?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,151
bash
# How to set up a proxy via bash shell? I set up a proxy on Mac via `System Preferences -> Network -> Advanced -> Proxies`. Is that possible to do the same programatically via bash shell?
Yes, using the `networksetup` command. There are separate options for setting different types of proxies (e.g. `-setwebproxy`, `-setsocksfirewallproxy`, etc), and you need to know the name of the primary network "service" (e.g. Ethernet, Airport... basically, the names listed in the sidebar of the Network preferences p...
45147547
Get only file with given extension in directory
14
2017-07-17 15:00:56
<p>I have a string variable pointing to a directory. In this directory is a single file with the extension <code>.xyz</code>. How do I get the path to this file, without knowing the file name itself?</p> <p>I have the following code so far:</p> <pre><code>$dir = "C:\Temp\MyDir" $xyzFiles = @(Get-ChildItem "$dir\*.xyz...
25,374
1,400,869
2022-09-28 16:10:32
45,147,769
13
2017-07-17 15:11:14
4,868,262
2022-09-28 16:08:57
https://stackoverflow.com/q/45147547
https://stackoverflow.com/a/45147769
<p>I would recommend using <code>Get-ChildItem</code>'s <code>-include</code> parameter:</p> <pre><code>Get-ChildItem $dir -include *.xyz </code></pre>
<p>I would recommend using <code>Get-ChildItem</code>'s <code>-include</code> parameter:</p> <pre><code>Get-ChildItem $dir -include *.xyz </code></pre>
526, 108010
powershell, powershell-5.0
<h1>Get only file with given extension in directory</h1> <p>I have a string variable pointing to a directory. In this directory is a single file with the extension <code>.xyz</code>. How do I get the path to this file, without knowing the file name itself?</p> <p>I have the following code so far:</p> <pre><code>$dir ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,152
bash
# Get only file with given extension in directory I have a string variable pointing to a directory. In this directory is a single file with the extension `.xyz`. How do I get the path to this file, without knowing the file name itself? I have the following code so far: ``` $dir = "C:\Temp\MyDir" $xyzFiles = @(Get-Ch...
I would recommend using `Get-ChildItem`'s `-include` parameter: ``` Get-ChildItem $dir -include *.xyz ```
35527301
NPM live-server: command not found
14
2016-02-20 18:29:24
<p>I install live-server globally with: </p> <p><code>npm install -g live-server</code> but for some reason it is not be found and I get the following error</p> <p><code>bash: live-server: command not found</code> after command <code>live-server</code></p> <p>Everything is correctly installed:</p> <pre><code>/User...
36,407
1,173,383
2024-02-06 06:29:02
35,527,743
13
2016-02-20 19:07:57
3,005,251
2016-02-20 19:07:57
https://stackoverflow.com/q/35527301
https://stackoverflow.com/a/35527743
<p>Add the path to your npm installation to your path. Just add this line at the end of <code>.bash_profile</code>. Run it in bash first, to make sure it works before putting it in <code>.bash_profile</code></p> <pre><code>export PATH=$PATH:/Users/username/npm-global/bin </code></pre>
<p>Add the path to your npm installation to your path. Just add this line at the end of <code>.bash_profile</code>. Run it in bash first, to make sure it works before putting it in <code>.bash_profile</code></p> <pre><code>export PATH=$PATH:/Users/username/npm-global/bin </code></pre>
387, 46426, 61387, 123787
bash, node.js, npm, npm-live-server
<h1>NPM live-server: command not found</h1> <p>I install live-server globally with: </p> <p><code>npm install -g live-server</code> but for some reason it is not be found and I get the following error</p> <p><code>bash: live-server: command not found</code> after command <code>live-server</code></p> <p>Everything i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,153
bash
# NPM live-server: command not found I install live-server globally with: `npm install -g live-server` but for some reason it is not be found and I get the following error `bash: live-server: command not found` after command `live-server` Everything is correctly installed: ``` /Users/username/npm-global/bin/live-s...
Add the path to your npm installation to your path. Just add this line at the end of `.bash_profile`. Run it in bash first, to make sure it works before putting it in `.bash_profile` ``` export PATH=$PATH:/Users/username/npm-global/bin ```
33809210
What do the $package and $project params contain in a NuGet install.ps1 script?
14
2015-11-19 16:22:04
<p>I'm writing my first install PowerShell script for a NuGet package. I'm trying to copy a file from the <code>lib</code> folder into the <code>tools</code> folder of another NuGet package. The default install.ps1 script has four parameters, two of which are:</p> <ul> <li>$package</li> <li>$project</li> </ul> <p>The...
3,121
3,092,298
2021-04-14 11:49:36
33,811,810
13
2015-11-19 18:37:11
268,874
2021-04-14 11:49:36
https://stackoverflow.com/q/33809210
https://stackoverflow.com/a/33811810
<p>In NuGet 2:</p> <ul> <li>$project =&gt; <a href="https://msdn.microsoft.com/en-us/library/envdte.project.aspx" rel="nofollow noreferrer">EnvDTE.Project</a> - which is the Visual Studio object model for a project.</li> <li>$package =&gt; <a href="https://github.com/NuGet/NuGet2/blob/d9e597f7164fd776a0b3162c653afce4cc...
<p>In NuGet 2:</p> <ul> <li>$project =&gt; <a href="https://msdn.microsoft.com/en-us/library/envdte.project.aspx" rel="nofollow noreferrer">EnvDTE.Project</a> - which is the Visual Studio object model for a project.</li> <li>$package =&gt; <a href="https://github.com/NuGet/NuGet2/blob/d9e597f7164fd776a0b3162c653afce4cc...
526, 62770, 62984, 93364
nuget, nuget-package, powershell, visual-studio-2013
<h1>What do the $package and $project params contain in a NuGet install.ps1 script?</h1> <p>I'm writing my first install PowerShell script for a NuGet package. I'm trying to copy a file from the <code>lib</code> folder into the <code>tools</code> folder of another NuGet package. The default install.ps1 script has four ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,154
bash
# What do the $package and $project params contain in a NuGet install.ps1 script? I'm writing my first install PowerShell script for a NuGet package. I'm trying to copy a file from the `lib` folder into the `tools` folder of another NuGet package. The default install.ps1 script has four parameters, two of which are: ...
In NuGet 2: - $project => [EnvDTE.Project](https://msdn.microsoft.com/en-us/library/envdte.project.aspx) - which is the Visual Studio object model for a project. - $package => [NuGet.IPackage](https://github.com/NuGet/NuGet2/blob/d9e597f7164fd776a0b3162c653afce4cc7c70d3/src/Core/Packages/IPackage.cs) - the NuGet packa...
33403037
powershell tf command not recognized as the name of a cmlet
14
2015-10-28 22:57:53
<blockquote> <p>tf : The term 'tf' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</p> </blockquote> <p>I set up the environment variable but does not work. tf comma...
22,640
3,939,140
2021-04-21 06:05:23
33,415,147
13
2015-10-29 13:08:54
5,191,724
2015-10-29 13:08:54
https://stackoverflow.com/q/33403037
https://stackoverflow.com/a/33415147
<p>You need to include tf.exe full path. For example, you want to check in files with tf checkin command in PowerShell:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>$filePath = "C:\Users\username\Source\Wo...
<p>You need to include tf.exe full path. For example, you want to check in files with tf checkin command in PowerShell:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>$filePath = "C:\Users\username\Source\Wo...
526, 733, 93364
powershell, tfs, visual-studio-2013
<h1>powershell tf command not recognized as the name of a cmlet</h1> <blockquote> <p>tf : The term 'tf' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</p> </blockquo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,155
bash
# powershell tf command not recognized as the name of a cmlet > tf : The term 'tf' is not recognized as the name of a cmdlet, > function, script file, or operable program. Check the spelling of the > name, or if a path was included, verify that the path is correct and > try again. I set up the environment variable bu...
You need to include tf.exe full path. For example, you want to check in files with tf checkin command in PowerShell: ``` $filePath = "C:\Users\username\Source\Workspaces\teamproject\solutionname\projectname\Class1.cs" Set-Alias tfs "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe" tfs chec...
24610085
Minicom send automate script
14
2014-07-07 11:59:24
<p>I'm using minicom to test my connection on serial port. </p> <pre><code> sudo minicom -b 115200 -D /dev/ttyS0 </code></pre> <p>in this way minicom opens its 'console-gui' and allow me to send data.</p> <p>I send:</p> <pre><code> atz </code></pre> <p>and obtain 'OK'</p> <pre><code>at </code></pre> <p>and obta...
40,536
980,344
2018-07-19 13:10:55
24,610,742
13
2014-07-07 12:34:08
3,184,706
2014-07-07 12:51:07
https://stackoverflow.com/q/24610085
https://stackoverflow.com/a/24610742
<p>Minicom have -S option for executing SCRIPT at startup time,so made a script with your commands like</p> <pre><code>vi script.txt send atz send at </code></pre> <p>Run your script with minicom like</p> <pre><code>minicom -S script.txt </code></pre> <p>Also refer <a href="http://www.linuxcommand.org/man_pages/run...
<p>Minicom have -S option for executing SCRIPT at startup time,so made a script with your commands like</p> <pre><code>vi script.txt send atz send at </code></pre> <p>Run your script with minicom like</p> <pre><code>minicom -S script.txt </code></pre> <p>Also refer <a href="http://www.linuxcommand.org/man_pages/run...
58, 387, 390, 3716
bash, linux, serial-port, shell
<h1>Minicom send automate script</h1> <p>I'm using minicom to test my connection on serial port. </p> <pre><code> sudo minicom -b 115200 -D /dev/ttyS0 </code></pre> <p>in this way minicom opens its 'console-gui' and allow me to send data.</p> <p>I send:</p> <pre><code> atz </code></pre> <p>and obtain 'OK'</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,156
bash
# Minicom send automate script I'm using minicom to test my connection on serial port. ``` sudo minicom -b 115200 -D /dev/ttyS0 ``` in this way minicom opens its 'console-gui' and allow me to send data. I send: ``` atz ``` and obtain 'OK' ``` at ``` and obtain 'OK' Ans so on. I need to run a script that wri...
Minicom have -S option for executing SCRIPT at startup time,so made a script with your commands like ``` vi script.txt send atz send at ``` Run your script with minicom like ``` minicom -S script.txt ``` Also refer <http://www.linuxcommand.org/man_pages/runscript1.html> for minicom scripting
23951346
Is there a subshell created when I run `sh -c "command"`, a new shell or none of these?
14
2014-05-30 09:34:52
<p>In bash, when I run the following command:</p> <pre><code>sh -c "<em>command</em>"</code></pre> <p>is there created a subshell and then the <code><em>command</em></code> is executed?</p> <p>My guess is that the command will run in the current shell, but I'm not sure. This guess come from the fact that I already t...
18,675
2,353,900
2015-02-19 21:12:07
24,041,668
13
2014-06-04 15:33:34
3,569,208
2014-06-05 05:52:31
https://stackoverflow.com/q/23951346
https://stackoverflow.com/a/24041668
<p>I think that with examples it's possible to understand the situation<br> (in my case <code>sh</code> is a symbolic link to <code>/bin/dash</code>).<br> I did this tests for <code>sh</code>:</p> <pre><code>echo $$ ; sh -c 'echo $$ ; sh -c '"'"'echo $$'"'"' ' 16102 7569 7570 </code></pre> <p>Three different <code>PI...
<p>I think that with examples it's possible to understand the situation<br> (in my case <code>sh</code> is a symbolic link to <code>/bin/dash</code>).<br> I did this tests for <code>sh</code>:</p> <pre><code>echo $$ ; sh -c 'echo $$ ; sh -c '"'"'echo $$'"'"' ' 16102 7569 7570 </code></pre> <p>Three different <code>PI...
387, 1231
bash, command-line
<h1>Is there a subshell created when I run `sh -c "command"`, a new shell or none of these?</h1> <p>In bash, when I run the following command:</p> <pre><code>sh -c "<em>command</em>"</code></pre> <p>is there created a subshell and then the <code><em>command</em></code> is executed?</p> <p>My guess is that the comman...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,157
bash
# Is there a subshell created when I run `sh -c "command"`, a new shell or none of these? In bash, when I run the following command: ``` sh -c "command" ``` is there created a subshell and then the `command` is executed? My guess is that the command will run in the current shell, but I'm not sure. This guess come f...
I think that with examples it's possible to understand the situation (in my case `sh` is a symbolic link to `/bin/dash`). I did this tests for `sh`: ``` echo $$ ; sh -c 'echo $$ ; sh -c '"'"'echo $$'"'"' ' 16102 7569 7570 ``` Three different `PID`, three different `shell`. (If there are different *shells*, there ...
22793713
How to set a shell exit trap from within a function in zsh and bash
14
2014-04-01 18:16:23
<p>Consider the following shell function:</p> <pre><code>f() { echo "function" trap 'echo trap; sleep 1' EXIT } </code></pre> <p>Under bash this will print the following:</p> <pre><code>~$ f function ~$ exit trap </code></pre> <p>On zsh however this is the result:</p> <pre><code>~$ f function trap ~$ exit ...
4,807
107,946
2014-04-01 18:49:24
22,794,374
13
2014-04-01 18:49:24
1,899,640
2014-04-01 18:49:24
https://stackoverflow.com/q/22793713
https://stackoverflow.com/a/22794374
<p>Obligatory boring and uninteresting answer:</p> <pre><code>f() { if [ "$ZSH_VERSION" ] then zshexit() { echo trap; sleep 1; } # zsh specific else trap 'echo trap; sleep 1' EXIT # POSIX fi } </code></pre>
<p>Obligatory boring and uninteresting answer:</p> <pre><code>f() { if [ "$ZSH_VERSION" ] then zshexit() { echo trap; sleep 1; } # zsh specific else trap 'echo trap; sleep 1' EXIT # POSIX fi } </code></pre>
387, 390, 3791
bash, shell, zsh
<h1>How to set a shell exit trap from within a function in zsh and bash</h1> <p>Consider the following shell function:</p> <pre><code>f() { echo "function" trap 'echo trap; sleep 1' EXIT } </code></pre> <p>Under bash this will print the following:</p> <pre><code>~$ f function ~$ exit trap </code></pre> <p>O...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,158
bash
# How to set a shell exit trap from within a function in zsh and bash Consider the following shell function: ``` f() { echo "function" trap 'echo trap; sleep 1' EXIT } ``` Under bash this will print the following: ``` ~$ f function ~$ exit trap ``` On zsh however this is the result: ``` ~$ f function trap...
Obligatory boring and uninteresting answer: ``` f() { if [ "$ZSH_VERSION" ] then zshexit() { echo trap; sleep 1; } # zsh specific else trap 'echo trap; sleep 1' EXIT # POSIX fi } ```
19246065
Python in Emacs shell-mode turns on stty echo and breaks C-d
14
2013-10-08 11:06:08
<p>When I run an interactive Python inside an Emacs shell buffer (M-x shell), it does two surprising things to the TTY. First, it turns on input echo, which persists after Python exits, until I do stty -echo. Secondly, it doesn't accept C-d (or C-q C-d, i.e. ^D) as EOF: I have to type quit() to leave the Python. How...
1,570
2,444,191
2022-10-06 13:43:47
19,251,659
13
2013-10-08 15:15:18
68,063
2018-12-06 18:37:51
https://stackoverflow.com/q/19246065
https://stackoverflow.com/a/19251659
<h3>0. Summary</h3> <p>If you installed Python via Macports, install the py27-gnureadline port (or py37-gnureadline, or whatever your version is) and the problem is fixed.</p> <h3>1. Reproduction</h3> <p>I can reproduce this (GNU Emacs 23.4.1; OS X 10.8.5; Python 3.3.2). Here's a session in a fresh <code>emacs -Q</c...
<h3>0. Summary</h3> <p>If you installed Python via Macports, install the py27-gnureadline port (or py37-gnureadline, or whatever your version is) and the problem is fixed.</p> <h3>1. Reproduction</h3> <p>I can reproduce this (GNU Emacs 23.4.1; OS X 10.8.5; Python 3.3.2). Here's a session in a fresh <code>emacs -Q</c...
16, 369, 371, 390, 17165
emacs, macos, python, shell, tty
<h1>Python in Emacs shell-mode turns on stty echo and breaks C-d</h1> <p>When I run an interactive Python inside an Emacs shell buffer (M-x shell), it does two surprising things to the TTY. First, it turns on input echo, which persists after Python exits, until I do stty -echo. Secondly, it doesn't accept C-d (or C-q...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,159
bash
# Python in Emacs shell-mode turns on stty echo and breaks C-d When I run an interactive Python inside an Emacs shell buffer (M-x shell), it does two surprising things to the TTY. First, it turns on input echo, which persists after Python exits, until I do stty -echo. Secondly, it doesn't accept C-d (or C-q C-d, i.e. ...
### 0. Summary If you installed Python via Macports, install the py27-gnureadline port (or py37-gnureadline, or whatever your version is) and the problem is fixed. ### 1. Reproduction I can reproduce this (GNU Emacs 23.4.1; OS X 10.8.5; Python 3.3.2). Here's a session in a fresh `emacs -Q` showing the problem: ``` ...
17809912
Parsing iw wlan0 scan output
14
2013-07-23 12:13:49
<p>I wrote wlan manager script to handle open/ad-hoc/wep/wpa2 networks. Now im trying to parse iw wlan0 scan output to get nice scan feature to my script. My goal is to get output like this :</p> <pre><code>SSID channel signal encryption wlan-ap 6 70% wpa2-psk test 1 ...
40,197
1,279,530
2025-02-23 17:55:31
17,880,517
13
2013-07-26 11:47:48
1,279,530
2013-07-26 12:10:59
https://stackoverflow.com/q/17809912
https://stackoverflow.com/a/17880517
<p>Here is my final solution based of <a href="https://stackoverflow.com/a/17810551/1066031">Sudo_O answer</a>:</p> <pre><code>$1 == "BSS" { MAC = $2 wifi[MAC]["enc"] = "Open" } $1 == "SSID:" { wifi[MAC]["SSID"] = $2 } $1 == "freq:" { wifi[MAC]["freq"] = $NF } $1 == "signal:" { wifi[MAC]["sig"] = $...
<p>Here is my final solution based of <a href="https://stackoverflow.com/a/17810551/1066031">Sudo_O answer</a>:</p> <pre><code>$1 == "BSS" { MAC = $2 wifi[MAC]["enc"] = "Open" } $1 == "SSID:" { wifi[MAC]["SSID"] = $2 } $1 == "freq:" { wifi[MAC]["freq"] = $NF } $1 == "signal:" { wifi[MAC]["sig"] = $...
387, 990, 1357, 5282
awk, bash, parsing, sed
<h1>Parsing iw wlan0 scan output</h1> <p>I wrote wlan manager script to handle open/ad-hoc/wep/wpa2 networks. Now im trying to parse iw wlan0 scan output to get nice scan feature to my script. My goal is to get output like this :</p> <pre><code>SSID channel signal encryption wlan-ap 6 70%...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,160
bash
# Parsing iw wlan0 scan output I wrote wlan manager script to handle open/ad-hoc/wep/wpa2 networks. Now im trying to parse iw wlan0 scan output to get nice scan feature to my script. My goal is to get output like this : ``` SSID channel signal encryption wlan-ap 6 70% wpa2-psk te...
Here is my final solution based of [Sudo_O answer](https://stackoverflow.com/a/17810551/1066031): ``` $1 == "BSS" { MAC = $2 wifi[MAC]["enc"] = "Open" } $1 == "SSID:" { wifi[MAC]["SSID"] = $2 } $1 == "freq:" { wifi[MAC]["freq"] = $NF } $1 == "signal:" { wifi[MAC]["sig"] = $2 " " $3 } $1 == "WPA:" {...
17821277
How to separate multiple commands passed to eval in bash
14
2013-07-23 21:17:56
<p>I'm trying to evaluate multiple lines of shell commands using <code>eval</code>, but when I try to resolve variables with eval separated by a newline <code>\n</code> the variables are not resolved.</p> <pre><code>x='echo a' y='echo b' z="$x\n$y" eval $x eval $y eval $z </code></pre> <p>Which outputs:</p> <pre><co...
17,956
559,676
2021-06-11 05:14:13
17,837,110
13
2013-07-24 14:34:32
89,817
2013-07-24 14:34:32
https://stackoverflow.com/q/17821277
https://stackoverflow.com/a/17837110
<p><code>\n</code> is not a newline; it's an escape sequence that <em>in some situations</em> will be translated into a newline, but you haven't used it in one of those situations. The variable <code>$z</code> doesn't wind up containing a newline, just backslash followed by "n". As a result, this is what's actually bei...
<p><code>\n</code> is not a newline; it's an escape sequence that <em>in some situations</em> will be translated into a newline, but you haven't used it in one of those situations. The variable <code>$z</code> doesn't wind up containing a newline, just backslash followed by "n". As a result, this is what's actually bei...
387, 390, 4413
bash, eval, shell
<h1>How to separate multiple commands passed to eval in bash</h1> <p>I'm trying to evaluate multiple lines of shell commands using <code>eval</code>, but when I try to resolve variables with eval separated by a newline <code>\n</code> the variables are not resolved.</p> <pre><code>x='echo a' y='echo b' z="$x\n$y" eval...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,161
bash
# How to separate multiple commands passed to eval in bash I'm trying to evaluate multiple lines of shell commands using `eval`, but when I try to resolve variables with eval separated by a newline `\n` the variables are not resolved. ``` x='echo a' y='echo b' z="$x\n$y" eval $x eval $y eval $z ``` Which outputs: `...
`\n` is not a newline; it's an escape sequence that *in some situations* will be translated into a newline, but you haven't used it in one of those situations. The variable `$z` doesn't wind up containing a newline, just backslash followed by "n". As a result, this is what's actually being executed: ``` $ echo a\necho...
14335825
Execute single command in shell script without sudo
14
2013-01-15 10:34:11
<p>I have a simple shell script that is run with sudo as most of the script requires it, yet one of the commands in the script is a Homebrew install, which cannot be executed with sudo..</p> <p>So, my question is when executing a shell script with sudo how do I execute sub commands as the current user and then continu...
5,836
591,969
2013-01-15 12:47:51
14,336,073
13
2013-01-15 10:48:10
1,978,011
2013-01-15 10:48:10
https://stackoverflow.com/q/14335825
https://stackoverflow.com/a/14336073
<p>The easiest way is to run the subcommand via <code>sudo</code> from within the script. The user id to run with can be obtained by $SUDO_USER (look at the output of <code>sudo env</code>):</p> <pre><code>sudo -u $SUDO_USER ./exec_as_normal_user.sh </code></pre>
<p>The easiest way is to run the subcommand via <code>sudo</code> from within the script. The user id to run with can be obtained by $SUDO_USER (look at the output of <code>sudo env</code>):</p> <pre><code>sudo -u $SUDO_USER ./exec_as_normal_user.sh </code></pre>
387, 1067, 1674
bash, homebrew, sudo
<h1>Execute single command in shell script without sudo</h1> <p>I have a simple shell script that is run with sudo as most of the script requires it, yet one of the commands in the script is a Homebrew install, which cannot be executed with sudo..</p> <p>So, my question is when executing a shell script with sudo how d...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,162
bash
# Execute single command in shell script without sudo I have a simple shell script that is run with sudo as most of the script requires it, yet one of the commands in the script is a Homebrew install, which cannot be executed with sudo.. So, my question is when executing a shell script with sudo how do I execute sub ...
The easiest way is to run the subcommand via `sudo` from within the script. The user id to run with can be obtained by $SUDO_USER (look at the output of `sudo env`): ``` sudo -u $SUDO_USER ./exec_as_normal_user.sh ```
12133062
Formatting lists with the column command in *nix
14
2012-08-26 19:08:04
<p>I'm trying to format a list of entries in bash, and am using the <code>column</code> command. However, the <code>-t</code> option defaults to using any whitespace as a delimiter, which does not work for the data I have (it contains spaces and tabs). I can't figure out how to get the <code>-s</code> flag to specify a...
22,138
1,626,213
2012-12-20 02:07:56
12,134,722
13
2012-08-26 23:27:19
978,917
2012-08-26 23:27:19
https://stackoverflow.com/q/12133062
https://stackoverflow.com/a/12134722
<p>In theory, to specify a newline, you can use the <code>$'...'</code> notation, which is just like <code>'...'</code> except that it supports C-style escape-sequences:</p> <pre><code>column -t -s $'\n' list-of-entries.txt </code></pre> <p>However, I don't really understand the purpose of this. A newline is the row ...
<p>In theory, to specify a newline, you can use the <code>$'...'</code> notation, which is just like <code>'...'</code> except that it supports C-style escape-sequences:</p> <pre><code>column -t -s $'\n' list-of-entries.txt </code></pre> <p>However, I don't really understand the purpose of this. A newline is the row ...
34, 58, 387, 390, 555
bash, formatting, linux, shell, unix
<h1>Formatting lists with the column command in *nix</h1> <p>I'm trying to format a list of entries in bash, and am using the <code>column</code> command. However, the <code>-t</code> option defaults to using any whitespace as a delimiter, which does not work for the data I have (it contains spaces and tabs). I can't f...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,163
bash
# Formatting lists with the column command in *nix I'm trying to format a list of entries in bash, and am using the `column` command. However, the `-t` option defaults to using any whitespace as a delimiter, which does not work for the data I have (it contains spaces and tabs). I can't figure out how to get the `-s` f...
In theory, to specify a newline, you can use the `$'...'` notation, which is just like `'...'` except that it supports C-style escape-sequences: ``` column -t -s $'\n' list-of-entries.txt ``` However, I don't really understand the purpose of this. A newline is the row delimiter, so a column-delimiter of `$'\n'` is eq...
9328777
ValueFromPipeline behavior?
14
2012-02-17 13:07:03
<p>I have a command <code>Get-Testdata</code> that retrieves test data from different sources and stores these into a <code>PSObject</code> with the different values as properties. The total number of objects are then stored as an array, for easy manipulation, sorting, calculating etc.</p> <p>My problem is that I want...
17,147
662,388
2018-07-30 20:28:00
9,329,145
13
2012-02-17 13:32:26
75,224
2012-02-17 14:59:05
https://stackoverflow.com/q/9328777
https://stackoverflow.com/a/9329145
<p>You probably process data in end block, not process block.</p> <p>Look at an example:</p> <pre><code>function getdata { 1 2 3 4 } function show-data { param( [Parameter(mandatory=$true, ValueFromPipeline=$true)]$InputObject, [Parameter(mandatory=$true)]$FileName ) # thi...
<p>You probably process data in end block, not process block.</p> <p>Look at an example:</p> <pre><code>function getdata { 1 2 3 4 } function show-data { param( [Parameter(mandatory=$true, ValueFromPipeline=$true)]$InputObject, [Parameter(mandatory=$true)]$FileName ) # thi...
526
powershell
<h1>ValueFromPipeline behavior?</h1> <p>I have a command <code>Get-Testdata</code> that retrieves test data from different sources and stores these into a <code>PSObject</code> with the different values as properties. The total number of objects are then stored as an array, for easy manipulation, sorting, calculating e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,164
bash
# ValueFromPipeline behavior? I have a command `Get-Testdata` that retrieves test data from different sources and stores these into a `PSObject` with the different values as properties. The total number of objects are then stored as an array, for easy manipulation, sorting, calculating etc. My problem is that I want ...
You probably process data in end block, not process block. Look at an example: ``` function getdata { 1 2 3 4 } function show-data { param( [Parameter(mandatory=$true, ValueFromPipeline=$true)]$InputObject, [Parameter(mandatory=$true)]$FileName ) # this is process block th...
9109362
Bash subshell/pipelines - which parts are executing in subshells?
14
2012-02-02 08:47:27
<p>In a <a href="https://stackoverflow.com/questions/9108181/append-output-of-one-command-to-the-output-of-another-in-a-single-command/9108410#comment11442552_9108410">comment on another post</a>, @JonathanLeffler stated that:</p> <blockquote> <p>{ ... } | somecommand is run in a sub-shell and doesn't affect the p...
3,484
128,625
2024-01-11 10:01:13
9,109,654
13
2012-02-02 09:10:34
126,769
2024-01-11 10:01:13
https://stackoverflow.com/q/9109362
https://stackoverflow.com/a/9109654
<p>Each side of a pipeline becomes a subshell at least.</p> <pre><code>X=PQR; echo $X; { X=ABC; echo $X; } | cat; echo $X </code></pre> <p>will make a subshell/process of , atleast <code>{ X=ABC; echo $X; }</code> and <code>cat</code>.</p> <p>&quot;Each command in a pipeline is executed as a separate process (i.e., in ...
<p>Each side of a pipeline becomes a subshell at least.</p> <pre><code>X=PQR; echo $X; { X=ABC; echo $X; } | cat; echo $X </code></pre> <p>will make a subshell/process of , atleast <code>{ X=ABC; echo $X; }</code> and <code>cat</code>.</p> <p>&quot;Each command in a pipeline is executed as a separate process (i.e., in ...
387
bash
<h1>Bash subshell/pipelines - which parts are executing in subshells?</h1> <p>In a <a href="https://stackoverflow.com/questions/9108181/append-output-of-one-command-to-the-output-of-another-in-a-single-command/9108410#comment11442552_9108410">comment on another post</a>, @JonathanLeffler stated that:</p> <blockquote> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,165
bash
# Bash subshell/pipelines - which parts are executing in subshells? In a [comment on another post](https://stackoverflow.com/questions/9108181/append-output-of-one-command-to-the-output-of-another-in-a-single-command/9108410#comment11442552_9108410), @JonathanLeffler stated that: > { ... } | somecommand is run in a s...
Each side of a pipeline becomes a subshell at least. ``` X=PQR; echo $X; { X=ABC; echo $X; } | cat; echo $X ``` will make a subshell/process of , atleast `{ X=ABC; echo $X; }` and `cat`. "Each command in a pipeline is executed as a separate process (i.e., in a subshell)." , from man bash If you instead do this ```...
8152937
running nohup command on script that takes all parameters
14
2011-11-16 14:06:20
<p>I am trying to run a script with nohup, but the command happens to take an entire line of parameters with the variable $*. I try running the command like this:</p> <pre><code> nohup time ./build_all all &amp; </code></pre> <p>But this is giving me the following error in nohup.out:</p> <pre><code>./build_all:...
28,257
487,980
2011-11-16 20:44:44
8,153,324
13
2011-11-16 14:34:11
977,484
2011-11-16 14:34:11
https://stackoverflow.com/q/8152937
https://stackoverflow.com/a/8153324
<p>Simply place the arguments to “build_all” on the command line, as for any other command:</p> <pre><code>nohup time ./build_all args to build_all go here &amp; </code></pre> <p>and the arguments will be passed to “build_all”, not to “time” or “nohup”. The ampersand will be interpreted correctly by the shell, and wi...
<p>Simply place the arguments to “build_all” on the command line, as for any other command:</p> <pre><code>nohup time ./build_all args to build_all go here &amp; </code></pre> <p>and the arguments will be passed to “build_all”, not to “time” or “nohup”. The ampersand will be interpreted correctly by the shell, and wi...
387, 18966
bash, nohup
<h1>running nohup command on script that takes all parameters</h1> <p>I am trying to run a script with nohup, but the command happens to take an entire line of parameters with the variable $*. I try running the command like this:</p> <pre><code> nohup time ./build_all all &amp; </code></pre> <p>But this is givin...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,166
bash
# running nohup command on script that takes all parameters I am trying to run a script with nohup, but the command happens to take an entire line of parameters with the variable $*. I try running the command like this: ``` nohup time ./build_all all & ``` But this is giving me the following error in nohup.out: ...
Simply place the arguments to “build_all” on the command line, as for any other command: ``` nohup time ./build_all args to build_all go here & ``` and the arguments will be passed to “build_all”, not to “time” or “nohup”. The ampersand will be interpreted correctly by the shell, and will not be passed as an argument...
4711465
using "touch" to create directories?
14
2011-01-17 09:04:03
<p>1) in the "A" directory:</p> <pre><code>find . -type f &gt; a.txt </code></pre> <p>2) in the "B" directory:</p> <pre><code>cat a.txt | while read FILENAMES; do touch "$FILENAMES"; done </code></pre> <p>3) Result: the 2) "creates the files" [i mean only with the same filename, but with 0 Byte size] ok. But if the...
36,058
752,665
2011-01-17 09:23:42
4,711,489
13
2011-01-17 09:07:47
507,519
2011-01-17 09:23:42
https://stackoverflow.com/q/4711465
https://stackoverflow.com/a/4711489
<p>Since <code>find</code> outputs one file per line:</p> <pre><code>cat a.txt | while read file; do if [[ "$file" = */* ]]; then mkdir -p "${file%/*}"; fi; touch "$file"; done </code></pre> <p>EDIT:</p> <p>This would be slightly more efficient if the directories where created in a separate step...
<p>Since <code>find</code> outputs one file per line:</p> <pre><code>cat a.txt | while read file; do if [[ "$file" = */* ]]; then mkdir -p "${file%/*}"; fi; touch "$file"; done </code></pre> <p>EDIT:</p> <p>This would be slightly more efficient if the directories where created in a separate step...
58, 387
bash, linux
<h1>using "touch" to create directories?</h1> <p>1) in the "A" directory:</p> <pre><code>find . -type f &gt; a.txt </code></pre> <p>2) in the "B" directory:</p> <pre><code>cat a.txt | while read FILENAMES; do touch "$FILENAMES"; done </code></pre> <p>3) Result: the 2) "creates the files" [i mean only with the same ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,167
bash
# using "touch" to create directories? 1) in the "A" directory: ``` find . -type f > a.txt ``` 2) in the "B" directory: ``` cat a.txt | while read FILENAMES; do touch "$FILENAMES"; done ``` 3) Result: the 2) "creates the files" [i mean only with the same filename, but with 0 Byte size] ok. But if there are subdirs...
Since `find` outputs one file per line: ``` cat a.txt | while read file; do if [[ "$file" = */* ]]; then mkdir -p "${file%/*}"; fi; touch "$file"; done ``` EDIT: This would be slightly more efficient if the directories where created in a separate step: ``` cat a.txt | grep / | sed 's|/[^/]*$||'...