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
38316001
How do I combine two arrays into a third array?
7
2016-07-11 20:50:54
<p>I have two arrays: <code>array1</code> and <code>array2</code>:</p> <pre><code>array1=( a b c ) array2=( 1 2 3 ) </code></pre> <p>How do I make a third array, <code>array3</code>:</p> <pre><code>array3=( a b c 1 2 3 ) </code></pre> <p>This question is different from <a href="https://stackoverflow.com/questions/61805...
14,550
9,636
2024-07-11 15:18:42
38,316,002
13
2016-07-11 20:50:54
9,636
2023-08-02 22:09:34
https://stackoverflow.com/q/38316001
https://stackoverflow.com/a/38316002
<p>From <a href="http://tldp.org/LDP/abs/html/arrays.html#ARRAYAPPEND" rel="noreferrer">The Advanced Bash Scripting Guide example 27-10</a>, with a correction:</p> <pre><code>declare -a array1=( zero1 one1 two1 ) declare -a array2=( [0]=zero2 [2]=two2 [3]=three2 ) dest=( &quot;${array1[@]}&quot; &quot;${array2[@]}&quot...
<p>From <a href="http://tldp.org/LDP/abs/html/arrays.html#ARRAYAPPEND" rel="noreferrer">The Advanced Bash Scripting Guide example 27-10</a>, with a correction:</p> <pre><code>declare -a array1=( zero1 one1 two1 ) declare -a array2=( [0]=zero2 [2]=two2 [3]=three2 ) dest=( &quot;${array1[@]}&quot; &quot;${array2[@]}&quot...
114, 387, 6050
arrays, bash, concatenation
<h1>How do I combine two arrays into a third array?</h1> <p>I have two arrays: <code>array1</code> and <code>array2</code>:</p> <pre><code>array1=( a b c ) array2=( 1 2 3 ) </code></pre> <p>How do I make a third array, <code>array3</code>:</p> <pre><code>array3=( a b c 1 2 3 ) </code></pre> <p>This question is differen...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,470
bash
# How do I combine two arrays into a third array? I have two arrays: `array1` and `array2`: ``` array1=( a b c ) array2=( 1 2 3 ) ``` How do I make a third array, `array3`: ``` array3=( a b c 1 2 3 ) ``` This question is different from [Combine arrays in the beginning of a for-loop (Bash)](https://stackoverflow.co...
From [The Advanced Bash Scripting Guide example 27-10](http://tldp.org/LDP/abs/html/arrays.html#ARRAYAPPEND), with a correction: ``` declare -a array1=( zero1 one1 two1 ) declare -a array2=( [0]=zero2 [2]=two2 [3]=three2 ) dest=( "${array1[@]}" "${array2[@]}" ) echo "${dest[@]}" zero1 one1 two1 zero2 two2 three2 ``` ...
37904757
Get shortpath using powershell
7
2016-06-19 07:02:36
<p>I am trying to get shortpath using the below code in powershell. For some folders it works. For some it does not work. </p> <pre><code>$a = New-Object -ComObject Scripting.FileSystemObject $f = $a.GetFile("C:\Program Files\Internet Explorer") $f.ShortPath </code></pre> <p>I get the below error although the folde...
6,050
3,180,704
2025-01-09 18:05:27
37,904,822
13
2016-06-19 07:11:51
3,439,404
2016-06-19 07:11:51
https://stackoverflow.com/q/37904757
https://stackoverflow.com/a/37904822
<p>Distinguish <em>files</em> and <em>folders</em>:</p> <pre><code>$a = New-Object -ComObject Scripting.FileSystemObject $f = $a.GetFile("C:\Program Files\Internet Explorer\iexplore.exe") $f.ShortPath $f = $a.GetFolder("C:\Program Files\Internet Explorer") $f.ShortPath </code></pre> <p>Output:</p> <pre><code>C:\P...
<p>Distinguish <em>files</em> and <em>folders</em>:</p> <pre><code>$a = New-Object -ComObject Scripting.FileSystemObject $f = $a.GetFile("C:\Program Files\Internet Explorer\iexplore.exe") $f.ShortPath $f = $a.GetFolder("C:\Program Files\Internet Explorer") $f.ShortPath </code></pre> <p>Output:</p> <pre><code>C:\P...
526
powershell
<h1>Get shortpath using powershell</h1> <p>I am trying to get shortpath using the below code in powershell. For some folders it works. For some it does not work. </p> <pre><code>$a = New-Object -ComObject Scripting.FileSystemObject $f = $a.GetFile("C:\Program Files\Internet Explorer") $f.ShortPath </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,471
bash
# Get shortpath using powershell I am trying to get shortpath using the below code in powershell. For some folders it works. For some it does not work. ``` $a = New-Object -ComObject Scripting.FileSystemObject $f = $a.GetFile("C:\Program Files\Internet Explorer") $f.ShortPath ``` I get the below error although the...
Distinguish *files* and *folders*: ``` $a = New-Object -ComObject Scripting.FileSystemObject $f = $a.GetFile("C:\Program Files\Internet Explorer\iexplore.exe") $f.ShortPath $f = $a.GetFolder("C:\Program Files\Internet Explorer") $f.ShortPath ``` Output: ``` C:\PROGRA~1\INTERN~1\iexplore.exe C:\PROGRA~1\INTERN~1 `...
37672417
Getting kernel version from the compressed kernel image
7
2016-06-07 06:53:30
<p>I am working on a shell script. I have a pre-built zImage. is it possible to know the kernel version from which this zImage was created?</p> <p>I have tried with the commands updated @ <a href="https://stackoverflow.com/questions/9535227/getting-uname-information-from-a-compressed-kernel-image">Getting uname inform...
21,249
4,266,488
2021-12-16 04:13:59
37,689,814
13
2016-06-07 21:37:29
3,866,447
2016-06-07 21:37:29
https://stackoverflow.com/q/37672417
https://stackoverflow.com/a/37689814
<h1>Check kernel compression algorithm</h1> <p>Most likely your <code>zImage</code> was compressed using LZMA compressor. You can check it in next files:</p> <ul> <li>in <code>.config</code> file (if you built kernel by yourself)</li> <li>in <code>/boot/config-`uname -r`</code> file (if you are using your distributio...
<h1>Check kernel compression algorithm</h1> <p>Most likely your <code>zImage</code> was compressed using LZMA compressor. You can check it in next files:</p> <ul> <li>in <code>.config</code> file (if you built kernel by yourself)</li> <li>in <code>/boot/config-`uname -r`</code> file (if you are using your distributio...
58, 390, 21990, 28643
embedded-linux, linux, linux-kernel, shell
<h1>Getting kernel version from the compressed kernel image</h1> <p>I am working on a shell script. I have a pre-built zImage. is it possible to know the kernel version from which this zImage was created?</p> <p>I have tried with the commands updated @ <a href="https://stackoverflow.com/questions/9535227/getting-uname...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,472
bash
# Getting kernel version from the compressed kernel image I am working on a shell script. I have a pre-built zImage. is it possible to know the kernel version from which this zImage was created? I have tried with the commands updated @ [Getting uname information from a compressed kernel image](https://stackoverflow.c...
# Check kernel compression algorithm Most likely your `zImage` was compressed using LZMA compressor. You can check it in next files: - in `.config` file (if you built kernel by yourself) - in `` /boot/config-`uname -r` `` file (if you are using your distribution) - in `/proc/config.gz` file (if `CONFIG_IKCONFIG_PROC`...
36316040
Exit a bash script if an error occurs in it or any of the background jobs it creates
7
2016-03-30 17:46:35
<p><strong>Background</strong></p> <p>I'm working on a bash script to automate the process of building half a dozen projects that live in the same directory. Each project has two scripts to run in order to build it:</p> <pre><code>npm install npm run build </code></pre> <p>The first line will fetch all of the depend...
5,006
2,193,290
2016-03-30 19:50:11
36,316,357
13
2016-03-30 18:02:46
14,122
2016-03-30 19:42:25
https://stackoverflow.com/q/36316040
https://stackoverflow.com/a/36316357
<p>Collect the PIDs for the background jobs; then, use <code>wait</code> to collect the exit status of each, exiting the first time any PID polled over in that loop is nonzero.</p> <pre><code>install_pids=( ) for dir in ./projects/**/; do (cd "$dir" &amp;&amp; exec npm install) &amp; install_pids+=( $! ) done for pi...
<p>Collect the PIDs for the background jobs; then, use <code>wait</code> to collect the exit status of each, exiting the first time any PID polled over in that loop is nonzero.</p> <pre><code>install_pids=( ) for dir in ./projects/**/; do (cd "$dir" &amp;&amp; exec npm install) &amp; install_pids+=( $! ) done for pi...
387, 390, 1783, 61387
bash, build-process, npm, shell
<h1>Exit a bash script if an error occurs in it or any of the background jobs it creates</h1> <p><strong>Background</strong></p> <p>I'm working on a bash script to automate the process of building half a dozen projects that live in the same directory. Each project has two scripts to run in order to build it:</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,473
bash
# Exit a bash script if an error occurs in it or any of the background jobs it creates **Background** I'm working on a bash script to automate the process of building half a dozen projects that live in the same directory. Each project has two scripts to run in order to build it: ``` npm install npm run build ``` Th...
Collect the PIDs for the background jobs; then, use `wait` to collect the exit status of each, exiting the first time any PID polled over in that loop is nonzero. ``` install_pids=( ) for dir in ./projects/**/; do (cd "$dir" && exec npm install) & install_pids+=( $! ) done for pid in "${install_pids[@]}"; do wait ...
35820818
How do I go to the next command in Git Bash after using git log?
7
2016-03-05 22:43:07
<p>When using Git Bash, I type the command:</p> <pre><code>git log </code></pre> <p>It shows me all the logs. But now I want to do a second command. So I hold the down arrow to get to the bottom of the logs and it just says <code>(END)</code>. How do I get to the next line so I can enter my next command?</p>
8,237
3,010,223
2016-03-06 06:45:29
35,820,935
13
2016-03-05 22:55:08
216,074
2016-03-05 22:55:08
https://stackoverflow.com/q/35820818
https://stackoverflow.com/a/35820935
<p>By default, Git commands that display a lot of information will show the information through a different program, called <a href="https://en.wikipedia.org/wiki/Terminal_pager" rel="noreferrer">terminal pager</a>. These programs basically show you the information in pages, so that you can see everything and not only ...
<p>By default, Git commands that display a lot of information will show the information through a different program, called <a href="https://en.wikipedia.org/wiki/Terminal_pager" rel="noreferrer">terminal pager</a>. These programs basically show you the information in pages, so that you can see everything and not only ...
119, 47913, 61874
git, git-bash, git-log
<h1>How do I go to the next command in Git Bash after using git log?</h1> <p>When using Git Bash, I type the command:</p> <pre><code>git log </code></pre> <p>It shows me all the logs. But now I want to do a second command. So I hold the down arrow to get to the bottom of the logs and it just says <code>(END)</code>. ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,474
bash
# How do I go to the next command in Git Bash after using git log? When using Git Bash, I type the command: ``` git log ``` It shows me all the logs. But now I want to do a second command. So I hold the down arrow to get to the bottom of the logs and it just says `(END)`. How do I get to the next line so I can enter...
By default, Git commands that display a lot of information will show the information through a different program, called [terminal pager](https://en.wikipedia.org/wiki/Terminal_pager). These programs basically show you the information in pages, so that you can see everything and not only the very last bit of informatio...
35289912
openssl enc -base64 -d does not decode strings after a certain length
7
2016-02-09 10:43:11
<p>I have a simple bash script that does encoding / decoding for strings using base64. The script is:</p> <pre><code>#!/bin/bash echo "encode or decode ?" read input if [ "$input" == "encode" ] then echo Please, enter your secret message read message echo "The cipher representing your message is" echo -n $message |...
9,686
5,482,311
2016-02-09 16:07:21
35,296,674
13
2016-02-09 16:07:21
2,214,695
2016-02-09 16:07:21
https://stackoverflow.com/q/35289912
https://stackoverflow.com/a/35296674
<p><code>openssl enc -base64</code> is inserting a carriage return after 64 characters of encoded string. This actually happens about the 49th character of string to be encoded.</p> <p>To avoid this line break in the encoded string, use option <code>-A</code> in both <code>openssl</code> commands to encode or decode t...
<p><code>openssl enc -base64</code> is inserting a carriage return after 64 characters of encoded string. This actually happens about the 49th character of string to be encoded.</p> <p>To avoid this line break in the encoded string, use option <code>-A</code> in both <code>openssl</code> commands to encode or decode t...
387, 1124, 1999
bash, encoding, openssl
<h1>openssl enc -base64 -d does not decode strings after a certain length</h1> <p>I have a simple bash script that does encoding / decoding for strings using base64. The script is:</p> <pre><code>#!/bin/bash echo "encode or decode ?" read input if [ "$input" == "encode" ] then echo Please, enter your secret message ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,475
bash
# openssl enc -base64 -d does not decode strings after a certain length I have a simple bash script that does encoding / decoding for strings using base64. The script is: ``` #!/bin/bash echo "encode or decode ?" read input if [ "$input" == "encode" ] then echo Please, enter your secret message read message echo "...
`openssl enc -base64` is inserting a carriage return after 64 characters of encoded string. This actually happens about the 49th character of string to be encoded. To avoid this line break in the encoded string, use option `-A` in both `openssl` commands to encode or decode the whole string at once: ``` echo -n $mess...
31982926
New-Item changes function return value
7
2015-08-13 08:13:57
<p>I want to write a function that creates a folder (if it doesn't exist) with specified name inside specified folder. It's turned out that depending on calling <code>New-Item</code> function return different values. And I can't figure out how it's related to <code>New-Item</code> actually.</p> <pre><code>$folderPath ...
4,643
1,606,662
2019-06-06 14:20:38
31,983,602
13
2015-08-13 08:51:49
1,630,171
2015-08-13 08:51:49
https://stackoverflow.com/q/31982926
https://stackoverflow.com/a/31983602
<p><code>New-Item</code> returns the created object, and PowerShell functions return all non-captured output, not just the argument of the <a href="https://technet.microsoft.com/en-us/library/hh847760.aspx" rel="noreferrer"><code>return</code></a> keyword.</p> <blockquote> <p>In Windows PowerShell, the results of ea...
<p><code>New-Item</code> returns the created object, and PowerShell functions return all non-captured output, not just the argument of the <a href="https://technet.microsoft.com/en-us/library/hh847760.aspx" rel="noreferrer"><code>return</code></a> keyword.</p> <blockquote> <p>In Windows PowerShell, the results of ea...
526, 108010
powershell, powershell-5.0
<h1>New-Item changes function return value</h1> <p>I want to write a function that creates a folder (if it doesn't exist) with specified name inside specified folder. It's turned out that depending on calling <code>New-Item</code> function return different values. And I can't figure out how it's related to <code>New-It...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,476
bash
# New-Item changes function return value I want to write a function that creates a folder (if it doesn't exist) with specified name inside specified folder. It's turned out that depending on calling `New-Item` function return different values. And I can't figure out how it's related to `New-Item` actually. ``` $folde...
`New-Item` returns the created object, and PowerShell functions return all non-captured output, not just the argument of the [`return`](https://technet.microsoft.com/en-us/library/hh847760.aspx) keyword. > In Windows PowerShell, the results of each statement are returned as output, even without a statement that contai...
31722119
Get the path where git alias was run from
7
2015-07-30 11:06:52
<p>When an external command is run via Git alias, it is run from the rood directory of the repository (where the .git/ is usually located). It can be checked with:</p> <pre><code>$ cd /some/path/inside/repo $ echo $(git -c alias.root='!pwd' root) </code></pre> <p>Now, <strong>is there a way to get the exact path wher...
1,947
2,790,048
2015-07-30 16:59:06
31,722,425
13
2015-07-30 11:22:22
6,309
2015-07-30 11:22:22
https://stackoverflow.com/q/31722119
https://stackoverflow.com/a/31722425
<p>You need to add <code>cd ${GIT_PREFIX:-.}</code> in your alias. </p> <p>(<a href="https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/Documentation/RelNotes/1.7.6.txt#L29-L31" rel="noreferrer">Git 1.7.6+</a>:</p> <blockquote> <p>Processes spawned by "<code>[alias] &lt;name&gt; = !process</c...
<p>You need to add <code>cd ${GIT_PREFIX:-.}</code> in your alias. </p> <p>(<a href="https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/Documentation/RelNotes/1.7.6.txt#L29-L31" rel="noreferrer">Git 1.7.6+</a>:</p> <blockquote> <p>Processes spawned by "<code>[alias] &lt;name&gt; = !process</c...
119, 390, 79211
git, git-alias, shell
<h1>Get the path where git alias was run from</h1> <p>When an external command is run via Git alias, it is run from the rood directory of the repository (where the .git/ is usually located). It can be checked with:</p> <pre><code>$ cd /some/path/inside/repo $ echo $(git -c alias.root='!pwd' root) </code></pre> <p>Now...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,477
bash
# Get the path where git alias was run from When an external command is run via Git alias, it is run from the rood directory of the repository (where the .git/ is usually located). It can be checked with: ``` $ cd /some/path/inside/repo $ echo $(git -c alias.root='!pwd' root) ``` Now, **is there a way to get the exa...
You need to add `cd ${GIT_PREFIX:-.}` in your alias. ([Git 1.7.6+](https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/Documentation/RelNotes/1.7.6.txt#L29-L31): > Processes spawned by "`[alias] <name> = !process`" in the configuration > can inspect `GIT_PREFIX` environment variable to learn wher...
13633826
How can I use ConvertTo-SecureString
7
2012-11-29 20:06:53
<p>Let's say I need to do this in Powershell:</p> <pre><code> $SecurePass = Get-Content $CredPath | ConvertTo-SecureString -Key (1..16) [String]$CleartextPass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($CredPass)); </code></pre> <p>The content of ...
19,033
1,848,046
2019-02-22 17:57:08
30,758,078
13
2015-06-10 13:39:30
4,995,043
2015-06-15 14:04:46
https://stackoverflow.com/q/13633826
https://stackoverflow.com/a/30758078
<p>I know this is an old post. I am posting this for completeness and posterity, because I couldn't find a complete answer on MSDN or stackoverflow. It will be here in case I ever need to do this again.</p> <p>It is a C# implementation of of powershell's ConvertTo-SecureString with AES encryption (turned on by using...
<p>I know this is an old post. I am posting this for completeness and posterity, because I couldn't find a complete answer on MSDN or stackoverflow. It will be here in case I ever need to do this again.</p> <p>It is a C# implementation of of powershell's ConvertTo-SecureString with AES encryption (turned on by using...
1, 9, 219, 526, 6728
.net, aes, c#, encryption, powershell
<h1>How can I use ConvertTo-SecureString</h1> <p>Let's say I need to do this in Powershell:</p> <pre><code> $SecurePass = Get-Content $CredPath | ConvertTo-SecureString -Key (1..16) [String]$CleartextPass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR(...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,478
bash
# How can I use ConvertTo-SecureString Let's say I need to do this in Powershell: ``` $SecurePass = Get-Content $CredPath | ConvertTo-SecureString -Key (1..16) [String]$CleartextPass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($CredPass)); ``` Th...
I know this is an old post. I am posting this for completeness and posterity, because I couldn't find a complete answer on MSDN or stackoverflow. It will be here in case I ever need to do this again. It is a C# implementation of of powershell's ConvertTo-SecureString with AES encryption (turned on by using the -key op...
29755942
Possible to urlencode a variable in a shell script?
7
2015-04-20 18:44:35
<p>Is it possible to url encode a variable within a shell script?</p> <pre><code>#!/bin/bash now=$(date +"%T") DATA=$(wget -q -O - "http://someurl.com/x.htm?callback=webRequest&amp;exthrs=1&amp;extMode=&amp;fund=1&amp;entitlement=0&amp;skipcache=&amp;extendedMask=1&amp;partnerId=2&amp;output=json&amp;noform=1") ...
12,108
4,440,636
2021-08-26 18:23:57
29,756,078
13
2015-04-20 18:52:46
3,030,305
2015-04-20 18:52:46
https://stackoverflow.com/q/29755942
https://stackoverflow.com/a/29756078
<p>Here is one method for URL encoding the shell string <code>DATA</code>:</p> <pre><code>DATA=$(python -c "import urllib, sys; print urllib.quote(sys.argv[1])" "$DATA") </code></pre> <p>Here is another:</p> <pre><code>DATA=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$DATA") </code></pre>
<p>Here is one method for URL encoding the shell string <code>DATA</code>:</p> <pre><code>DATA=$(python -c "import urllib, sys; print urllib.quote(sys.argv[1])" "$DATA") </code></pre> <p>Here is another:</p> <pre><code>DATA=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$DATA") </code></pre>
390, 5583, 10327
sh, shell, wget
<h1>Possible to urlencode a variable in a shell script?</h1> <p>Is it possible to url encode a variable within a shell script?</p> <pre><code>#!/bin/bash now=$(date +"%T") DATA=$(wget -q -O - "http://someurl.com/x.htm?callback=webRequest&amp;exthrs=1&amp;extMode=&amp;fund=1&amp;entitlement=0&amp;skipcache=&amp;e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,479
bash
# Possible to urlencode a variable in a shell script? Is it possible to url encode a variable within a shell script? ``` #!/bin/bash now=$(date +"%T") DATA=$(wget -q -O - "http://someurl.com/x.htm?callback=webRequest&exthrs=1&extMode=&fund=1&entitlement=0&skipcache=&extendedMask=1&partnerId=2&output=json&noform...
Here is one method for URL encoding the shell string `DATA`: ``` DATA=$(python -c "import urllib, sys; print urllib.quote(sys.argv[1])" "$DATA") ``` Here is another: ``` DATA=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$DATA") ```
29427364
Non-bash equivalent to "trap ERR"
7
2015-04-03 06:35:09
<p>I'm trying to remove some bashisms from a shell script.</p> <p>I can't figure out how I would replicate 'trap ERR': ERR is not a signal, and is not in the <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28" rel="noreferrer">standard</a>, but is a common bashism (see e.g. <a ...
2,015
463,510
2015-04-04 14:03:43
29,447,316
13
2015-04-04 14:03:43
1,126,841
2015-04-04 14:03:43
https://stackoverflow.com/q/29427364
https://stackoverflow.com/a/29447316
<p>You can use a combination of <code>set -e</code> and <code>trap ... EXIT</code>.</p> <pre><code>#!/bin/sh set -e err_handler () { [ $? -eq 0 ] &amp;&amp; exit # Code for non-zero exit status here } trap err_handler EXIT </code></pre> <p><code>set -e</code> will cause the script to exit whenever an ungua...
<p>You can use a combination of <code>set -e</code> and <code>trap ... EXIT</code>.</p> <pre><code>#!/bin/sh set -e err_handler () { [ $? -eq 0 ] &amp;&amp; exit # Code for non-zero exit status here } trap err_handler EXIT </code></pre> <p><code>set -e</code> will cause the script to exit whenever an ungua...
387, 390
bash, shell
<h1>Non-bash equivalent to "trap ERR"</h1> <p>I'm trying to remove some bashisms from a shell script.</p> <p>I can't figure out how I would replicate 'trap ERR': ERR is not a signal, and is not in the <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28" rel="noreferrer">standard...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,480
bash
# Non-bash equivalent to "trap ERR" I'm trying to remove some bashisms from a shell script. I can't figure out how I would replicate 'trap ERR': ERR is not a signal, and is not in the [standard](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28), but is a common bashism (see e.g. [the...
You can use a combination of `set -e` and `trap ... EXIT`. ``` #!/bin/sh set -e err_handler () { [ $? -eq 0 ] && exit # Code for non-zero exit status here } trap err_handler EXIT ``` `set -e` will cause the script to exit whenever an unguarded command has an non-zero exit status. The error handler will be ...
29242217
"sh: line 1: Moved: command not found" installing npm with curl | sh
7
2015-03-24 20:25:52
<p>I attempted to install <code>npm</code> on mac OSX Yosemite with the command:</p> <pre class="lang-sh prettyprint-override"><code>curl https://www.npmjs.org/install.sh | sh </code></pre> <p>And I received the following message: </p> <pre class="lang-none prettyprint-override"><code>% Total % Received % Xferd ...
4,403
2,898,736
2015-07-16 14:38:40
29,242,272
13
2015-03-24 20:29:09
2,050,455
2015-03-25 02:11:20
https://stackoverflow.com/q/29242217
https://stackoverflow.com/a/29242272
<p>You're missing the curl <code>-L</code> option to follow redirects. However, you don't need to use this installation method anymore, npm comes with node and if your distro happens to split node's components up, npm is usually available as a separate package from one of your distro's repositories.</p>
<p>You're missing the curl <code>-L</code> option to follow redirects. However, you don't need to use this installation method anymore, npm comes with node and if your distro happens to split node's components up, npm is usually available as a separate package from one of your distro's repositories.</p>
58, 387, 390, 1554, 46426
bash, curl, linux, node.js, shell
<h1>"sh: line 1: Moved: command not found" installing npm with curl | sh</h1> <p>I attempted to install <code>npm</code> on mac OSX Yosemite with the command:</p> <pre class="lang-sh prettyprint-override"><code>curl https://www.npmjs.org/install.sh | sh </code></pre> <p>And I received the following message: </p> <pr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,481
bash
# "sh: line 1: Moved: command not found" installing npm with curl | sh I attempted to install `npm` on mac OSX Yosemite with the command: ``` curl https://www.npmjs.org/install.sh | sh ``` And I received the following message: ``` % Total % Received % Xferd Average Speed Time Time Time Current ...
You're missing the curl `-L` option to follow redirects. However, you don't need to use this installation method anymore, npm comes with node and if your distro happens to split node's components up, npm is usually available as a separate package from one of your distro's repositories.
28725944
merge contents of two files into one file in bash
7
2015-02-25 17:41:29
<p>I have two files which has following contents</p> <p>File1</p> <pre><code>Line1file1 Line2file1 line3file1 line4file1 </code></pre> <p>File2</p> <pre><code>Line1file2 Line2file2 line3file2 line4file2 </code></pre> <p>I want to have these file's content merged to file3 as</p> <p>File3</p> <pre><code>Line1file1...
14,504
3,784,040
2017-03-31 17:49:36
28,726,079
13
2015-02-25 17:48:50
2,842,375
2015-02-25 17:48:50
https://stackoverflow.com/q/28725944
https://stackoverflow.com/a/28726079
<p>You can always use <a href="http://www.computerhope.com/unix/upaste.htm" rel="noreferrer"><code>paste</code></a> command.</p> <pre><code>paste -d"\n" File1 File2 &gt; File3 </code></pre>
<p>You can always use <a href="http://www.computerhope.com/unix/upaste.htm" rel="noreferrer"><code>paste</code></a> command.</p> <pre><code>paste -d"\n" File1 File2 &gt; File3 </code></pre>
58, 387, 717, 990, 5282
awk, bash, linux, merge, sed
<h1>merge contents of two files into one file in bash</h1> <p>I have two files which has following contents</p> <p>File1</p> <pre><code>Line1file1 Line2file1 line3file1 line4file1 </code></pre> <p>File2</p> <pre><code>Line1file2 Line2file2 line3file2 line4file2 </code></pre> <p>I want to have these file's content ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,482
bash
# merge contents of two files into one file in bash I have two files which has following contents File1 ``` Line1file1 Line2file1 line3file1 line4file1 ``` File2 ``` Line1file2 Line2file2 line3file2 line4file2 ``` I want to have these file's content merged to file3 as File3 ``` Line1file1 Line1file2 Line2file1 ...
You can always use [`paste`](http://www.computerhope.com/unix/upaste.htm) command. ``` paste -d"\n" File1 File2 > File3 ```
28450603
bash wildcard with variables inside an if statement
7
2015-02-11 09:21:59
<p>I want to find substring in a string according to <a href="https://stackoverflow.com/questions/229551/string-contains-in-bash">this solution</a>.</p> <p>But for some reason it doesn't work with variables:</p> <pre><code>str="abcd"; substr="abc"; if [[ "${substr}"* == ${str} ]] then echo "CONTAINS!"; fi </c...
18,897
1,114,130
2015-02-11 09:36:44
28,450,908
13
2015-02-11 09:36:44
1,815,797
2015-02-11 09:36:44
https://stackoverflow.com/q/28450603
https://stackoverflow.com/a/28450908
<p>In the reference manual, <a href="http://www.gnu.org/software/bash/manual/bashref.html#Conditional-Constructs" rel="noreferrer">section <em>Conditional Constructs</em></a>, you will read, for the documentation of <code>[[ ... ]]</code>:</p> <blockquote> <p>When the <code>==</code> and <code>!=</code> operators ar...
<p>In the reference manual, <a href="http://www.gnu.org/software/bash/manual/bashref.html#Conditional-Constructs" rel="noreferrer">section <em>Conditional Constructs</em></a>, you will read, for the documentation of <code>[[ ... ]]</code>:</p> <blockquote> <p>When the <code>==</code> and <code>!=</code> operators ar...
139, 387, 2773, 5997
bash, if-statement, string, wildcard
<h1>bash wildcard with variables inside an if statement</h1> <p>I want to find substring in a string according to <a href="https://stackoverflow.com/questions/229551/string-contains-in-bash">this solution</a>.</p> <p>But for some reason it doesn't work with variables:</p> <pre><code>str="abcd"; substr="abc"; if [[ "$...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,483
bash
# bash wildcard with variables inside an if statement I want to find substring in a string according to [this solution](https://stackoverflow.com/questions/229551/string-contains-in-bash). But for some reason it doesn't work with variables: ``` str="abcd"; substr="abc"; if [[ "${substr}"* == ${str} ]] then e...
In the reference manual, [section *Conditional Constructs*](http://www.gnu.org/software/bash/manual/bashref.html#Conditional-Constructs), you will read, for the documentation of `[[ ... ]]`: > When the `==` and `!=` operators are used, **the string to the right of the operator is considered a pattern** and matched acc...
27090373
Monit restart program script
7
2014-11-23 15:06:38
<p>I am fairly new to monit and I was wondering if this script is enough to restart a crashed program lets say program1 is the name of the program.</p> <pre><code>check process program1 matching "program1" start program = "/home/user/files/start.sh" stop program = "/home/user/files/stop.sh" </code></pre> <p>Will it r...
19,895
3,572,440
2017-04-01 08:32:52
27,091,258
13
2014-11-23 16:25:35
2,057,388
2014-11-23 20:01:10
https://stackoverflow.com/q/27090373
https://stackoverflow.com/a/27091258
<blockquote> <p>Monit uses the system call execv to execute a program or a script. This means that you cannot write shell commands directly in the start, stop or exec statements. To do this, you must do as above; start a shell and issue your commands there.</p> </blockquote> <p><a href="http://mmonit.com/wiki/...
<blockquote> <p>Monit uses the system call execv to execute a program or a script. This means that you cannot write shell commands directly in the start, stop or exec statements. To do this, you must do as above; start a shell and issue your commands there.</p> </blockquote> <p><a href="http://mmonit.com/wiki/...
58, 387, 390, 21166
bash, linux, monit, shell
<h1>Monit restart program script</h1> <p>I am fairly new to monit and I was wondering if this script is enough to restart a crashed program lets say program1 is the name of the program.</p> <pre><code>check process program1 matching "program1" start program = "/home/user/files/start.sh" stop program = "/home/user/file...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,484
bash
# Monit restart program script I am fairly new to monit and I was wondering if this script is enough to restart a crashed program lets say program1 is the name of the program. ``` check process program1 matching "program1" start program = "/home/user/files/start.sh" stop program = "/home/user/files/stop.sh" ``` Will...
> Monit uses the system call execv to execute a program or a script. > This means that you cannot write shell commands directly in the start, > stop or exec statements. To do this, you must do as above; start a > shell and issue your commands there. [`Read about execution`](http://mmonit.com/wiki/Monit/FAQ#execution) ...
26593200
Listen for a key press with PowerShell, but don't wait for it
7
2014-10-27 17:24:08
<p>I'm trying to write a script that toggles the <a href="https://en.wikipedia.org/wiki/Caps_Lock" rel="nofollow noreferrer">Caps Lock</a> key periodically, but I also want to be able to toggle the script because it causes some issues with other functionality (like <kbd>Alt</kbd> tabbing, and rolling over Windows in th...
37,041
2,954,317
2025-04-09 21:56:53
26,595,471
13
2014-10-27 19:36:09
2,627,148
2014-10-27 19:36:09
https://stackoverflow.com/q/26593200
https://stackoverflow.com/a/26595471
<p>Here is a try. BTW I changed the sleep to 1 second so it doesn't flash capslock too much while testing:</p> <pre><code>$continue = $true while($continue) { if ([console]::KeyAvailable) { echo "Toggle with F12"; $x = [System.Console]::ReadKey() switch ( $x.key) { ...
<p>Here is a try. BTW I changed the sleep to 1 second so it doesn't flash capslock too much while testing:</p> <pre><code>$continue = $true while($continue) { if ([console]::KeyAvailable) { echo "Toggle with F12"; $x = [System.Console]::ReadKey() switch ( $x.key) { ...
526
powershell
<h1>Listen for a key press with PowerShell, but don't wait for it</h1> <p>I'm trying to write a script that toggles the <a href="https://en.wikipedia.org/wiki/Caps_Lock" rel="nofollow noreferrer">Caps Lock</a> key periodically, but I also want to be able to toggle the script because it causes some issues with other fun...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,485
bash
# Listen for a key press with PowerShell, but don't wait for it I'm trying to write a script that toggles the [Caps Lock](https://en.wikipedia.org/wiki/Caps_Lock) key periodically, but I also want to be able to toggle the script because it causes some issues with other functionality (like `Alt` tabbing, and rolling ov...
Here is a try. BTW I changed the sleep to 1 second so it doesn't flash capslock too much while testing: ``` $continue = $true while($continue) { if ([console]::KeyAvailable) { echo "Toggle with F12"; $x = [System.Console]::ReadKey() switch ( $x.key) { F12 { $conti...
25324162
How to pass two parameters or arguments in bash scripting
7
2014-08-15 09:29:58
<p>I am new to bash scripting and I need your support to solve this problem. I have a bash script "start.sh". I want to write a script with two arguments so that I could run the script in the following way</p> <p>./start.sh -dayoffset 1 -processMode true</p> <p>dayoffset and processMode are the two parameters that I ...
36,509
1,983,063
2018-01-05 16:06:13
25,324,203
13
2014-08-15 09:33:30
445,221
2014-08-15 09:46:07
https://stackoverflow.com/q/25324162
https://stackoverflow.com/a/25324203
<p>As a start you can do this:</p> <pre><code>#!/bin/bash dayoffset=$1 processMode=$2 echo "Do something with $dayoffset and $processMode." </code></pre> <p>Usage:</p> <pre><code>./start.sh 1 true </code></pre> <p>Another:</p> <pre><code>#!/bin/bash while [[ $# -gt 0 ]]; do case "$1" in -dayoffset) ...
<p>As a start you can do this:</p> <pre><code>#!/bin/bash dayoffset=$1 processMode=$2 echo "Do something with $dayoffset and $processMode." </code></pre> <p>Usage:</p> <pre><code>./start.sh 1 true </code></pre> <p>Another:</p> <pre><code>#!/bin/bash while [[ $# -gt 0 ]]; do case "$1" in -dayoffset) ...
34, 58, 387, 390
bash, linux, shell, unix
<h1>How to pass two parameters or arguments in bash scripting</h1> <p>I am new to bash scripting and I need your support to solve this problem. I have a bash script "start.sh". I want to write a script with two arguments so that I could run the script in the following way</p> <p>./start.sh -dayoffset 1 -processMode tr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,486
bash
# How to pass two parameters or arguments in bash scripting I am new to bash scripting and I need your support to solve this problem. I have a bash script "start.sh". I want to write a script with two arguments so that I could run the script in the following way ./start.sh -dayoffset 1 -processMode true dayoffset an...
As a start you can do this: ``` #!/bin/bash dayoffset=$1 processMode=$2 echo "Do something with $dayoffset and $processMode." ``` Usage: ``` ./start.sh 1 true ``` Another: ``` #!/bin/bash while [[ $# -gt 0 ]]; do case "$1" in -dayoffset) day_offset=$2 shift ;; -processMode) ...
20689850
Define schemes in an xcode phonegap project from terminal
7
2013-12-19 19:13:49
<p>I'm writing a script to archive the iOS portion of a phonegap project. The script wipes the directory that the project is in and then repopulates it using the latest code from source control. I then run<code>$ phonegap local build ios</code> in order to build the project. However in order to archive the project I...
3,851
2,615,252
2015-03-08 19:25:59
23,901,764
13
2014-05-28 02:11:27
2,288,565
2014-05-28 02:11:27
https://stackoverflow.com/q/20689850
https://stackoverflow.com/a/23901764
<p>This is a completely fair question given that Xcode schemes are somewhat less than thoroughly documented and schemes have this feeling of being somewhat magical until you see how they hook into the build process as a whole.</p> <p>Based on the workarounds you are seeking, it sounds as though you need to promote a s...
<p>This is a completely fair question given that Xcode schemes are somewhat less than thoroughly documented and schemes have this feeling of being somewhat magical until you see how they hook into the build process as a whole.</p> <p>Based on the workarounds you are seeking, it sounds as though you need to promote a s...
387, 12892, 78331
bash, cordova, xcodebuild
<h1>Define schemes in an xcode phonegap project from terminal</h1> <p>I'm writing a script to archive the iOS portion of a phonegap project. The script wipes the directory that the project is in and then repopulates it using the latest code from source control. I then run<code>$ phonegap local build ios</code> in ord...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,487
bash
# Define schemes in an xcode phonegap project from terminal I'm writing a script to archive the iOS portion of a phonegap project. The script wipes the directory that the project is in and then repopulates it using the latest code from source control. I then run`$ phonegap local build ios` in order to build the projec...
This is a completely fair question given that Xcode schemes are somewhat less than thoroughly documented and schemes have this feeling of being somewhat magical until you see how they hook into the build process as a whole. Based on the workarounds you are seeking, it sounds as though you need to promote a scheme to b...
23761109
Invoke-command -ArgumentList parameter syntax
7
2014-05-20 13:25:09
<p>I'm trying to add multiple csv-imported lists to a remote executed PS script. It works fine when I pass only one list using the following command:</p> <pre><code>Invoke-Command -filepath $createSAPSPath -ConnectionUri $uri -Credential $credential -ArgumentList (,$accountsList) </code></pre> <p>What would be the co...
69,220
1,241,342
2021-08-03 18:45:16
23,766,633
13
2014-05-20 17:49:27
674,943
2014-05-20 17:49:27
https://stackoverflow.com/q/23761109
https://stackoverflow.com/a/23766633
<p>You have to realize why you need unary comma in the first situation, to understand why its not needed in the second one.</p> <p>Parameter <code>-ArgumentList</code> takes <code>Object[]</code> argument type. If you are passing single collection, you need to prevent PowerShell from treating single argument (that hap...
<p>You have to realize why you need unary comma in the first situation, to understand why its not needed in the second one.</p> <p>Parameter <code>-ArgumentList</code> takes <code>Object[]</code> argument type. If you are passing single collection, you need to prevent PowerShell from treating single argument (that hap...
526, 63177
powershell, powershell-remoting
<h1>Invoke-command -ArgumentList parameter syntax</h1> <p>I'm trying to add multiple csv-imported lists to a remote executed PS script. It works fine when I pass only one list using the following command:</p> <pre><code>Invoke-Command -filepath $createSAPSPath -ConnectionUri $uri -Credential $credential -ArgumentList ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,488
bash
# Invoke-command -ArgumentList parameter syntax I'm trying to add multiple csv-imported lists to a remote executed PS script. It works fine when I pass only one list using the following command: ``` Invoke-Command -filepath $createSAPSPath -ConnectionUri $uri -Credential $credential -ArgumentList (,$accountsList) ```...
You have to realize why you need unary comma in the first situation, to understand why its not needed in the second one. Parameter `-ArgumentList` takes `Object[]` argument type. If you are passing single collection, you need to prevent PowerShell from treating single argument (that happens to be a collection) as coll...
23147370
How to schedule a shell script in Linux centos?
7
2014-04-18 04:28:13
<p>I have a script that I need to schedule on daily basis. How can I schedule a script in centos. Like I want to run that script everyday at 10 AM and can I store the output of the script in a log file.</p> <p>How to achieve this?</p> <p>Thanks</p>
19,025
3,466,859
2014-04-18 04:33:43
23,147,406
13
2014-04-18 04:33:43
970,195
2014-04-18 04:33:43
https://stackoverflow.com/q/23147370
https://stackoverflow.com/a/23147406
<p>To schedule a script, you'll need to use <code>crontab</code>. You can add a schedule entry by doing:</p> <pre><code>crontab -e </code></pre> <p>Once you are inside, the <code>cron</code> accepts pattern in the form: </p> <pre><code>&lt;Minute&gt; &lt;Hour&gt; &lt;Day&gt; &lt;Month&gt; &lt;Day of Week&gt; &lt;Com...
<p>To schedule a script, you'll need to use <code>crontab</code>. You can add a schedule entry by doing:</p> <pre><code>crontab -e </code></pre> <p>Once you are inside, the <code>cron</code> accepts pattern in the form: </p> <pre><code>&lt;Minute&gt; &lt;Hour&gt; &lt;Day&gt; &lt;Month&gt; &lt;Day of Week&gt; &lt;Com...
58, 390, 4192
linux, scheduling, shell
<h1>How to schedule a shell script in Linux centos?</h1> <p>I have a script that I need to schedule on daily basis. How can I schedule a script in centos. Like I want to run that script everyday at 10 AM and can I store the output of the script in a log file.</p> <p>How to achieve this?</p> <p>Thanks</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,489
bash
# How to schedule a shell script in Linux centos? I have a script that I need to schedule on daily basis. How can I schedule a script in centos. Like I want to run that script everyday at 10 AM and can I store the output of the script in a log file. How to achieve this? Thanks
To schedule a script, you'll need to use `crontab`. You can add a schedule entry by doing: ``` crontab -e ``` Once you are inside, the `cron` accepts pattern in the form: ``` <Minute> <Hour> <Day> <Month> <Day of Week> <Command> ``` So a correct crontab entry for 10am would be ``` 0 10 * * * /path/to/script ``` I...
22048216
How to remove a file whose name starts with '-'
7
2014-02-26 17:01:59
<p>After a mistake in a script I ended up with a file whose name starts with a dash, <code>-</code>:</p> <pre><code>-myfile.txt </code></pre> <p>I tried so far:</p> <pre><code>rm -myfile.txt rm: illegal option -- m usage: rm [-f | -i] [-dPRrvW] file ... unlink file rm "-myfile.txt" rm: illegal option -- m us...
3,222
3,297,428
2019-04-03 16:31:28
22,048,350
13
2014-02-26 17:06:56
3,297,428
2014-02-26 17:06:56
https://stackoverflow.com/q/22048216
https://stackoverflow.com/a/22048350
<p>Thanks to @ajp15243 : the answer is :</p> <pre><code>rm ./-myfile.txt </code></pre> <p>or</p> <pre><code>rm -- -myfile.txt </code></pre>
<p>Thanks to @ajp15243 : the answer is :</p> <pre><code>rm ./-myfile.txt </code></pre> <p>or</p> <pre><code>rm -- -myfile.txt </code></pre>
34, 387, 390, 5610
bash, rm, shell, unix
<h1>How to remove a file whose name starts with '-'</h1> <p>After a mistake in a script I ended up with a file whose name starts with a dash, <code>-</code>:</p> <pre><code>-myfile.txt </code></pre> <p>I tried so far:</p> <pre><code>rm -myfile.txt rm: illegal option -- m usage: rm [-f | -i] [-dPRrvW] file ... ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,490
bash
# How to remove a file whose name starts with '-' After a mistake in a script I ended up with a file whose name starts with a dash, `-`: ``` -myfile.txt ``` I tried so far: ``` rm -myfile.txt rm: illegal option -- m usage: rm [-f | -i] [-dPRrvW] file ... unlink file rm "-myfile.txt" rm: illegal option -- m ...
Thanks to @ajp15243 : the answer is : ``` rm ./-myfile.txt ``` or ``` rm -- -myfile.txt ```
21651114
error while running "source .vimrc"
7
2014-02-08 20:00:28
<p>i am having a simple vimrc file when i run "source .vimrc" in ubuntu I am getting the following error.</p> <pre><code>$ source .vimrc bash: .vimrc: line 3: syntax error near unexpected token `"syntax"' bash: .vimrc: line 3: `if has("syntax")' </code></pre> <p>Here is my script file</p> <pre><code>set term=builti...
4,374
2,421,350
2014-02-08 20:13:51
21,651,147
13
2014-02-08 20:03:01
546,861
2014-02-08 20:03:01
https://stackoverflow.com/q/21651114
https://stackoverflow.com/a/21651147
<p>You tried to source your Vim configuration file from bash. Do it from Vim:</p> <pre><code>$ vim :source /path/to/.vimrc </code></pre> <p>If it's located at <code>~/.vimrc</code>, Vim will source that file automatically.</p>
<p>You tried to source your Vim configuration file from bash. Do it from Vim:</p> <pre><code>$ vim :source /path/to/.vimrc </code></pre> <p>If it's located at <code>~/.vimrc</code>, Vim will source that file automatically.</p>
370, 387, 80492
bash, ubuntu-12.04, vim
<h1>error while running "source .vimrc"</h1> <p>i am having a simple vimrc file when i run "source .vimrc" in ubuntu I am getting the following error.</p> <pre><code>$ source .vimrc bash: .vimrc: line 3: syntax error near unexpected token `"syntax"' bash: .vimrc: line 3: `if has("syntax")' </code></pre> <p>Here is m...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,491
bash
# error while running "source .vimrc" i am having a simple vimrc file when i run "source .vimrc" in ubuntu I am getting the following error. ``` $ source .vimrc bash: .vimrc: line 3: syntax error near unexpected token `"syntax"' bash: .vimrc: line 3: `if has("syntax")' ``` Here is my script file ``` set term=built...
You tried to source your Vim configuration file from bash. Do it from Vim: ``` $ vim :source /path/to/.vimrc ``` If it's located at `~/.vimrc`, Vim will source that file automatically.
21249419
How do I programatically detect if my laptop is plugged in or not? (osx)
7
2014-01-21 04:50:06
<p>Exactly as the title says -- I'm looking for a way, in OSX, to tell me if my laptop is currently plugged in so that I can start/pause CPU intensive tasks as necessary.</p> <p>Better yet, a way to get notifications whenever there is a change to the plugged in state.</p>
3,140
null
2014-01-21 05:49:49
21,249,561
13
2014-01-21 05:02:41
2,235,132
2014-01-21 05:02:41
https://stackoverflow.com/q/21249419
https://stackoverflow.com/a/21249561
<p>You could use <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pmset.1.html" rel="noreferrer"><code>pmset</code></a>:</p> <blockquote> <p><code>-g</code> ps / batt displays status of batteries and UPSs.</p> </blockquote> <p>Saying:</p> <pre><code>pmset -g ps </code><...
<p>You could use <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pmset.1.html" rel="noreferrer"><code>pmset</code></a>:</p> <blockquote> <p><code>-g</code> ps / batt displays status of batteries and UPSs.</p> </blockquote> <p>Saying:</p> <pre><code>pmset -g ps </code><...
369, 390
macos, shell
<h1>How do I programatically detect if my laptop is plugged in or not? (osx)</h1> <p>Exactly as the title says -- I'm looking for a way, in OSX, to tell me if my laptop is currently plugged in so that I can start/pause CPU intensive tasks as necessary.</p> <p>Better yet, a way to get notifications whenever there is a ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,492
bash
# How do I programatically detect if my laptop is plugged in or not? (osx) Exactly as the title says -- I'm looking for a way, in OSX, to tell me if my laptop is currently plugged in so that I can start/pause CPU intensive tasks as necessary. Better yet, a way to get notifications whenever there is a change to the pl...
You could use [`pmset`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pmset.1.html): > `-g` ps / batt displays status of batteries and UPSs. Saying: ``` pmset -g ps ``` would tell you if the laptop is running on AC power or using battery power. To translate into a condition, ...
20335659
Powershell Start-job synchronous output
7
2013-12-02 18:52:24
<p>I have a powershell script that starts a job</p> <pre><code>start-job -scriptblock { while($true) { echo "Running" Start-Sleep 2 } } </code></pre> <p>and then it continues executing the rest of the script.</p> <p>That job, is kind of a monitoring one for the PID of that process.</p> <p>I would like ...
4,005
1,728,402
2014-07-18 21:27:42
20,337,008
13
2013-12-02 20:16:27
897,326
2013-12-02 20:22:17
https://stackoverflow.com/q/20335659
https://stackoverflow.com/a/20337008
<p>Yes, you can use events:</p> <pre><code>$job = Start-Job -ScriptBlock { while($true) { Register-EngineEvent -SourceIdentifier MyNewMessage -Forward Start-Sleep -Seconds 3 $null = New-Event -SourceIdentifier MyNewMessage -MessageData "Pingback from job." } } $event = Register-EngineEvent -SourceIde...
<p>Yes, you can use events:</p> <pre><code>$job = Start-Job -ScriptBlock { while($true) { Register-EngineEvent -SourceIdentifier MyNewMessage -Forward Start-Sleep -Seconds 3 $null = New-Event -SourceIdentifier MyNewMessage -MessageData "Pingback from job." } } $event = Register-EngineEvent -SourceIde...
526, 531, 43392
powershell, scripting, start-job
<h1>Powershell Start-job synchronous output</h1> <p>I have a powershell script that starts a job</p> <pre><code>start-job -scriptblock { while($true) { echo "Running" Start-Sleep 2 } } </code></pre> <p>and then it continues executing the rest of the script.</p> <p>That job, is kind of a monitoring one f...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,493
bash
# Powershell Start-job synchronous output I have a powershell script that starts a job ``` start-job -scriptblock { while($true) { echo "Running" Start-Sleep 2 } } ``` and then it continues executing the rest of the script. That job, is kind of a monitoring one for the PID of that process. I would lik...
Yes, you can use events: ``` $job = Start-Job -ScriptBlock { while($true) { Register-EngineEvent -SourceIdentifier MyNewMessage -Forward Start-Sleep -Seconds 3 $null = New-Event -SourceIdentifier MyNewMessage -MessageData "Pingback from job." } } $event = Register-EngineEvent -SourceIdentifier MyNewM...
19065522
Shebang executable not found because of UTF-8 BOM (Byte Order Mark)
7
2013-09-28 09:42:10
<p>For some reason the shebang in one of my scripts does not work:</p> <pre><code>#!/usr/bin/env python # -*- coding: utf-8 -*- print "Hello World" </code></pre> <p>When I execute this file, I get an error</p> <pre><code> % ./test.py ./test.py: 1: #!/usr/bin/env: not found </code></pre> <p>There is no problem with ...
7,972
479,851
2015-07-14 21:02:36
19,065,575
13
2013-09-28 09:47:55
510,937
2013-09-28 09:50:08
https://stackoverflow.com/q/19065522
https://stackoverflow.com/a/19065575
<p>This is due to how Unix and Linux handle the shebang. <a href="http://en.wikipedia.org/wiki/Shebang_%28Unix%29" rel="noreferrer"><code>#!</code></a> must be the <em>first two bytes</em> in the file. If you have a BOM then this isn't true anymore hence the error.</p> <p>Note that putting a BOM is completely useless ...
<p>This is due to how Unix and Linux handle the shebang. <a href="http://en.wikipedia.org/wiki/Shebang_%28Unix%29" rel="noreferrer"><code>#!</code></a> must be the <em>first two bytes</em> in the file. If you have a BOM then this isn't true anymore hence the error.</p> <p>Note that putting a BOM is completely useless ...
16, 387
bash, python
<h1>Shebang executable not found because of UTF-8 BOM (Byte Order Mark)</h1> <p>For some reason the shebang in one of my scripts does not work:</p> <pre><code>#!/usr/bin/env python # -*- coding: utf-8 -*- print "Hello World" </code></pre> <p>When I execute this file, I get an error</p> <pre><code> % ./test.py ./test...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,495
bash
# Shebang executable not found because of UTF-8 BOM (Byte Order Mark) For some reason the shebang in one of my scripts does not work: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- print "Hello World" ``` When I execute this file, I get an error ``` % ./test.py ./test.py: 1: #!/usr/bin/env: not found ``` There...
This is due to how Unix and Linux handle the shebang. [`#!`](http://en.wikipedia.org/wiki/Shebang_%28Unix%29) must be the *first two bytes* in the file. If you have a BOM then this isn't true anymore hence the error. Note that putting a BOM is completely useless from the point of view of the python interpreter, since ...
18638087
Differences between Invoke-Expression and Invoke-Expression -Command
7
2013-09-05 13:46:22
<p>Can someone explain the differences between <code>Invoke-Expression $test</code> and <code>Invoke-Expression -Command $test</code>?</p> <p>variable test is:</p> <pre><code> $test = "notepad.exe myfile.txt" </code></pre>
23,561
1,157,530
2021-01-21 01:30:59
18,638,275
13
2013-09-05 13:54:11
2,215,029
2013-09-05 13:54:11
https://stackoverflow.com/q/18638087
https://stackoverflow.com/a/18638275
<p>Both <code>Invoke-Expression $test</code> and <code>Invoke-Expression -Command $test</code> are the same. Both will put <code>$test</code> into the 'command' parameter that is at position 1. The <code>-Command</code> is and optional parameter name that you can put in. </p> <pre><code>SYNTAX Invoke-Expression [-...
<p>Both <code>Invoke-Expression $test</code> and <code>Invoke-Expression -Command $test</code> are the same. Both will put <code>$test</code> into the 'command' parameter that is at position 1. The <code>-Command</code> is and optional parameter name that you can put in. </p> <pre><code>SYNTAX Invoke-Expression [-...
526, 24067
powershell, powershell-2.0
<h1>Differences between Invoke-Expression and Invoke-Expression -Command</h1> <p>Can someone explain the differences between <code>Invoke-Expression $test</code> and <code>Invoke-Expression -Command $test</code>?</p> <p>variable test is:</p> <pre><code> $test = "notepad.exe myfile.txt" </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,496
bash
# Differences between Invoke-Expression and Invoke-Expression -Command Can someone explain the differences between `Invoke-Expression $test` and `Invoke-Expression -Command $test`? variable test is: ``` $test = "notepad.exe myfile.txt" ```
Both `Invoke-Expression $test` and `Invoke-Expression -Command $test` are the same. Both will put `$test` into the 'command' parameter that is at position 1. The `-Command` is and optional parameter name that you can put in. ``` SYNTAX Invoke-Expression [-Command] <string> [<CommonParameters>] ```
18087964
sh screen - Wait for screen to terminate
7
2013-08-06 18:37:28
<p>I'm writing on a little script that does send a command to a running screen session. This command stops the screen but not instantly. I need to wait for it to finish in order to continue with the rest of the script.</p> <p>This is how I stop the screen:</p> <pre><code>screen -S $SCREEN_NAME -p 0 -X stuff "`printf ...
7,561
1,996,022
2019-09-13 19:17:43
18,137,087
13
2013-08-08 22:14:12
1,996,022
2013-08-08 22:14:12
https://stackoverflow.com/q/18087964
https://stackoverflow.com/a/18137087
<p>I found an solution:</p> <p>You just simply check if the screen is still running and wait (<code>sleep</code>) for one second.</p> <p>Like this:</p> <pre><code>while screen -list | grep -q $SCREEN_NAME do sleep 1 done </code></pre>
<p>I found an solution:</p> <p>You just simply check if the screen is still running and wait (<code>sleep</code>) for one second.</p> <p>Like this:</p> <pre><code>while screen -list | grep -q $SCREEN_NAME do sleep 1 done </code></pre>
390, 5024, 13691, 21289
gnu-screen, shell, terminate, wait
<h1>sh screen - Wait for screen to terminate</h1> <p>I'm writing on a little script that does send a command to a running screen session. This command stops the screen but not instantly. I need to wait for it to finish in order to continue with the rest of the script.</p> <p>This is how I stop the screen:</p> <pre><c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,497
bash
# sh screen - Wait for screen to terminate I'm writing on a little script that does send a command to a running screen session. This command stops the screen but not instantly. I need to wait for it to finish in order to continue with the rest of the script. This is how I stop the screen: ``` screen -S $SCREEN_NAME ...
I found an solution: You just simply check if the screen is still running and wait (`sleep`) for one second. Like this: ``` while screen -list | grep -q $SCREEN_NAME do sleep 1 done ```
17588678
TFS commands in PowerShell script
7
2013-07-11 08:32:28
<p>I have a Powershell script written in the version 1.0. In this existing old script I need the facility to get the latest code of a project from TFS. I have TFS client on the machine and that lets me use the TFS command line. I have created the TFS command line comments to get the latest from TFS. These commands run ...
23,803
2,193,894
2016-06-03 13:15:53
17,589,221
13
2013-07-11 09:00:01
26,396
2013-07-11 11:55:11
https://stackoverflow.com/q/17588678
https://stackoverflow.com/a/17589221
<p>One option is to run the <a href="http://msdn.microsoft.com/en-us/library/z51z7zy0%28v=vs.100%29.aspx">TF.exe</a> program with the necessary arguments from within your PowerShell script, as you would with any other executable:</p> <pre><code>PS&gt; &amp; "$env:ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\T...
<p>One option is to run the <a href="http://msdn.microsoft.com/en-us/library/z51z7zy0%28v=vs.100%29.aspx">TF.exe</a> program with the necessary arguments from within your PowerShell script, as you would with any other executable:</p> <pre><code>PS&gt; &amp; "$env:ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\T...
526, 733
powershell, tfs
<h1>TFS commands in PowerShell script</h1> <p>I have a Powershell script written in the version 1.0. In this existing old script I need the facility to get the latest code of a project from TFS. I have TFS client on the machine and that lets me use the TFS command line. I have created the TFS command line comments to g...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,498
bash
# TFS commands in PowerShell script I have a Powershell script written in the version 1.0. In this existing old script I need the facility to get the latest code of a project from TFS. I have TFS client on the machine and that lets me use the TFS command line. I have created the TFS command line comments to get the la...
One option is to run the [TF.exe](http://msdn.microsoft.com/en-us/library/z51z7zy0%28v=vs.100%29.aspx) program with the necessary arguments from within your PowerShell script, as you would with any other executable: ``` PS> & "$env:ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" @("workspace", "/new", "W...
17565829
bash: kill $$ not work?
7
2013-07-10 08:30:16
<p>The command <code>kill $$</code> should kill current bash, but it seems that it doesn't work:</p> <pre><code>$ ps -p $$ PID TTY TIME CMD 18179 pts/4 00:00:00 bash $ kill $$ $ ps -p $$ PID TTY TIME CMD 18179 pts/4 00:00:00 bash </code></pre> <p>Why?</p>
6,170
1,253,826
2013-07-10 08:49:25
17,566,194
13
2013-07-10 08:48:26
2,235,132
2013-07-10 08:48:26
https://stackoverflow.com/q/17565829
https://stackoverflow.com/a/17566194
<p>I'm not sure why one would like to <code>kill</code> the current shell. Nevertheless...</p> <p><code>kill PID</code> would send <code>SIGTERM</code> when no signal is specified. <code>bash</code> ignores <code>SIGTERM</code> and <code>SIGQUIT</code> in the absence of any traps.</p> <p>You'll achieve the <em>desi...
<p>I'm not sure why one would like to <code>kill</code> the current shell. Nevertheless...</p> <p><code>kill PID</code> would send <code>SIGTERM</code> when no signal is specified. <code>bash</code> ignores <code>SIGTERM</code> and <code>SIGQUIT</code> in the absence of any traps.</p> <p>You'll achieve the <em>desi...
58, 387, 5779
bash, kill, linux
<h1>bash: kill $$ not work?</h1> <p>The command <code>kill $$</code> should kill current bash, but it seems that it doesn't work:</p> <pre><code>$ ps -p $$ PID TTY TIME CMD 18179 pts/4 00:00:00 bash $ kill $$ $ ps -p $$ PID TTY TIME CMD 18179 pts/4 00:00:00 bash </code></pre> <p>Why?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,499
bash
# bash: kill $$ not work? The command `kill $$` should kill current bash, but it seems that it doesn't work: ``` $ ps -p $$ PID TTY TIME CMD 18179 pts/4 00:00:00 bash $ kill $$ $ ps -p $$ PID TTY TIME CMD 18179 pts/4 00:00:00 bash ``` Why?
I'm not sure why one would like to `kill` the current shell. Nevertheless... `kill PID` would send `SIGTERM` when no signal is specified. `bash` ignores `SIGTERM` and `SIGQUIT` in the absence of any traps. You'll achieve the *desired* effect if you were to say ``` kill -9 $$ ``` or ``` kill -SIGKILL $$ ``` Quotin...
17487514
in Linux "which source" returns nothing?
7
2013-07-05 11:11:01
<p>I want to <code>source</code> some shell scripts in <code>c</code> using <code>exec()</code>.</p> <p>What is <code>source</code> ? is that a <code>binary executable</code> or a <code>shell script</code> ? where can i find that in linux file system ?</p> <p>I ran</p> <pre><code>charan@PC-113:~$ which source char...
4,483
1,619,597
2013-07-08 08:14:42
17,487,554
13
2013-07-05 11:12:33
1,983,854
2013-07-08 08:14:42
https://stackoverflow.com/q/17487514
https://stackoverflow.com/a/17487554
<p>It is a builtin shell command, like <code>cd</code>, <code>exit</code>, <code>pwd</code>...:</p> <pre><code>$ enable -p | grep source enable source </code></pre> <p>Note that <code>enable -p</code> shows all the builtins. More info in <a href="http://ss64.com/bash/enable.html" rel="noreferrer">enable Man page</a>....
<p>It is a builtin shell command, like <code>cd</code>, <code>exit</code>, <code>pwd</code>...:</p> <pre><code>$ enable -p | grep source enable source </code></pre> <p>Note that <code>enable -p</code> shows all the builtins. More info in <a href="http://ss64.com/bash/enable.html" rel="noreferrer">enable Man page</a>....
8, 58, 390, 9661
c, linux, shell, system-calls
<h1>in Linux "which source" returns nothing?</h1> <p>I want to <code>source</code> some shell scripts in <code>c</code> using <code>exec()</code>.</p> <p>What is <code>source</code> ? is that a <code>binary executable</code> or a <code>shell script</code> ? where can i find that in linux file system ?</p> <p>I ran</p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,500
bash
# in Linux "which source" returns nothing? I want to `source` some shell scripts in `c` using `exec()`. What is `source` ? is that a `binary executable` or a `shell script` ? where can i find that in linux file system ? I ran ``` charan@PC-113:~$ which source charan@PC-113:~$ ```
It is a builtin shell command, like `cd`, `exit`, `pwd`...: ``` $ enable -p | grep source enable source ``` Note that `enable -p` shows all the builtins. More info in [enable Man page](http://ss64.com/bash/enable.html). ### Update Just saw a pretty interesting thread in SuperUser: [What does source do?](https://sup...
14841946
Trouble when running autogen.sh
7
2013-02-12 21:14:00
<p>I have downloaded R tree from <a href="http://libspatialindex.github.com/" rel="noreferrer">http://libspatialindex.github.com/</a></p> <p>Since on running ./autogen.sh I was getting file/folder not found, therefore I downloaded the file autogen.sh from the github repository given below:</p> <p><a href="https://raw...
17,104
1,778,824
2022-03-29 14:06:11
14,842,032
13
2013-02-12 21:19:05
1,899,640
2013-02-12 21:19:05
https://stackoverflow.com/q/14841946
https://stackoverflow.com/a/14842032
<p>Install <code>libtool</code> from your package manager. </p>
<p>Install <code>libtool</code> from your package manager. </p>
58, 387, 549
bash, linux, ubuntu
<h1>Trouble when running autogen.sh</h1> <p>I have downloaded R tree from <a href="http://libspatialindex.github.com/" rel="noreferrer">http://libspatialindex.github.com/</a></p> <p>Since on running ./autogen.sh I was getting file/folder not found, therefore I downloaded the file autogen.sh from the github repository ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,501
bash
# Trouble when running autogen.sh I have downloaded R tree from <http://libspatialindex.github.com/> Since on running ./autogen.sh I was getting file/folder not found, therefore I downloaded the file autogen.sh from the github repository given below: <https://raw.github.com/libspatialindex/libspatialindex/9a5a2f4d83...
Install `libtool` from your package manager.
14116275
grep for string in all files in directories with certain names
7
2013-01-02 02:37:22
<p>I have csv files in directories with this structure:</p> <pre><code>20090120/ 20090121/ 20090122/ etc... </code></pre> <p>I want to grep for a certain string in all of the csv files in these directories, but only for January 2009, e.g. 200901*/*.csv</p> <p>Is there a bash command line argument that can do this?</...
19,300
788,171
2017-07-26 21:11:08
14,116,290
13
2013-01-02 02:39:37
1,574,959
2013-01-02 02:39:37
https://stackoverflow.com/q/14116275
https://stackoverflow.com/a/14116290
<p>Yes. <code>grep "a certain string" 200901*/*.csv</code>.</p>
<p>Yes. <code>grep "a certain string" 200901*/*.csv</code>.</p>
218, 387, 1271, 10193
bash, directory, find, grep
<h1>grep for string in all files in directories with certain names</h1> <p>I have csv files in directories with this structure:</p> <pre><code>20090120/ 20090121/ 20090122/ etc... </code></pre> <p>I want to grep for a certain string in all of the csv files in these directories, but only for January 2009, e.g. 200901*...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,502
bash
# grep for string in all files in directories with certain names I have csv files in directories with this structure: ``` 20090120/ 20090121/ 20090122/ etc... ``` I want to grep for a certain string in all of the csv files in these directories, but only for January 2009, e.g. 200901*/*.csv Is there a bash command l...
Yes. `grep "a certain string" 200901*/*.csv`.
13950044
How to execute a .Bat with mutliple Parameters from Powershell scripts
7
2012-12-19 10:16:39
<p>how do I execue a .bat from a powershell script.</p> <p>I want to do something like:</p> <pre><code>foreach($item in $list){ param1= $item.Name param2= $item.path C:\Filesystem_Batches\test.bat param1 param2 } </code></pre> <p>Thank you</p>
32,553
1,768,339
2019-04-07 01:54:41
13,950,096
13
2012-12-19 10:19:10
381,149
2012-12-19 10:19:10
https://stackoverflow.com/q/13950044
https://stackoverflow.com/a/13950096
<p>You can call </p> <pre><code>cmd.exe /C "test.bat param1 param2" </code></pre> <p>In powershell V3 there is a new espace string --% which allow to send "weird" parameters to your exes. exemple :</p> <pre><code>PS&gt; echoargs.exe --% %USERNAME%,this=$something{weird} Arg 0 is &lt;jason,this=$something{weird}&gt...
<p>You can call </p> <pre><code>cmd.exe /C "test.bat param1 param2" </code></pre> <p>In powershell V3 there is a new espace string --% which allow to send "weird" parameters to your exes. exemple :</p> <pre><code>PS&gt; echoargs.exe --% %USERNAME%,this=$something{weird} Arg 0 is &lt;jason,this=$something{weird}&gt...
360, 526, 7002
batch-file, parameters, powershell
<h1>How to execute a .Bat with mutliple Parameters from Powershell scripts</h1> <p>how do I execue a .bat from a powershell script.</p> <p>I want to do something like:</p> <pre><code>foreach($item in $list){ param1= $item.Name param2= $item.path C:\Filesystem_Batches\test.bat param1 param2 } </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,503
bash
# How to execute a .Bat with mutliple Parameters from Powershell scripts how do I execue a .bat from a powershell script. I want to do something like: ``` foreach($item in $list){ param1= $item.Name param2= $item.path C:\Filesystem_Batches\test.bat param1 param2 } ``` Thank you
You can call ``` cmd.exe /C "test.bat param1 param2" ``` In powershell V3 there is a new espace string --% which allow to send "weird" parameters to your exes. exemple : ``` PS> echoargs.exe --% %USERNAME%,this=$something{weird} Arg 0 is <jason,this=$something{weird}> ```
13630559
Adding up numbers in PowerShell
7
2012-11-29 16:45:07
<p>I am trying to add up two numbers in PowerShell. I have the input the user gives stored in <code>$Value1</code> and <code>$Value2</code>. However I can't find any way to actually add these numbers up. I tried using the <code>Measure-Object</code> cmdlet but I can't seem to get it to work.</p> <p>How does one add up...
79,064
null
2018-11-13 09:51:17
13,630,632
13
2012-11-29 16:48:51
69,590
2012-11-29 17:26:00
https://stackoverflow.com/q/13630559
https://stackoverflow.com/a/13630632
<pre><code>PS H:\&gt; $value1 = 10 PS H:\&gt; $value2 = 10 PS H:\&gt; $value1 + $value2 20 </code></pre> <p>If your numbers are stored as strings then you'll need to cast them to integers like this:</p> <pre><code>PS H:\&gt; $value1 = "10" PS H:\&gt; $value2 = "20" PS H:\&gt; [int]$value1 + [int]$value2 30 </code></p...
<pre><code>PS H:\&gt; $value1 = 10 PS H:\&gt; $value2 = 10 PS H:\&gt; $value1 + $value2 20 </code></pre> <p>If your numbers are stored as strings then you'll need to cast them to integers like this:</p> <pre><code>PS H:\&gt; $value1 = "10" PS H:\&gt; $value2 = "20" PS H:\&gt; [int]$value1 + [int]$value2 30 </code></p...
390, 526
powershell, shell
<h1>Adding up numbers in PowerShell</h1> <p>I am trying to add up two numbers in PowerShell. I have the input the user gives stored in <code>$Value1</code> and <code>$Value2</code>. However I can't find any way to actually add these numbers up. I tried using the <code>Measure-Object</code> cmdlet but I can't seem to ge...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,504
bash
# Adding up numbers in PowerShell I am trying to add up two numbers in PowerShell. I have the input the user gives stored in `$Value1` and `$Value2`. However I can't find any way to actually add these numbers up. I tried using the `Measure-Object` cmdlet but I can't seem to get it to work. How does one add up/substra...
``` PS H:\> $value1 = 10 PS H:\> $value2 = 10 PS H:\> $value1 + $value2 20 ``` If your numbers are stored as strings then you'll need to cast them to integers like this: ``` PS H:\> $value1 = "10" PS H:\> $value2 = "20" PS H:\> [int]$value1 + [int]$value2 30 ```
13555834
how to use vim to open every .txt file under a directory (with Bash)
7
2012-11-25 21:46:57
<p>I am trying the following to use a <code>vim</code> to open every <code>txt</code> file under current directory. </p> <pre><code>find . -name "*.txt" -print | while read aline; do read -p "start spellchecking fine: $aline" sth vim $aline done </code></pre> <p>Running it in <code>bash</code> complains with </p>...
1,881
486,720
2014-04-27 10:53:09
13,555,918
13
2012-11-25 21:55:05
140,750
2012-11-25 22:00:09
https://stackoverflow.com/q/13555834
https://stackoverflow.com/a/13555918
<p>Try:</p> <pre><code>vim $( find . -name "*.txt" ) </code></pre> <p>To fix your solution, you can (probably) do:</p> <pre><code>find . -name "*.txt" -print | while read aline; do read -p "start spellchecking fine: $aline" sth &lt; /dev/tty vim $aline &lt; /dev/tty done </code></pre> <p>The problem is ...
<p>Try:</p> <pre><code>vim $( find . -name "*.txt" ) </code></pre> <p>To fix your solution, you can (probably) do:</p> <pre><code>find . -name "*.txt" -print | while read aline; do read -p "start spellchecking fine: $aline" sth &lt; /dev/tty vim $aline &lt; /dev/tty done </code></pre> <p>The problem is ...
370, 387, 17310
bash, vim, while-loop
<h1>how to use vim to open every .txt file under a directory (with Bash)</h1> <p>I am trying the following to use a <code>vim</code> to open every <code>txt</code> file under current directory. </p> <pre><code>find . -name "*.txt" -print | while read aline; do read -p "start spellchecking fine: $aline" sth vim $al...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,505
bash
# how to use vim to open every .txt file under a directory (with Bash) I am trying the following to use a `vim` to open every `txt` file under current directory. ``` find . -name "*.txt" -print | while read aline; do read -p "start spellchecking fine: $aline" sth vim $aline done ``` Running it in `bash` complain...
Try: ``` vim $( find . -name "*.txt" ) ``` To fix your solution, you can (probably) do: ``` find . -name "*.txt" -print | while read aline; do read -p "start spellchecking fine: $aline" sth < /dev/tty vim $aline < /dev/tty done ``` The problem is that the entire while loop is taking its input from find,...
13059845
C style arithmetic with floating point values in Bash
7
2012-10-25 00:21:37
<p>How can I have the right result from this bash script?</p> <pre><code>#!/bin/bash echo $(( 1/2 )) </code></pre> <p>I get <code>0</code> as result! So I tried to use these but without success:</p> <pre><code>$ echo $(( 1/2.0 )) bash: 1/2.0 : syntax error: invalid arithmetic operator (error token is ".0 ") $ echo $...
4,639
954,485
2018-11-13 18:07:56
13,059,861
13
2012-10-25 00:23:27
465,183
2013-10-17 20:24:52
https://stackoverflow.com/q/13059845
https://stackoverflow.com/a/13059861
<p><a href="/questions/tagged/bash" class="post-tag" title="show questions tagged 'bash'" rel="tag">bash</a> is not the right tool alone to use <em>floats</em>, you should use <a href="/questions/tagged/bc" class="post-tag" title="show questions tagged 'bc'" rel="tag">bc</a> with it :</p> <pre><code>bc &lt;&lt;&lt; "s...
<p><a href="/questions/tagged/bash" class="post-tag" title="show questions tagged 'bash'" rel="tag">bash</a> is not the right tool alone to use <em>floats</em>, you should use <a href="/questions/tagged/bc" class="post-tag" title="show questions tagged 'bc'" rel="tag">bc</a> with it :</p> <pre><code>bc &lt;&lt;&lt; "s...
305, 387, 5481
arithmetic-expressions, bash, floating-point
<h1>C style arithmetic with floating point values in Bash</h1> <p>How can I have the right result from this bash script?</p> <pre><code>#!/bin/bash echo $(( 1/2 )) </code></pre> <p>I get <code>0</code> as result! So I tried to use these but without success:</p> <pre><code>$ echo $(( 1/2.0 )) bash: 1/2.0 : syntax err...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,506
bash
# C style arithmetic with floating point values in Bash How can I have the right result from this bash script? ``` #!/bin/bash echo $(( 1/2 )) ``` I get `0` as result! So I tried to use these but without success: ``` $ echo $(( 1/2.0 )) bash: 1/2.0 : syntax error: invalid arithmetic operator (error token is ".0 ") ...
[bash](/questions/tagged/bash "show questions tagged 'bash'") is not the right tool alone to use *floats*, you should use [bc](/questions/tagged/bc "show questions tagged 'bc'") with it : ``` bc <<< "scale=2; 1/2" .50 ``` If you need to store the result in a variable : ``` res=$(bc <<< "scale=2; 1/2") echo $res ```
12409619
how can i make awk process the BEGIN block for each file it parses?
7
2012-09-13 15:21:20
<p>i have an <code>awk</code> script that i'm running against a pair of files. i'm calling it like this:</p> <p><code>awk -f script.awk file1 file2</code></p> <p>script.awk looks something like this:</p> <pre><code>BEGIN {FS=":"} { if( NR == 1 ) { var=$2 FS=" " } else print var,"|",$0 } </co...
2,647
1,599,114
2018-10-08 15:09:41
12,410,003
13
2012-09-13 15:41:22
1,331,399
2018-10-08 08:14:29
https://stackoverflow.com/q/12409619
https://stackoverflow.com/a/12410003
<p>If you're using <code>gawk</code> version 4 or later there's the <code>BEGINFILE</code> block. From the manual:</p> <blockquote> <p>BEGINFILE and ENDFILE are additional special patterns whose bodies are executed before reading the first record of each command line input file and after reading the last rec...
<p>If you're using <code>gawk</code> version 4 or later there's the <code>BEGINFILE</code> block. From the manual:</p> <blockquote> <p>BEGINFILE and ENDFILE are additional special patterns whose bodies are executed before reading the first record of each command line input file and after reading the last rec...
387, 990, 1731
awk, bash, cygwin
<h1>how can i make awk process the BEGIN block for each file it parses?</h1> <p>i have an <code>awk</code> script that i'm running against a pair of files. i'm calling it like this:</p> <p><code>awk -f script.awk file1 file2</code></p> <p>script.awk looks something like this:</p> <pre><code>BEGIN {FS=":"} { if( NR ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,507
bash
# how can i make awk process the BEGIN block for each file it parses? i have an `awk` script that i'm running against a pair of files. i'm calling it like this: `awk -f script.awk file1 file2` script.awk looks something like this: ``` BEGIN {FS=":"} { if( NR == 1 ) { var=$2 FS=" " } else pri...
If you're using `gawk` version 4 or later there's the `BEGINFILE` block. From the manual: > BEGINFILE and ENDFILE are additional special patterns whose bodies are executed before reading the first > record of each command line input file and after reading the last record of each file. Inside the BEGINFILE > rule, the ...
12224804
How to set ANT_HOME on Ubuntu Desktop 12.04?
7
2012-09-01 04:05:47
<p>It looks like Ubuntu uses <code>~/.bashrc</code>, <code>~/.bash_profile</code>, <code>~/.pam_profile</code>, <code>/etc/environment</code>, and <code>/etc/profile</code> in very similar ways. I'd like to be able to add a configuration to one of these (which ever is the appropriate one) to set <code>ANT_HOME</code> t...
31,231
892,029
2014-02-26 08:31:41
12,224,878
13
2012-09-01 04:24:39
482,628
2012-09-01 04:24:39
https://stackoverflow.com/q/12224804
https://stackoverflow.com/a/12224878
<p><strong>For global settings, system-wide environment variables</strong></p> <ul> <li>Use <code>/etc/environment</code> </li> <li>don't use <code>/etc/profile</code>, or <code>/etc/bash.bashrc</code></li> </ul> <p>From <a href="https://help.ubuntu.com/community/EnvironmentVariables">this</a> page :</p> <blockquote...
<p><strong>For global settings, system-wide environment variables</strong></p> <ul> <li>Use <code>/etc/environment</code> </li> <li>don't use <code>/etc/profile</code>, or <code>/etc/bash.bashrc</code></li> </ul> <p>From <a href="https://help.ubuntu.com/community/EnvironmentVariables">this</a> page :</p> <blockquote...
17, 142, 387, 549, 9013
ant, bash, environment-variables, java, ubuntu
<h1>How to set ANT_HOME on Ubuntu Desktop 12.04?</h1> <p>It looks like Ubuntu uses <code>~/.bashrc</code>, <code>~/.bash_profile</code>, <code>~/.pam_profile</code>, <code>/etc/environment</code>, and <code>/etc/profile</code> in very similar ways. I'd like to be able to add a configuration to one of these (which ever ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,508
bash
# How to set ANT_HOME on Ubuntu Desktop 12.04? It looks like Ubuntu uses `~/.bashrc`, `~/.bash_profile`, `~/.pam_profile`, `/etc/environment`, and `/etc/profile` in very similar ways. I'd like to be able to add a configuration to one of these (which ever is the appropriate one) to set `ANT_HOME` to be the absolute pat...
**For global settings, system-wide environment variables** - Use `/etc/environment` - don't use `/etc/profile`, or `/etc/bash.bashrc` From [this](https://help.ubuntu.com/community/EnvironmentVariables) page : > `/etc/environment` [...] is > specifically meant for system-wide > environment variable settings. It is > ...
11523809
How can I extract a tag's attribute value from an HTML file?
7
2012-07-17 13:43:24
<p>I know, don't parse using curl, grep and sed. But I am looking for an easy approach, not a very safe one.</p> <p>So I get an HTML file with curl, from which I need a value of a certain attribute from a tag. I use grep to get me the line where it says <code>token</code>. This only occurs once. This gives me a whole ...
20,054
338,476
2015-01-22 02:41:57
11,523,965
13
2012-07-17 13:51:56
390,913
2012-07-17 13:51:56
https://stackoverflow.com/q/11523809
https://stackoverflow.com/a/11523965
<p>There's no need to grep:</p> <pre><code>sed -n '/token/s/.*name="ltoken"\s\+value="\([^"]\+\).*/\1/p' input_file </code></pre>
<p>There's no need to grep:</p> <pre><code>sed -n '/token/s/.*name="ltoken"\s\+value="\([^"]\+\).*/\1/p' input_file </code></pre>
18, 387
bash, regex
<h1>How can I extract a tag's attribute value from an HTML file?</h1> <p>I know, don't parse using curl, grep and sed. But I am looking for an easy approach, not a very safe one.</p> <p>So I get an HTML file with curl, from which I need a value of a certain attribute from a tag. I use grep to get me the line where it ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,509
bash
# How can I extract a tag's attribute value from an HTML file? I know, don't parse using curl, grep and sed. But I am looking for an easy approach, not a very safe one. So I get an HTML file with curl, from which I need a value of a certain attribute from a tag. I use grep to get me the line where it says `token`. Th...
There's no need to grep: ``` sed -n '/token/s/.*name="ltoken"\s\+value="\([^"]\+\).*/\1/p' input_file ```
11235362
Which Windows Shell command will print a file content on the standard output (like cat in Linux)?
7
2012-06-27 21:57:04
<p>Which Windows Shell command will print a file content on the standard output (like cat in Linux) ?</p> <p>With Google, Stackoverflow, etc, I just could not find a solution, but I am sure, there is an easy one.</p>
10,216
1,406,176
2017-02-24 02:36:05
11,235,376
13
2012-06-27 21:58:22
38,206
2012-06-27 21:58:22
https://stackoverflow.com/q/11235362
https://stackoverflow.com/a/11235376
<p>The command is: <code>type &lt;filename&gt;</code></p> <p>However, if you want to Unix-fy your Windows shell there are <a href="http://unxutils.sourceforge.net/">Win32 ports</a> of most of the command Unix style commands. </p>
<p>The command is: <code>type &lt;filename&gt;</code></p> <p>However, if you want to Unix-fy your Windows shell there are <a href="http://unxutils.sourceforge.net/">Win32 ports</a> of most of the command Unix style commands. </p>
64, 390, 22820
cat, shell, windows
<h1>Which Windows Shell command will print a file content on the standard output (like cat in Linux)?</h1> <p>Which Windows Shell command will print a file content on the standard output (like cat in Linux) ?</p> <p>With Google, Stackoverflow, etc, I just could not find a solution, but I am sure, there is an easy one....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,510
bash
# Which Windows Shell command will print a file content on the standard output (like cat in Linux)? Which Windows Shell command will print a file content on the standard output (like cat in Linux) ? With Google, Stackoverflow, etc, I just could not find a solution, but I am sure, there is an easy one.
The command is: `type <filename>` However, if you want to Unix-fy your Windows shell there are [Win32 ports](http://unxutils.sourceforge.net/) of most of the command Unix style commands.
11132763
Linux - get text from second tab
7
2012-06-21 06:35:10
<p>Suppose that we have file like this:</p> <blockquote> <p>sometext11 sometext12 sometext13 sometext21 sometext22 sometext23</p> </blockquote> <p>Texts are separated by tabs and we know sometext from column 1 but want to get text from column 2. I know I can get line by:</p> <pre><code>grep 'sometext...
25,407
932,965
2014-05-20 06:54:40
11,135,625
13
2012-06-21 09:49:34
297,323
2012-06-21 09:49:34
https://stackoverflow.com/q/11132763
https://stackoverflow.com/a/11135625
<p>awk:</p> <pre><code>awk '{print $2}' file.txt </code></pre> <p>cut:</p> <pre><code>cut -f2 file.txt </code></pre> <p>bash:</p> <pre><code>while read -a A; do echo ${A[1]}; done &lt; file.txt </code></pre> <p>perl:</p> <pre><code>perl -lane 'print $F[1]' file.txt </code></pre> <p>If you know the string you ar...
<p>awk:</p> <pre><code>awk '{print $2}' file.txt </code></pre> <p>cut:</p> <pre><code>cut -f2 file.txt </code></pre> <p>bash:</p> <pre><code>while read -a A; do echo ${A[1]}; done &lt; file.txt </code></pre> <p>perl:</p> <pre><code>perl -lane 'print $F[1]' file.txt </code></pre> <p>If you know the string you ar...
58, 387, 1469
bash, linux, text
<h1>Linux - get text from second tab</h1> <p>Suppose that we have file like this:</p> <blockquote> <p>sometext11 sometext12 sometext13 sometext21 sometext22 sometext23</p> </blockquote> <p>Texts are separated by tabs and we know sometext from column 1 but want to get text from column 2. I know I can g...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,511
bash
# Linux - get text from second tab Suppose that we have file like this: > sometext11 sometext12 sometext13 > sometext21 sometext22 sometext23 Texts are separated by tabs and we know sometext from column 1 but want to get text from column 2. I know I can get line by: ``` grep 'sometext11' file.txt ``` How to get te...
awk: ``` awk '{print $2}' file.txt ``` cut: ``` cut -f2 file.txt ``` bash: ``` while read -a A; do echo ${A[1]}; done < file.txt ``` perl: ``` perl -lane 'print $F[1]' file.txt ``` If you know the string you are grepping for, you can use `grep`: ``` grep -o 'sometext12' file.txt ```
10736923
Detect OS from Bash script and notify user
7
2012-05-24 11:49:49
<p>Using bash, I want to find the operating system and notify the user. I tried:</p> <pre><code>OS='uname -s' echo "$OS" if [ "$OS" == 'Linux' ]; then echo "Linux" else echo "Not Linux" fi </code></pre> <p>I just get</p> <pre><code>uname -s Not Linux </code></pre> <p>on the terminal, which is wrong. How d...
13,178
1,173,913
2014-10-22 06:20:08
10,736,950
13
2012-05-24 11:52:01
140,750
2012-05-24 11:52:01
https://stackoverflow.com/q/10736923
https://stackoverflow.com/a/10736950
<p>Rather than single quotes, you probably meant to use backticks:</p> <pre><code>OS=`uname -s` </code></pre> <p>but you really want</p> <pre><code>OS=$(uname -s) </code></pre> <p>Also, rather than an if statment, which will eventually become an if/else series, you might consider using case:</p> <pre><code>case $(...
<p>Rather than single quotes, you probably meant to use backticks:</p> <pre><code>OS=`uname -s` </code></pre> <p>but you really want</p> <pre><code>OS=$(uname -s) </code></pre> <p>Also, rather than an if statment, which will eventually become an if/else series, you might consider using case:</p> <pre><code>case $(...
139, 387, 5163, 13106
bash, string, system, uname
<h1>Detect OS from Bash script and notify user</h1> <p>Using bash, I want to find the operating system and notify the user. I tried:</p> <pre><code>OS='uname -s' echo "$OS" if [ "$OS" == 'Linux' ]; then echo "Linux" else echo "Not Linux" fi </code></pre> <p>I just get</p> <pre><code>uname -s Not Linux </co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,512
bash
# Detect OS from Bash script and notify user Using bash, I want to find the operating system and notify the user. I tried: ``` OS='uname -s' echo "$OS" if [ "$OS" == 'Linux' ]; then echo "Linux" else echo "Not Linux" fi ``` I just get ``` uname -s Not Linux ``` on the terminal, which is wrong. How do I c...
Rather than single quotes, you probably meant to use backticks: ``` OS=`uname -s` ``` but you really want ``` OS=$(uname -s) ``` Also, rather than an if statment, which will eventually become an if/else series, you might consider using case: ``` case $( uname -s ) in Linux) echo Linux;; *) echo other;; esac ``...
10161162
metadata editing in bash linux for multimedia files(not images) in linux
7
2012-04-15 10:20:07
<p>I've searched across stackoverflow, and I've been on google and also duckduckgo and no one seems to have a nice way for me to do this.</p> <p>The only tool that seems to maybe have worked was Exiftool which only has the read ability for ogg files(which is what I'm using at the moment). I'd like some way to do this ...
7,458
327,544
2012-04-15 13:53:14
10,162,208
13
2012-04-15 12:57:29
313,821
2012-04-15 13:53:14
https://stackoverflow.com/q/10161162
https://stackoverflow.com/a/10162208
<p><code>ID3</code> tags are MP3 specific. For Ogg Vorbis comment field specifications, see: <a href="http://www.xiph.org/vorbis/doc/v-comment.html">Field Names</a> </p> <p><code>vorbiscomment</code> (package <em>vorbis-tools</em>) can modify and query <code>ogg</code> tag info.<br> <code>mp3info</code> is one of ...
<p><code>ID3</code> tags are MP3 specific. For Ogg Vorbis comment field specifications, see: <a href="http://www.xiph.org/vorbis/doc/v-comment.html">Field Names</a> </p> <p><code>vorbiscomment</code> (package <em>vorbis-tools</em>) can modify and query <code>ogg</code> tag info.<br> <code>mp3info</code> is one of ...
58, 387, 3703, 3794, 13681
bash, exif, linux, metadata, ogg
<h1>metadata editing in bash linux for multimedia files(not images) in linux</h1> <p>I've searched across stackoverflow, and I've been on google and also duckduckgo and no one seems to have a nice way for me to do this.</p> <p>The only tool that seems to maybe have worked was Exiftool which only has the read ability f...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,513
bash
# metadata editing in bash linux for multimedia files(not images) in linux I've searched across stackoverflow, and I've been on google and also duckduckgo and no one seems to have a nice way for me to do this. The only tool that seems to maybe have worked was Exiftool which only has the read ability for ogg files(whi...
`ID3` tags are MP3 specific. For Ogg Vorbis comment field specifications, see: [Field Names](http://www.xiph.org/vorbis/doc/v-comment.html) `vorbiscomment` (package *vorbis-tools*) can modify and query `ogg` tag info. `mp3info` is one of many tools to work wirh `mp3` tags. --- # .ogg ``` # Clear all info printf '...
9593287
Execute shellcode by casting to function pointer in Visual C++
7
2012-03-06 22:57:41
<p>In gcc this works fine. The code goes something like:</p> <pre><code>unsigned char b[50] = "\xda\xd1 ... \x0"; //some shellcode with terminating \x0 ( (void(*)())b )(); //cast b to function pointer from void to void, then run it </code></pre> <p>But when this is put in Visual C++, it spits out this error message:<...
14,519
1,253,415
2012-03-20 19:31:19
9,593,583
13
2012-03-06 23:29:14
916,657
2012-03-06 23:46:07
https://stackoverflow.com/q/9593287
https://stackoverflow.com/a/9593583
<p>A proper debugger will tell you what's going wrong. I can only guess that your code is causing an access violation because the buffer you want to jump to is not executable.</p> <p>Probably you're on a default-<a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention" rel="noreferrer">DEP</a>-enabled system li...
<p>A proper debugger will tell you what's going wrong. I can only guess that your code is causing an access violation because the buffer you want to jump to is not executable.</p> <p>Probably you're on a default-<a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention" rel="noreferrer">DEP</a>-enabled system li...
10, 2754, 78469
c++, casting, shellcode
<h1>Execute shellcode by casting to function pointer in Visual C++</h1> <p>In gcc this works fine. The code goes something like:</p> <pre><code>unsigned char b[50] = "\xda\xd1 ... \x0"; //some shellcode with terminating \x0 ( (void(*)())b )(); //cast b to function pointer from void to void, then run it </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,514
bash
# Execute shellcode by casting to function pointer in Visual C++ In gcc this works fine. The code goes something like: ``` unsigned char b[50] = "\xda\xd1 ... \x0"; //some shellcode with terminating \x0 ( (void(*)())b )(); //cast b to function pointer from void to void, then run it ``` But when this is put in Visual...
A proper debugger will tell you what's going wrong. I can only guess that your code is causing an access violation because the buffer you want to jump to is not executable. Probably you're on a default-[DEP](http://en.wikipedia.org/wiki/Data_Execution_Prevention)-enabled system like Vista or 7, so you have to make sur...
8949079
Unable to understand [-t 0] inside shell script
7
2012-01-20 23:17:05
<p><a href="https://gist.github.com/318247" rel="nofollow noreferrer">This browser gist</a> by defunkt github user starts with this shell expression</p> <pre><code>if [ -t 0 ]; then ... </code></pre> <p>What is the meaning of this line of code?</p> <p><strong>UPDATE:</strong> could you also explain why i need this chec...
4,095
204,159
2022-12-15 14:53:20
8,949,099
13
2012-01-20 23:20:09
35,092
2019-09-30 16:44:54
https://stackoverflow.com/q/8949079
https://stackoverflow.com/a/8949099
<ul> <li><code>[</code> and <code>]</code> invokes <code>test</code></li> <li><code>-t</code> makes the <code>test</code> test a file descriptor to see if it's a terminal</li> <li><code>0</code> is the file descriptor for STDIN.</li> </ul> <p>So that says</p> <pre class="lang-none prettyprint-override"><code>if STDIN...
<ul> <li><code>[</code> and <code>]</code> invokes <code>test</code></li> <li><code>-t</code> makes the <code>test</code> test a file descriptor to see if it's a terminal</li> <li><code>0</code> is the file descriptor for STDIN.</li> </ul> <p>So that says</p> <pre class="lang-none prettyprint-override"><code>if STDIN...
390
shell
<h1>Unable to understand [-t 0] inside shell script</h1> <p><a href="https://gist.github.com/318247" rel="nofollow noreferrer">This browser gist</a> by defunkt github user starts with this shell expression</p> <pre><code>if [ -t 0 ]; then ... </code></pre> <p>What is the meaning of this line of code?</p> <p><strong>UPD...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,515
bash
# Unable to understand [-t 0] inside shell script [This browser gist](https://gist.github.com/318247) by defunkt github user starts with this shell expression ``` if [ -t 0 ]; then ... ``` What is the meaning of this line of code? **UPDATE:** could you also explain why i need this check before doing anything else? ...
- `[` and `]` invokes `test` - `-t` makes the `test` test a file descriptor to see if it's a terminal - `0` is the file descriptor for STDIN. So that says ``` if STDIN is a terminal then ... ``` ### Motivation I'd have to read the whole script to know for sure, but usually it's because the script wants to do someth...
8563636
Export certificate from IIS using PowerShell
7
2011-12-19 15:37:32
<p>How do I export a self-signed certificate from <a href="http://en.wikipedia.org/wiki/Internet_Information_Services" rel="noreferrer">IIS</a> 7 using PowerShell?</p>
8,793
1,106,196
2015-06-28 16:21:26
8,563,823
13
2011-12-19 15:52:02
978,511
2015-06-28 16:21:26
https://stackoverflow.com/q/8563636
https://stackoverflow.com/a/8563823
<pre><code>dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("c:\$($_.Subject).pfx", ($_.Export('PFX', 'secret')) ) } </code></pre> <p>Source: <em><a href="http://powershell.com/cs/blogs/tips/archive/2009/10/20/exporting-certificate-with-private-key....
<pre><code>dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("c:\$($_.Subject).pfx", ($_.Export('PFX', 'secret')) ) } </code></pre> <p>Source: <em><a href="http://powershell.com/cs/blogs/tips/archive/2009/10/20/exporting-certificate-with-private-key....
215, 526
iis, powershell
<h1>Export certificate from IIS using PowerShell</h1> <p>How do I export a self-signed certificate from <a href="http://en.wikipedia.org/wiki/Internet_Information_Services" rel="noreferrer">IIS</a> 7 using 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,516
bash
# Export certificate from IIS using PowerShell How do I export a self-signed certificate from [IIS](http://en.wikipedia.org/wiki/Internet_Information_Services) 7 using PowerShell?
``` dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("c:\$($_.Subject).pfx", ($_.Export('PFX', 'secret')) ) } ``` Source: *[Exporting Certificate With Private Key](http://powershell.com/cs/blogs/tips/archive/2009/10/20/exporting-certificate-with-pri...
8168676
Does file ".bash_history" always record every command I ever issue?
7
2011-11-17 14:23:51
<p>I'd like to be able to look through my command history (all the way back to the beginning of the user).</p> <p>Is there any guarantee that file <em>.bash_history</em> will continue to be appended to?</p> <p>If there is a limit where the file will start to be truncated (hopefully from the beginning), is there a way t...
13,989
340,947
2021-08-06 17:18:41
8,168,723
13
2011-11-17 14:27:03
1,023,815
2021-08-06 17:18:41
https://stackoverflow.com/q/8168676
https://stackoverflow.com/a/8168723
<p>There are a number of environment variables that control how history works in Bash. Relevant excerpt from bash manpage follows:</p> <pre class="lang-none prettyprint-override"><code>HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values incl...
<p>There are a number of environment variables that control how history works in Bash. Relevant excerpt from bash manpage follows:</p> <pre class="lang-none prettyprint-override"><code>HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values incl...
58, 387
bash, linux
<h1>Does file ".bash_history" always record every command I ever issue?</h1> <p>I'd like to be able to look through my command history (all the way back to the beginning of the user).</p> <p>Is there any guarantee that file <em>.bash_history</em> will continue to be appended to?</p> <p>If there is a limit where the fil...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,517
bash
# Does file ".bash_history" always record every command I ever issue? I'd like to be able to look through my command history (all the way back to the beginning of the user). Is there any guarantee that file *.bash_history* will continue to be appended to? If there is a limit where the file will start to be truncated...
There are a number of environment variables that control how history works in Bash. Relevant excerpt from bash manpage follows: ``` HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with ...
7639186
How to find a pattern and surrounding content in a very large SINGLE line file?
7
2011-10-03 18:38:49
<p>I have a very large file 100Mb+ where all the content is on one line. I wish to find a pattern in that file and a number of characters around that pattern.</p> <p>For example I would like to call a command like the one below but where -A and -B are number of bytes not lines:</p> <pre><code>cat very_large_file | gr...
793
135,124
2011-10-03 20:19:06
7,639,241
13
2011-10-03 18:44:16
15,622
2011-10-03 18:44:16
https://stackoverflow.com/q/7639186
https://stackoverflow.com/a/7639241
<p>You could try the -o option:</p> <pre><code>-o, --only-matching Show only the part of a matching line that matches PATTERN. </code></pre> <p>and use a regular expression to match your pattern and the 3 preceding/following characters i.e.</p> <pre><code>grep -o -P ".{3}pattern.{3}" very_large_file </code></...
<p>You could try the -o option:</p> <pre><code>-o, --only-matching Show only the part of a matching line that matches PATTERN. </code></pre> <p>and use a regular expression to match your pattern and the 3 preceding/following characters i.e.</p> <pre><code>grep -o -P ".{3}pattern.{3}" very_large_file </code></...
387, 1357
bash, parsing
<h1>How to find a pattern and surrounding content in a very large SINGLE line file?</h1> <p>I have a very large file 100Mb+ where all the content is on one line. I wish to find a pattern in that file and a number of characters around that pattern.</p> <p>For example I would like to call a command like the one below bu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,518
bash
# How to find a pattern and surrounding content in a very large SINGLE line file? I have a very large file 100Mb+ where all the content is on one line. I wish to find a pattern in that file and a number of characters around that pattern. For example I would like to call a command like the one below but where -A and -...
You could try the -o option: ``` -o, --only-matching Show only the part of a matching line that matches PATTERN. ``` and use a regular expression to match your pattern and the 3 preceding/following characters i.e. ``` grep -o -P ".{3}pattern.{3}" very_large_file ``` In the example you gave, it would be ``` e...
6922187
How to fix Makefile syntax error when using wildcard on make clean?
7
2011-08-03 05:47:05
<p>I have a simple Makefile that just contains this one target. It looks like this:</p> <pre><code>SHELL:=/bin/bash clean: rm !(*.tex|Makefile|*.pdf) </code></pre> <p>When I run this command in bash it works fine, i.e. it gives no errors and it removes the desired files. However when I run <code>make clean</code...
2,989
451,761
2015-05-10 17:42:29
6,922,447
13
2011-08-03 06:21:15
855,954
2011-08-03 06:21:15
https://stackoverflow.com/q/6922187
https://stackoverflow.com/a/6922447
<p>Change the <code>SHELL</code> line to </p> <pre><code>SHELL:=/bin/bash -O extglob </code></pre> <p>The <code>extglob</code> option is not set by default, so you have to do that yourself.</p>
<p>Change the <code>SHELL</code> line to </p> <pre><code>SHELL:=/bin/bash -O extglob </code></pre> <p>The <code>extglob</code> option is not set by default, so you have to do that yourself.</p>
387, 390, 4301, 5997
bash, makefile, shell, wildcard
<h1>How to fix Makefile syntax error when using wildcard on make clean?</h1> <p>I have a simple Makefile that just contains this one target. It looks like this:</p> <pre><code>SHELL:=/bin/bash clean: rm !(*.tex|Makefile|*.pdf) </code></pre> <p>When I run this command in bash it works fine, i.e. it gives no error...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,519
bash
# How to fix Makefile syntax error when using wildcard on make clean? I have a simple Makefile that just contains this one target. It looks like this: ``` SHELL:=/bin/bash clean: rm !(*.tex|Makefile|*.pdf) ``` When I run this command in bash it works fine, i.e. it gives no errors and it removes the desired file...
Change the `SHELL` line to ``` SHELL:=/bin/bash -O extglob ``` The `extglob` option is not set by default, so you have to do that yourself.
6758860
How to modify a file by using awk?
7
2011-07-20 08:08:56
<pre><code>awk '/&lt;ul&gt;/ {ul++} ul == 6 { getline } 1' /var/www/html/INFOSEC/english/test.html </code></pre> <p>if i run this line of code, the shell will not help me to modify the file, instead, it only output the result in the shell. Can any one help???thx</p>
13,027
1,280,996
2011-07-20 08:14:06
6,758,908
13
2011-07-20 08:14:06
406,323
2011-07-20 08:14:06
https://stackoverflow.com/q/6758860
https://stackoverflow.com/a/6758908
<p>The simplest solution is to just send the output to a file; you might want to copy the file beforehand so you don't have to overwrite the file you're reading (which might otherwise lead to undesired behavior).</p> <pre><code>cp test.html test.html.orig awk 'your awk script here' test.html.orig &gt;test.html # and t...
<p>The simplest solution is to just send the output to a file; you might want to copy the file beforehand so you don't have to overwrite the file you're reading (which might otherwise lead to undesired behavior).</p> <pre><code>cp test.html test.html.orig awk 'your awk script here' test.html.orig &gt;test.html # and t...
387, 990
awk, bash
<h1>How to modify a file by using awk?</h1> <pre><code>awk '/&lt;ul&gt;/ {ul++} ul == 6 { getline } 1' /var/www/html/INFOSEC/english/test.html </code></pre> <p>if i run this line of code, the shell will not help me to modify the file, instead, it only output the result in the shell. Can any one help???thx</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,520
bash
# How to modify a file by using awk? ``` awk '/<ul>/ {ul++} ul == 6 { getline } 1' /var/www/html/INFOSEC/english/test.html ``` if i run this line of code, the shell will not help me to modify the file, instead, it only output the result in the shell. Can any one help???thx
The simplest solution is to just send the output to a file; you might want to copy the file beforehand so you don't have to overwrite the file you're reading (which might otherwise lead to undesired behavior). ``` cp test.html test.html.orig awk 'your awk script here' test.html.orig >test.html # and then optionally re...
6665541
Checking for null string in bash
7
2011-07-12 14:11:11
<p>Is there any difference between the following tests?</p> <pre><code>[[ "$STRING" = "" ]] &amp;&amp; exit 1; [[ "x$STRING" = "x" ]] &amp;&amp; exit 1; [[ -z $STRING ]] &amp;&amp; exit 1; </code></pre>
8,863
211,659
2011-07-12 14:22:23
6,665,583
13
2011-07-12 14:14:27
694,014
2011-07-12 14:14:27
https://stackoverflow.com/q/6665541
https://stackoverflow.com/a/6665583
<p>Nope, they are all the same. But couple of defensive habits to get into.</p> <ul> <li>You should quote the <code>$STRING</code> in the <code>-z</code> one as well</li> <li>If you are running with the -u option (I always do) then you should reference the possibly optional variable as <code>${STRING-}</code> just in ...
<p>Nope, they are all the same. But couple of defensive habits to get into.</p> <ul> <li>You should quote the <code>$STRING</code> in the <code>-z</code> one as well</li> <li>If you are running with the -u option (I always do) then you should reference the possibly optional variable as <code>${STRING-}</code> just in ...
58, 387
bash, linux
<h1>Checking for null string in bash</h1> <p>Is there any difference between the following tests?</p> <pre><code>[[ "$STRING" = "" ]] &amp;&amp; exit 1; [[ "x$STRING" = "x" ]] &amp;&amp; exit 1; [[ -z $STRING ]] &amp;&amp; exit 1; </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,521
bash
# Checking for null string in bash Is there any difference between the following tests? ``` [[ "$STRING" = "" ]] && exit 1; [[ "x$STRING" = "x" ]] && exit 1; [[ -z $STRING ]] && exit 1; ```
Nope, they are all the same. But couple of defensive habits to get into. - You should quote the `$STRING` in the `-z` one as well - If you are running with the -u option (I always do) then you should reference the possibly optional variable as `${STRING-}` just in case its not set at all
6471090
Join Arguments - Escape Spaces
7
2011-06-24 16:50:12
<p>Is there any easy way to "join" the arguments passed to a script? I'd like something similar to <code>$@</code>, but that passes the arguments at once.</p> <p>For example, consider the following script:</p> <pre><code>$/bin/bash ./my_program $@ </code></pre> <p>When called as</p> <pre><code>./script arg1 arg2 a...
2,048
557,306
2016-01-25 21:29:42
6,471,153
13
2011-06-24 16:56:53
650,405
2011-06-24 16:56:53
https://stackoverflow.com/q/6471090
https://stackoverflow.com/a/6471153
<p>Use this one:</p> <pre><code>./my_program "$*" </code></pre>
<p>Use this one:</p> <pre><code>./my_program "$*" </code></pre>
387, 2313
arguments, bash
<h1>Join Arguments - Escape Spaces</h1> <p>Is there any easy way to "join" the arguments passed to a script? I'd like something similar to <code>$@</code>, but that passes the arguments at once.</p> <p>For example, consider the following script:</p> <pre><code>$/bin/bash ./my_program $@ </code></pre> <p>When called...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,522
bash
# Join Arguments - Escape Spaces Is there any easy way to "join" the arguments passed to a script? I'd like something similar to `$@`, but that passes the arguments at once. For example, consider the following script: ``` $/bin/bash ./my_program $@ ``` When called as ``` ./script arg1 arg2 arg3 ``` `my_program` ...
Use this one: ``` ./my_program "$*" ```
5852643
Piping in on the command line simulating a file?
7
2011-05-02 01:11:26
<p>I've seen the technique before, but don't know what it's called and forget the exact syntax. Let's say I need to pipe in a file to a program like: command &lt; input-file. However, I want to directly pass these lines of the input file into the command without the intermediate input file. It looks something like this...
4,296
449,511
2011-05-02 01:15:47
5,852,659
13
2011-05-02 01:14:37
207,248
2011-05-02 01:14:37
https://stackoverflow.com/q/5852643
https://stackoverflow.com/a/5852659
<p>This is called <code>Process Substitution</code></p> <pre><code>command &lt; &lt;(printf "%s\n" "file-line1" "file-line2" "file-line3") </code></pre> <p>With the above, <code>command</code> will think its being input a file with a name much like <code>/dev/fd/XX</code> where 'XX' is some number. As you mentioned, ...
<p>This is called <code>Process Substitution</code></p> <pre><code>command &lt; &lt;(printf "%s\n" "file-line1" "file-line2" "file-line3") </code></pre> <p>With the above, <code>command</code> will think its being input a file with a name much like <code>/dev/fd/XX</code> where 'XX' is some number. As you mentioned, ...
387, 1231, 5813
bash, command-line, pipe
<h1>Piping in on the command line simulating a file?</h1> <p>I've seen the technique before, but don't know what it's called and forget the exact syntax. Let's say I need to pipe in a file to a program like: command &lt; input-file. However, I want to directly pass these lines of the input file into the command without...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,523
bash
# Piping in on the command line simulating a file? I've seen the technique before, but don't know what it's called and forget the exact syntax. Let's say I need to pipe in a file to a program like: command < input-file. However, I want to directly pass these lines of the input file into the command without the interme...
This is called `Process Substitution` ``` command < <(printf "%s\n" "file-line1" "file-line2" "file-line3") ``` With the above, `command` will think its being input a file with a name much like `/dev/fd/XX` where 'XX' is some number. As you mentioned, this is a temporary file (actually a file descriptor) but it will ...
5810296
bash: find -exec and filenames
7
2011-04-27 20:40:07
<p>I want to strip the HTML out of few hundred files. </p> <p>Here's the command I've started with:</p> <pre><code>find -name *.html -exec w3m {} &gt; w3m {}.html.out \; </code></pre> <p>The problem I've run into is that it created one single large .htm.out file (named {}.html.out) -- I want the file I'm using to b...
3,522
2,764
2011-04-27 20:42:06
5,810,316
13
2011-04-27 20:42:06
20,862
2011-04-27 20:42:06
https://stackoverflow.com/q/5810296
https://stackoverflow.com/a/5810316
<p>The redirection happens outside of <code>find</code>. Invoke a subshell.</p> <pre><code>find -name *.html -exec bash -c 'w3m "$1" &gt; w3m-"$1".html.out' w3mout {} \; </code></pre>
<p>The redirection happens outside of <code>find</code>. Invoke a subshell.</p> <pre><code>find -name *.html -exec bash -c 'w3m "$1" &gt; w3m-"$1".html.out' w3mout {} \; </code></pre>
387, 7932, 10193, 28569
bash, exec, find, w3m
<h1>bash: find -exec and filenames</h1> <p>I want to strip the HTML out of few hundred files. </p> <p>Here's the command I've started with:</p> <pre><code>find -name *.html -exec w3m {} &gt; w3m {}.html.out \; </code></pre> <p>The problem I've run into is that it created one single large .htm.out file (named {}.htm...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,524
bash
# bash: find -exec and filenames I want to strip the HTML out of few hundred files. Here's the command I've started with: ``` find -name *.html -exec w3m {} > w3m {}.html.out \; ``` The problem I've run into is that it created one single large .htm.out file (named {}.html.out) -- I want the file I'm using to be nam...
The redirection happens outside of `find`. Invoke a subshell. ``` find -name *.html -exec bash -c 'w3m "$1" > w3m-"$1".html.out' w3mout {} \; ```
5168616
Powershell - How to search for Whole Words (or) Exact Matches
7
2011-03-02 14:12:33
<p>this is my requirement. </p> <p>I need to find if a certain CSS classes is referenced in my Solution which has over 120 aspx pages. </p> <p>This is the command that we wrote</p> <pre><code>gci . -include *.aspx -recurse | select-string -pattern ".rtop" -caseSensitive &gt;&gt; D:\CSSResult.txt </code></pre> <p>Ho...
34,979
182,978
2012-06-22 14:52:48
5,168,712
13
2011-03-02 14:19:33
20,670
2011-03-02 14:19:33
https://stackoverflow.com/q/5168616
https://stackoverflow.com/a/5168712
<p>Try <code>select-string -pattern "\.rtop\b"</code>.</p> <p>You need to escape the dot, or it will match any character; and the <code>\b</code> word boundary anchor ensures that the word does not continue after <code>rtop</code>.</p>
<p>Try <code>select-string -pattern "\.rtop\b"</code>.</p> <p>You need to escape the dot, or it will match any character; and the <code>\b</code> word boundary anchor ensures that the word does not continue after <code>rtop</code>.</p>
18, 526
powershell, regex
<h1>Powershell - How to search for Whole Words (or) Exact Matches</h1> <p>this is my requirement. </p> <p>I need to find if a certain CSS classes is referenced in my Solution which has over 120 aspx pages. </p> <p>This is the command that we wrote</p> <pre><code>gci . -include *.aspx -recurse | select-string -patter...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,525
bash
# Powershell - How to search for Whole Words (or) Exact Matches this is my requirement. I need to find if a certain CSS classes is referenced in my Solution which has over 120 aspx pages. This is the command that we wrote ``` gci . -include *.aspx -recurse | select-string -pattern ".rtop" -caseSensitive >> D:\CSSRe...
Try `select-string -pattern "\.rtop\b"`. You need to escape the dot, or it will match any character; and the `\b` word boundary anchor ensures that the word does not continue after `rtop`.
4304631
Rescheduling an at job
7
2010-11-29 14:22:01
<p>Is there a way to change the date of a job that has been issued with the unix <code>at</code> command?</p> <p>I need to do this because my Application has scheduled too many jobs at the same time which will bring the machine to a grinding halt.</p>
5,484
305,910
2013-03-25 10:34:43
4,306,526
13
2010-11-29 17:52:50
26,428
2010-11-30 10:45:29
https://stackoverflow.com/q/4304631
https://stackoverflow.com/a/4306526
<p>This is probably implementation dependent, but on my system I can rename the job like so:</p> <pre><code>$ # Bash $ sudo ls -l /var/spool/cron/atjobs -rwx------ 1 username daemon 3782 Nov 29 11:24 a00078014854e8 $ atq 120 Mon Nov 29 11:44:00 2010 a username $ printf "%x\n" $((16#14854e8 + 60*2)) # 2 hour del...
<p>This is probably implementation dependent, but on my system I can rename the job like so:</p> <pre><code>$ # Bash $ sudo ls -l /var/spool/cron/atjobs -rwx------ 1 username daemon 3782 Nov 29 11:24 a00078014854e8 $ atq 120 Mon Nov 29 11:44:00 2010 a username $ printf "%x\n" $((16#14854e8 + 60*2)) # 2 hour del...
34, 390, 90171
at-job, shell, unix
<h1>Rescheduling an at job</h1> <p>Is there a way to change the date of a job that has been issued with the unix <code>at</code> command?</p> <p>I need to do this because my Application has scheduled too many jobs at the same time which will bring the machine to a grinding halt.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,526
bash
# Rescheduling an at job Is there a way to change the date of a job that has been issued with the unix `at` command? I need to do this because my Application has scheduled too many jobs at the same time which will bring the machine to a grinding halt.
This is probably implementation dependent, but on my system I can rename the job like so: ``` $ # Bash $ sudo ls -l /var/spool/cron/atjobs -rwx------ 1 username daemon 3782 Nov 29 11:24 a00078014854e8 $ atq 120 Mon Nov 29 11:44:00 2010 a username $ printf "%x\n" $((16#14854e8 + 60*2)) # 2 hour delay 1485560 $ s...
3542649
CakePHP Console on Godaddy Hosting
7
2010-08-22 18:08:08
<p>I have been struggling to get my CakePHP site working on a Godaddy "grid hosting" account. My cake app is setup is hosted from a subdirectory on the account, and can be accessed via a subdomain. I had to adjust my .htaccess files to get this working, and now I need to get the CakePHP console working in this environm...
3,441
13,800
2016-08-16 10:54:27
3,570,142
13
2010-08-25 20:58:14
13,800
2010-08-29 18:05:11
https://stackoverflow.com/q/3542649
https://stackoverflow.com/a/3570142
<p>in the cake shell script (cake/console/cake) change</p> <pre><code>exec php -q ${LIB}cake.php -working "${APP}" "$@" </code></pre> <p>to </p> <pre><code>exec php -q -d register_argc_argv=1 ${LIB}cake.php -working "${APP}" "$@" </code></pre> <p>after this I found out that calling php like this happened to run the...
<p>in the cake shell script (cake/console/cake) change</p> <pre><code>exec php -q ${LIB}cake.php -working "${APP}" "$@" </code></pre> <p>to </p> <pre><code>exec php -q -d register_argc_argv=1 ${LIB}cake.php -working "${APP}" "$@" </code></pre> <p>after this I found out that calling php like this happened to run the...
5, 58, 387, 3437
bash, cakephp, linux, php
<h1>CakePHP Console on Godaddy Hosting</h1> <p>I have been struggling to get my CakePHP site working on a Godaddy "grid hosting" account. My cake app is setup is hosted from a subdirectory on the account, and can be accessed via a subdomain. I had to adjust my .htaccess files to get this working, and now I need to get ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,527
bash
# CakePHP Console on Godaddy Hosting I have been struggling to get my CakePHP site working on a Godaddy "grid hosting" account. My cake app is setup is hosted from a subdirectory on the account, and can be accessed via a subdomain. I had to adjust my .htaccess files to get this working, and now I need to get the CakeP...
in the cake shell script (cake/console/cake) change ``` exec php -q ${LIB}cake.php -working "${APP}" "$@" ``` to ``` exec php -q -d register_argc_argv=1 ${LIB}cake.php -working "${APP}" "$@" ``` after this I found out that calling php like this happened to run the PHP 4 CLI. to fix this here is the final bash scrip...
2588277
How can I swap or replace multiple strings in code at the same time?
7
2010-04-06 20:59:24
<p>Given the following code sample:</p> <pre><code>uint8_t i, in, ni; i = in = 2; ni = 1; while (2 == i &gt; ni) in++; </code></pre> <p>How can I replace <code>i, in, and ni</code>, respectively with either <code>in, ni, and i</code> or <code>inni, inin, and nini</code> using emacs, vi, *nix commands, or anything els...
1,843
290,128
2013-08-19 22:08:06
2,592,685
13
2010-04-07 13:17:22
16,240
2013-08-19 22:08:06
https://stackoverflow.com/q/2588277
https://stackoverflow.com/a/2592685
<p>If I'm not mistaken, the solutions provided so far (using Perl and Vim) do not work correctly when any of the replacements is among the latter words to be replaced. In particular, none of the solutions works for the first example: "i" would be replaced with "in", which would then be incorrectly replaced with "ni" a...
<p>If I'm not mistaken, the solutions provided so far (using Perl and Vim) do not work correctly when any of the replacements is among the latter words to be replaced. In particular, none of the solutions works for the first example: "i" would be replaced with "in", which would then be incorrectly replaced with "ni" a...
8, 293, 371, 387, 1086
bash, c, emacs, refactoring, vi
<h1>How can I swap or replace multiple strings in code at the same time?</h1> <p>Given the following code sample:</p> <pre><code>uint8_t i, in, ni; i = in = 2; ni = 1; while (2 == i &gt; ni) in++; </code></pre> <p>How can I replace <code>i, in, and ni</code>, respectively with either <code>in, ni, and i</code> or <co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,528
bash
# How can I swap or replace multiple strings in code at the same time? Given the following code sample: ``` uint8_t i, in, ni; i = in = 2; ni = 1; while (2 == i > ni) in++; ``` How can I replace `i, in, and ni`, respectively with either `in, ni, and i` or `inni, inin, and nini` using emacs, vi, *nix commands, or any...
If I'm not mistaken, the solutions provided so far (using Perl and Vim) do not work correctly when any of the replacements is among the latter words to be replaced. In particular, none of the solutions works for the first example: "i" would be replaced with "in", which would then be incorrectly replaced with "ni" and t...
2362154
shell float number in expr
7
2010-03-02 09:43:22
<p>I'm trying to get a float number from this :</p> <pre><code>totalmark=$(expr $sum / $subjects ) </code></pre> <p>Is this correct?</p>
17,561
262,854
2010-03-04 11:34:30
2,362,611
13
2010-03-02 11:02:45
131,527
2010-03-02 11:02:45
https://stackoverflow.com/q/2362154
https://stackoverflow.com/a/2362611
<p>bash doesn't support floats, use awk or bc/dc</p> <p>eg awk</p> <pre><code>totalmark=$(awk 'BEGIN{print $sum / $subjects}') </code></pre> <p>or bc</p> <pre><code>totalmark=$(echo "scale=2;$sum/$subjects"|bc) </code></pre> <p>if you have the luxury to use different shells other than bash, try zsh or ksh</p> <pr...
<p>bash doesn't support floats, use awk or bc/dc</p> <p>eg awk</p> <pre><code>totalmark=$(awk 'BEGIN{print $sum / $subjects}') </code></pre> <p>or bc</p> <pre><code>totalmark=$(echo "scale=2;$sum/$subjects"|bc) </code></pre> <p>if you have the luxury to use different shells other than bash, try zsh or ksh</p> <pr...
387, 390
bash, shell
<h1>shell float number in expr</h1> <p>I'm trying to get a float number from this :</p> <pre><code>totalmark=$(expr $sum / $subjects ) </code></pre> <p>Is this correct?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,529
bash
# shell float number in expr I'm trying to get a float number from this : ``` totalmark=$(expr $sum / $subjects ) ``` Is this correct?
bash doesn't support floats, use awk or bc/dc eg awk ``` totalmark=$(awk 'BEGIN{print $sum / $subjects}') ``` or bc ``` totalmark=$(echo "scale=2;$sum/$subjects"|bc) ``` if you have the luxury to use different shells other than bash, try zsh or ksh ``` $ zsh -c 'echo $((4/1.3))' 3.0769230769230766 $ ksh -c 'echo...
619649
Passing an associative array from c# to Powershell
7
2009-03-06 17:14:23
<p>I'd like to pass an associative array from C# to Powershell. As an example I'd like to execute this powershell line of code:</p> <pre><code> PS C:\> get-command | select name, @{N="Foo";E={"Bar"}} -first 3 Name Foo ---- ...
4,910
61,396
2009-03-06 19:45:36
620,165
13
2009-03-06 19:45:36
6,920
2009-03-06 19:45:36
https://stackoverflow.com/q/619649
https://stackoverflow.com/a/620165
<p>Creating a pipeline through c# and creating a pipeline with native powershell script have one major difference that is actually quite subtle: the parameter binder.</p> <p>if I write a version of your code in pure script, I will get the same error: the hashtable literal is treated as a string value.</p> <pre><code>...
<p>Creating a pipeline through c# and creating a pipeline with native powershell script have one major difference that is actually quite subtle: the parameter binder.</p> <p>if I write a version of your code in pure script, I will get the same error: the hashtable literal is treated as a string value.</p> <pre><code>...
9, 526, 2575
associative-array, c#, powershell
<h1>Passing an associative array from c# to Powershell</h1> <p>I'd like to pass an associative array from C# to Powershell. As an example I'd like to execute this powershell line of code:</p> <pre><code> PS C:\> get-command | select name, @{N="Foo";E={"Bar"}} -first 3 Name ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,530
bash
# Passing an associative array from c# to Powershell I'd like to pass an associative array from C# to Powershell. As an example I'd like to execute this powershell line of code: ``` PS C:\> get-command | select name, @{N="Foo";E={"Bar"}} -first 3 Name Foo ---- ...
Creating a pipeline through c# and creating a pipeline with native powershell script have one major difference that is actually quite subtle: the parameter binder. if I write a version of your code in pure script, I will get the same error: the hashtable literal is treated as a string value. ``` ps> $ps = $ps.Command...
295303
CommonAppData in vbscript
7
2008-11-17 10:49:39
<p>A customer's application "AppName" has its configuration files stored in CommonAppData. </p> <ul> <li>Under Windows XP that is <code>C:\Documents and Settings\All Users\Application Data\AppName</code></li> <li>Under Windows Vista that is <code>C:\ProgramData\AppName</code></li> </ul> <p>How do I get the correct fo...
9,542
23,369
2019-08-05 11:05:56
295,319
13
2008-11-17 11:01:40
18,771
2019-08-05 11:05:56
https://stackoverflow.com/q/295303
https://stackoverflow.com/a/295319
<pre><code>Const CommonAppData = &amp;H23&amp; ' the second &amp; denotes a long integer ' Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(CommonAppData) Set objFolderItem = objFolder.Self MsgBox objFolderItem.Name &amp; ": " &amp; objFolderItem.Path </code></pre> <p>The MSDN h...
<pre><code>Const CommonAppData = &amp;H23&amp; ' the second &amp; denotes a long integer ' Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(CommonAppData) Set objFolderItem = objFolder.Self MsgBox objFolderItem.Name &amp; ": " &amp; objFolderItem.Path </code></pre> <p>The MSDN h...
64, 494, 889, 8123, 16652
special-folders, vbscript, winapi, windows, windows-shell
<h1>CommonAppData in vbscript</h1> <p>A customer's application "AppName" has its configuration files stored in CommonAppData. </p> <ul> <li>Under Windows XP that is <code>C:\Documents and Settings\All Users\Application Data\AppName</code></li> <li>Under Windows Vista that is <code>C:\ProgramData\AppName</code></li> </...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,531
bash
# CommonAppData in vbscript A customer's application "AppName" has its configuration files stored in CommonAppData. - Under Windows XP that is `C:\Documents and Settings\All Users\Application Data\AppName` - Under Windows Vista that is `C:\ProgramData\AppName` How do I get the correct foldername with VBScript?
``` Const CommonAppData = &H23& ' the second & denotes a long integer ' Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(CommonAppData) Set objFolderItem = objFolder.Self MsgBox objFolderItem.Name & ": " & objFolderItem.Path ``` The MSDN holds a page that lists the other [Shell ...
72886868
Alacritty delete line with Cmd + Backspace
6
2022-07-06 16:17:30
<p>Recently switched from Iterm to Alacritty for various reasons. One thing that I'm now realizing I used a lot is command + backspace to delete and entire line (Yes I'm aware of CTR + U, but that's not muscle memory for me). Is there a way to set up a shortcut for line clear in alacrity?</p>
4,216
18,192,482
2024-02-13 05:55:06
72,945,790
13
2022-07-12 00:07:13
12,957,340
2022-07-12 00:07:13
https://stackoverflow.com/q/72886868
https://stackoverflow.com/a/72945790
<p>Adding the line <code> - { key: Back, mods: Command, chars: &quot;\x15&quot; }</code> to the alacritty.yml file will delete the entire line with &quot;Cmd+Backspace&quot; on macOS.</p> <p>Also, here are some additional keybinding changes I've made to my alacritty setup that may make your life easier (per <a href="ht...
<p>Adding the line <code> - { key: Back, mods: Command, chars: &quot;\x15&quot; }</code> to the alacritty.yml file will delete the entire line with &quot;Cmd+Backspace&quot; on macOS.</p> <p>Also, here are some additional keybinding changes I've made to my alacritty setup that may make your life easier (per <a href="ht...
369, 390, 1852, 146769
alacritty, macos, shell, yaml
<h1>Alacritty delete line with Cmd + Backspace</h1> <p>Recently switched from Iterm to Alacritty for various reasons. One thing that I'm now realizing I used a lot is command + backspace to delete and entire line (Yes I'm aware of CTR + U, but that's not muscle memory for me). Is there a way to set up a shortcut for li...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,532
bash
# Alacritty delete line with Cmd + Backspace Recently switched from Iterm to Alacritty for various reasons. One thing that I'm now realizing I used a lot is command + backspace to delete and entire line (Yes I'm aware of CTR + U, but that's not muscle memory for me). Is there a way to set up a shortcut for line clear ...
Adding the line `- { key: Back, mods: Command, chars: "\x15" }` to the alacritty.yml file will delete the entire line with "Cmd+Backspace" on macOS. Also, here are some additional keybinding changes I've made to my alacritty setup that may make your life easier (per <https://github.com/alacritty/alacritty/issues/474#...
70804147
How to run bash script within VS Code?
6
2022-01-21 16:00:59
<p>I want to run bash script when I hit <code>F5</code> and see the results in the terminal like I can do with python scripts or whatever. I tried to do that with <code>Bash Debug</code> however it automatically goes to the debug mode and stops at the first step even if I do not put breakpoint. This is the launch confi...
23,468
3,095,866
2024-07-04 09:12:06
72,097,548
13
2022-05-03 09:45:32
2,053,706
2022-09-21 03:58:58
https://stackoverflow.com/q/70804147
https://stackoverflow.com/a/72097548
<p>I don't know about running <code>bash</code> in a <strong>debug mode</strong> (doesn't seem like you need those features based on your example) but you can easily get your script to run as a <em>Task</em> or <em>Build</em> option.</p> <p>Place this at <code>.vscode/tasks.json</code> of your project dir</p> <pre clas...
<p>I don't know about running <code>bash</code> in a <strong>debug mode</strong> (doesn't seem like you need those features based on your example) but you can easily get your script to run as a <em>Task</em> or <em>Build</em> option.</p> <p>Place this at <code>.vscode/tasks.json</code> of your project dir</p> <pre clas...
387, 111608
bash, visual-studio-code
<h1>How to run bash script within VS Code?</h1> <p>I want to run bash script when I hit <code>F5</code> and see the results in the terminal like I can do with python scripts or whatever. I tried to do that with <code>Bash Debug</code> however it automatically goes to the debug mode and stops at the first step even if I...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,533
bash
# How to run bash script within VS Code? I want to run bash script when I hit `F5` and see the results in the terminal like I can do with python scripts or whatever. I tried to do that with `Bash Debug` however it automatically goes to the debug mode and stops at the first step even if I do not put breakpoint. This is...
I don't know about running `bash` in a **debug mode** (doesn't seem like you need those features based on your example) but you can easily get your script to run as a *Task* or *Build* option. Place this at `.vscode/tasks.json` of your project dir ``` { // See https://go.microsoft.com/fwlink/?LinkId=733558 //...
68419132
In Azure pipeline, how can Powershell make a task fail?
6
2021-07-17 09:17:11
<p>I am working on Azure Pipelines on a Windows Self hosted Agent. I need my pipeline to run a PowerShell script and if the script is successful, the next stage do the deployment, else the task fails, we have to fix something and resume the task</p> <p>I'll describe what the pipeline does since the start as it might he...
13,433
2,362,196
2025-03-25 12:25:15
68,443,534
13
2021-07-19 15:55:33
2,362,196
2021-07-19 15:55:33
https://stackoverflow.com/q/68419132
https://stackoverflow.com/a/68443534
<p>I was able to use these exit values to make the pipeline task succeed or failed:</p> <pre><code>if($equal) { # make pipeline to succeed exit 0 } else { exit 1 } </code></pre> <p>I used the PowerShell script in its own stage instead of in a job and it worked, when the task fails, I can do required manual ...
<p>I was able to use these exit values to make the pipeline task succeed or failed:</p> <pre><code>if($equal) { # make pipeline to succeed exit 0 } else { exit 1 } </code></pre> <p>I used the PowerShell script in its own stage instead of in a job and it worked, when the task fails, I can do required manual ...
81879, 139136
azure-pipelines-yaml, azure-powershell
<h1>In Azure pipeline, how can Powershell make a task fail?</h1> <p>I am working on Azure Pipelines on a Windows Self hosted Agent. I need my pipeline to run a PowerShell script and if the script is successful, the next stage do the deployment, else the task fails, we have to fix something and resume the task</p> <p>I'...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,534
bash
# In Azure pipeline, how can Powershell make a task fail? I am working on Azure Pipelines on a Windows Self hosted Agent. I need my pipeline to run a PowerShell script and if the script is successful, the next stage do the deployment, else the task fails, we have to fix something and resume the task I'll describe wha...
I was able to use these exit values to make the pipeline task succeed or failed: ``` if($equal) { # make pipeline to succeed exit 0 } else { exit 1 } ``` I used the PowerShell script in its own stage instead of in a job and it worked, when the task fails, I can do required manual actions and run the task ...
64467425
MD5-Checksum hashing with powershell for a whole directory
6
2020-10-21 15:56:51
<p>I'm trying to generate an MD5-Checksum with powershell for a whole directory. On Linux there is a 1-liner that works just great, like this one:</p> <p>$ tar -cf - somedir | md5sum</p> <p>I learned that &quot;tar&quot; is now part of Windows10 and that it can be adressed in the PowerShell. So I tried this:</p> <p>tar...
28,123
9,033,281
2024-04-17 23:05:32
64,468,867
13
2020-10-21 17:37:45
11,301,839
2020-10-22 11:02:58
https://stackoverflow.com/q/64467425
https://stackoverflow.com/a/64468867
<p>EDIT: Here's an alternate method that is consistent even if all the files are moved/copied to another location. This one uses the hashes of all files to create a &quot;master hash&quot;. It takes longer to run for obvious reasons but will be more reliable.</p> <pre><code>$HashString = (Get-ChildItem C:\Temp -Recurse...
<p>EDIT: Here's an alternate method that is consistent even if all the files are moved/copied to another location. This one uses the hashes of all files to create a &quot;master hash&quot;. It takes longer to run for obvious reasons but will be more reliable.</p> <pre><code>$HashString = (Get-ChildItem C:\Temp -Recurse...
218, 526, 2179, 2358
checksum, directory, md5, powershell
<h1>MD5-Checksum hashing with powershell for a whole directory</h1> <p>I'm trying to generate an MD5-Checksum with powershell for a whole directory. On Linux there is a 1-liner that works just great, like this one:</p> <p>$ tar -cf - somedir | md5sum</p> <p>I learned that &quot;tar&quot; is now part of Windows10 and th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,535
bash
# MD5-Checksum hashing with powershell for a whole directory I'm trying to generate an MD5-Checksum with powershell for a whole directory. On Linux there is a 1-liner that works just great, like this one: $ tar -cf - somedir | md5sum I learned that "tar" is now part of Windows10 and that it can be adressed in the Po...
EDIT: Here's an alternate method that is consistent even if all the files are moved/copied to another location. This one uses the hashes of all files to create a "master hash". It takes longer to run for obvious reasons but will be more reliable. ``` $HashString = (Get-ChildItem C:\Temp -Recurse | Get-FileHash -Algori...
63288592
How to use git bash in sublime text 3
6
2020-08-06 17:10:09
<p>I use Sublime Text 3 as my default text/code editor and I very frequently use the terminal in Sublime Text 3 with the Terminus package. And recently I've discovered git it has a really wonderful bash and I prefer using the git bash instead of using git through the default Windows terminal.</p> <p>Is there any way th...
8,377
12,033,855
2022-10-06 08:00:17
63,293,174
13
2020-08-06 23:36:41
814,803
2020-08-06 23:36:41
https://stackoverflow.com/q/63288592
https://stackoverflow.com/a/63293174
<p>To do this, open the Terminus preferences by choosing <code>Preferences &gt; Package Settings &gt; Terminus &gt; Settings</code> from the menu or <code>Preferences: Terminus Settings</code> from the command palette.</p> <p>Both will open the Terminus settings in a new split window, with your settings on the right an...
<p>To do this, open the Terminus preferences by choosing <code>Preferences &gt; Package Settings &gt; Terminus &gt; Settings</code> from the menu or <code>Preferences: Terminus Settings</code> from the command palette.</p> <p>Both will open the Terminus settings in a new split window, with your settings on the right an...
119, 387, 72788, 88190
bash, git, sublimetext, sublimetext3
<h1>How to use git bash in sublime text 3</h1> <p>I use Sublime Text 3 as my default text/code editor and I very frequently use the terminal in Sublime Text 3 with the Terminus package. And recently I've discovered git it has a really wonderful bash and I prefer using the git bash instead of using git through the defau...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,536
bash
# How to use git bash in sublime text 3 I use Sublime Text 3 as my default text/code editor and I very frequently use the terminal in Sublime Text 3 with the Terminus package. And recently I've discovered git it has a really wonderful bash and I prefer using the git bash instead of using git through the default Window...
To do this, open the Terminus preferences by choosing `Preferences > Package Settings > Terminus > Settings` from the menu or `Preferences: Terminus Settings` from the command palette. Both will open the Terminus settings in a new split window, with your settings on the right and the defaults on the left. What you nee...
60600539
Powershell 5 : Cannot convert value To System.String
6
2020-03-09 12:26:01
<p>I have a PS script with which I read a csv file line by line into a variable :</p> <p>CSV :</p> <pre><code> header1;header2 column1;column2 </code></pre> <p>PS Script :</p> <pre><code>#------------------------- # Func declarations #------------------------- function myFunc{ param( [Parameter(Mandator...
41,552
315,591
2024-02-13 17:49:49
60,601,823
13
2020-03-09 13:42:55
45,375
2023-11-01 18:27:15
https://stackoverflow.com/q/60600539
https://stackoverflow.com/a/60601823
<p>Note: As of this writing, there's no explanation for the specific symptoms described in the question, and Sandy reports their problem as now resolved.<br /> <strong>This answer generally explains under what circumstance you'll see the <code>Cannot convert value to type System.String</code> error when passing an arg...
<p>Note: As of this writing, there's no explanation for the specific symptoms described in the question, and Sandy reports their problem as now resolved.<br /> <strong>This answer generally explains under what circumstance you'll see the <code>Cannot convert value to type System.String</code> error when passing an arg...
526, 108010
powershell, powershell-5.0
<h1>Powershell 5 : Cannot convert value To System.String</h1> <p>I have a PS script with which I read a csv file line by line into a variable :</p> <p>CSV :</p> <pre><code> header1;header2 column1;column2 </code></pre> <p>PS Script :</p> <pre><code>#------------------------- # Func declarations #--------------...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,537
bash
# Powershell 5 : Cannot convert value To System.String I have a PS script with which I read a csv file line by line into a variable : CSV : ``` header1;header2 column1;column2 ``` PS Script : ``` #------------------------- # Func declarations #------------------------- function myFunc{ param( [Par...
Note: As of this writing, there's no explanation for the specific symptoms described in the question, and Sandy reports their problem as now resolved. **This answer generally explains under what circumstance you'll see the `Cannot convert value to type System.String` error when passing an argument to a `[string]`-typ...
55682533
why 'read' command in shell script is missing initial characters?
6
2019-04-15 04:14:37
<p>I have the following shell script and it is missing some initial characters (it misses initial couple of characters, so far in my observation) from each line except the first line. </p> <p>And this happens only when I use the <code>ffmpeg</code> command. Otherwise, it is fine. But this command does the actual task ...
1,867
2,249,026
2019-04-15 04:57:59
55,682,555
13
2019-04-15 04:20:01
5,291,015
2019-04-15 04:57:59
https://stackoverflow.com/q/55682533
https://stackoverflow.com/a/55682555
<p>This is pretty well explained in this post <a href="https://mywiki.wooledge.org/BashFAQ/089" rel="noreferrer">I'm reading a file line by line and running ssh or ffmpeg, only the first line gets processed!</a>. When reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input f...
<p>This is pretty well explained in this post <a href="https://mywiki.wooledge.org/BashFAQ/089" rel="noreferrer">I'm reading a file line by line and running ssh or ffmpeg, only the first line gets processed!</a>. When reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input f...
58, 387, 390, 549, 3847
bash, ffmpeg, linux, shell, ubuntu
<h1>why 'read' command in shell script is missing initial characters?</h1> <p>I have the following shell script and it is missing some initial characters (it misses initial couple of characters, so far in my observation) from each line except the first line. </p> <p>And this happens only when I use the <code>ffmpeg</c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,538
bash
# why 'read' command in shell script is missing initial characters? I have the following shell script and it is missing some initial characters (it misses initial couple of characters, so far in my observation) from each line except the first line. And this happens only when I use the `ffmpeg` command. Otherwise, it ...
This is pretty well explained in this post [I'm reading a file line by line and running ssh or ffmpeg, only the first line gets processed!](https://mywiki.wooledge.org/BashFAQ/089). When reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input file. In your case `ffmpeg` also...
52858090
Run bash command from windows Command line (WSL)
6
2018-10-17 15:07:56
<p>I have installed WSL on Windows 10 Pro. And I need to execute bash commands from Windows Command Line like this:</p> <pre><code>bash -c ll </code></pre> <p>Expected: <code>ll</code> command output in Command Line console</p> <p>In practice: <code>/bin/bash: ll: command not found</code></p> <p>But its work for s...
12,947
4,481,855
2018-10-17 15:36:01
52,858,333
13
2018-10-17 15:19:30
469,210
2018-10-17 15:19:30
https://stackoverflow.com/q/52858090
https://stackoverflow.com/a/52858333
<p><code>ll</code> is a common alias (for <code>ls -alF</code> in WSL; defined in the default <code>.bashrc</code>). Depending on how you invoke <code>bash</code> will determine whether the scripts which set up your system aliases are run. See the <code>INVOCATION</code> section of the <code>bash</code> manual.</p> ...
<p><code>ll</code> is a common alias (for <code>ls -alF</code> in WSL; defined in the default <code>.bashrc</code>). Depending on how you invoke <code>bash</code> will determine whether the scripts which set up your system aliases are run. See the <code>INVOCATION</code> section of the <code>bash</code> manual.</p> ...
387, 119526
bash, windows-subsystem-for-linux
<h1>Run bash command from windows Command line (WSL)</h1> <p>I have installed WSL on Windows 10 Pro. And I need to execute bash commands from Windows Command Line like this:</p> <pre><code>bash -c ll </code></pre> <p>Expected: <code>ll</code> command output in Command Line console</p> <p>In practice: <code>/bin/bas...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,539
bash
# Run bash command from windows Command line (WSL) I have installed WSL on Windows 10 Pro. And I need to execute bash commands from Windows Command Line like this: ``` bash -c ll ``` Expected: `ll` command output in Command Line console In practice: `/bin/bash: ll: command not found` But its work for some commands...
`ll` is a common alias (for `ls -alF` in WSL; defined in the default `.bashrc`). Depending on how you invoke `bash` will determine whether the scripts which set up your system aliases are run. See the `INVOCATION` section of the `bash` manual. You can use `bash -i -c ll` to invoke `bash` in an appropriate way for WSL.
51175430
Give the generated PDF a custom title
6
2018-07-04 13:56:23
<p>I've merged two PDF using the command<pre>$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";</pre> This is working for me. But the issue is title of the new generated PDF is not set as per I've set in the <code>header('Content-Disposition: inline; filename="Test.pdf"');</code> I'm expectin...
3,016
6,468,641
2019-01-09 16:02:37
51,177,618
13
2018-07-04 16:09:10
701,996
2018-07-04 16:09:10
https://stackoverflow.com/q/51175430
https://stackoverflow.com/a/51177618
<p>Sounds to me like you need to set the Title in the Document /Info dictionary of the PDF file. You can do that by sending a DOCINFO pdfmark.</p> <p>You can pick up the pdfmark reference manual by googling for it. Its on the Adobe web site but they move the furniture so often there's no point in quoting today's URL.<...
<p>Sounds to me like you need to set the Title in the Document /Info dictionary of the PDF file. You can do that by sending a DOCINFO pdfmark.</p> <p>You can pick up the pdfmark reference manual by googling for it. Its on the Adobe web site but they move the furniture so often there's no point in quoting today's URL.<...
5, 90, 390, 5062, 13265
ghostscript, header, pdf, php, shell
<h1>Give the generated PDF a custom title</h1> <p>I've merged two PDF using the command<pre>$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";</pre> This is working for me. But the issue is title of the new generated PDF is not set as per I've set in the <code>header('Content-Disposition: inl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,540
bash
# Give the generated PDF a custom title I've merged two PDF using the command ``` $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName "; ``` This is working for me. But the issue is title of the new generated PDF is not set as per I've set in the `header('Content-Disposition: inline; filename=...
Sounds to me like you need to set the Title in the Document /Info dictionary of the PDF file. You can do that by sending a DOCINFO pdfmark. You can pick up the pdfmark reference manual by googling for it. Its on the Adobe web site but they move the furniture so often there's no point in quoting today's URL. You can f...
50082253
Replace hyphen with space using bash
6
2018-04-29 00:23:06
<p>I'm reading a filename that has this data:</p> <pre><code>2017-03-23 2018-01-23 2017-07-31 </code></pre> <p>I want to read each line and replace the hyphens with spaces. Given the above example, I should get the following:</p> <pre><code>2017 03 23 2018 01 23 2017 07 31 </code></pre> <p>Here's my code:</p> <pre...
8,771
3,097,391
2022-12-19 17:54:15
50,082,306
13
2018-04-29 00:33:43
3,097,391
2018-04-29 03:43:57
https://stackoverflow.com/q/50082253
https://stackoverflow.com/a/50082306
<p>tr will replace hyphens with spaces, for example:</p> <pre><code>test=$(echo $date | tr "-" " ") </code></pre>
<p>tr will replace hyphens with spaces, for example:</p> <pre><code>test=$(echo $date | tr "-" " ") </code></pre>
18, 387, 5282
bash, regex, sed
<h1>Replace hyphen with space using bash</h1> <p>I'm reading a filename that has this data:</p> <pre><code>2017-03-23 2018-01-23 2017-07-31 </code></pre> <p>I want to read each line and replace the hyphens with spaces. Given the above example, I should get the following:</p> <pre><code>2017 03 23 2018 01 23 2017 07 ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,541
bash
# Replace hyphen with space using bash I'm reading a filename that has this data: ``` 2017-03-23 2018-01-23 2017-07-31 ``` I want to read each line and replace the hyphens with spaces. Given the above example, I should get the following: ``` 2017 03 23 2018 01 23 2017 07 31 ``` Here's my code: ``` #!/bin/sh file...
tr will replace hyphens with spaces, for example: ``` test=$(echo $date | tr "-" " ") ```
48936032
Bash concatenate array entries without spaces in between
6
2018-02-22 19:50:19
<p><strong>Problem</strong></p> <p>I'm writing an bash script (version 4.3.48). There I have an array and want to concatenate all entries as a single string. The following code do such task (but lag in some case):</p> <pre><code>declare -a array=(one two three) echo "${array[@]}" </code></pre> <p>Unfortunately I get...
5,893
9,031,159
2023-06-18 07:39:02
48,936,123
13
2018-02-22 19:55:22
1,566,221
2018-02-22 19:55:22
https://stackoverflow.com/q/48936032
https://stackoverflow.com/a/48936123
<p><code>printf</code> gives you a lot more control over formatting, and it is also a bash builtin:</p> <pre><code>printf %s "${array[@]}" $'\n' </code></pre> <p>(That works because the shell's <code>printf</code> keeps on repeating the pattern until the arguments are all used up.)</p>
<p><code>printf</code> gives you a lot more control over formatting, and it is also a bash builtin:</p> <pre><code>printf %s "${array[@]}" $'\n' </code></pre> <p>(That works because the shell's <code>printf</code> keeps on repeating the pattern until the arguments are all used up.)</p>
114, 387, 598, 6050
arrays, bash, concatenation, performance
<h1>Bash concatenate array entries without spaces in between</h1> <p><strong>Problem</strong></p> <p>I'm writing an bash script (version 4.3.48). There I have an array and want to concatenate all entries as a single string. The following code do such task (but lag in some case):</p> <pre><code>declare -a array=(one t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,542
bash
# Bash concatenate array entries without spaces in between **Problem** I'm writing an bash script (version 4.3.48). There I have an array and want to concatenate all entries as a single string. The following code do such task (but lag in some case): ``` declare -a array=(one two three) echo "${array[@]}" ``` Unfort...
`printf` gives you a lot more control over formatting, and it is also a bash builtin: ``` printf %s "${array[@]}" $'\n' ``` (That works because the shell's `printf` keeps on repeating the pattern until the arguments are all used up.)
46586447
Using bash, how can I remove the extensions of all files in a specific directory?
6
2017-10-05 13:08:10
<p>I want to keep the files but remove their extensions. The files do not have the same extension to them. My end goal is to remove all their extensions and change them to one single extension of my choice. I have the second part down.</p> <p>My code so far:</p> <pre><code>#!/bin/bash echo -n "Enter the directory: " ...
4,891
7,337,777
2022-01-31 05:21:28
46,586,508
13
2017-10-05 13:11:41
5,291,015
2022-01-31 05:21:28
https://stackoverflow.com/q/46586447
https://stackoverflow.com/a/46586508
<p>You don't need an external command <code>find</code> for this, but do it in <code>bash</code> alone. The script below removes the extension from all the files in the folder <code>path</code>.</p> <pre class="lang-sh prettyprint-override"><code>for file in &quot;$path&quot;/*; do [ -f &quot;$file&quot; ] || conti...
<p>You don't need an external command <code>find</code> for this, but do it in <code>bash</code> alone. The script below removes the extension from all the files in the folder <code>path</code>.</p> <pre class="lang-sh prettyprint-override"><code>for file in &quot;$path&quot;/*; do [ -f &quot;$file&quot; ] || conti...
58, 387, 390, 10327
bash, linux, sh, shell
<h1>Using bash, how can I remove the extensions of all files in a specific directory?</h1> <p>I want to keep the files but remove their extensions. The files do not have the same extension to them. My end goal is to remove all their extensions and change them to one single extension of my choice. I have the second part...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,543
bash
# Using bash, how can I remove the extensions of all files in a specific directory? I want to keep the files but remove their extensions. The files do not have the same extension to them. My end goal is to remove all their extensions and change them to one single extension of my choice. I have the second part down. M...
You don't need an external command `find` for this, but do it in `bash` alone. The script below removes the extension from all the files in the folder `path`. ``` for file in "$path"/*; do [ -f "$file" ] || continue mv "$file" "${file%.*}" done ``` The reason for using `[ -f "$file" ]` is only for a safety ch...
43531688
Unnecessary space in output when using Write-Host
6
2017-04-20 23:49:05
<p>When I use <code>Write-Host</code> within a <code>Foreach-Object</code>, I get an unnecessary space in the output.</p> <pre><code>write-host "http://contoso.com/personal/"$_.ADUserName </code></pre> <p>Output:</p> <pre><code>http://contoso.com/personal/ john.doe </code></pre> <p>How can I remove the space before...
6,014
7,898,591
2017-04-22 20:42:15
43,531,874
13
2017-04-21 00:09:37
24,995
2017-04-21 00:42:37
https://stackoverflow.com/q/43531688
https://stackoverflow.com/a/43531874
<p>This is happening because Write-Host is considering your constant string and your object to be two separate parameters -- you aren't actually joining the strings together the way you're calling it. Instead of calling it this way, actually concatenate the strings:</p> <pre><code>write-host "http://contoso.com/perso...
<p>This is happening because Write-Host is considering your constant string and your object to be two separate parameters -- you aren't actually joining the strings together the way you're calling it. Instead of calling it this way, actually concatenate the strings:</p> <pre><code>write-host "http://contoso.com/perso...
526
powershell
<h1>Unnecessary space in output when using Write-Host</h1> <p>When I use <code>Write-Host</code> within a <code>Foreach-Object</code>, I get an unnecessary space in the output.</p> <pre><code>write-host "http://contoso.com/personal/"$_.ADUserName </code></pre> <p>Output:</p> <pre><code>http://contoso.com/personal/ j...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,544
bash
# Unnecessary space in output when using Write-Host When I use `Write-Host` within a `Foreach-Object`, I get an unnecessary space in the output. ``` write-host "http://contoso.com/personal/"$_.ADUserName ``` Output: ``` http://contoso.com/personal/ john.doe ``` How can I remove the space before john? Trim does not...
This is happening because Write-Host is considering your constant string and your object to be two separate parameters -- you aren't actually joining the strings together the way you're calling it. Instead of calling it this way, actually concatenate the strings: ``` write-host "http://contoso.com/personal/$($_.ADUser...
42622556
How to run a shell script from cocoa application using Swift?
6
2017-03-06 09:58:55
<p>How can I run a shell script from cocoa application using Swift?</p> <p>I have a shell script file.sh that I want to run from within my cocoa application. How can I do this using Swift?</p> <p>Any help appreciated! :)</p>
7,042
2,972,303
2022-04-05 06:23:23
42,623,019
13
2017-03-06 10:20:51
4,063,602
2020-01-25 15:40:19
https://stackoverflow.com/q/42622556
https://stackoverflow.com/a/42623019
<h1>Pre Swift 3</h1> <p>You can use <code>NSTask</code> (<a href="https://developer.apple.com/reference/foundation/nstask" rel="noreferrer">API reference here</a>) for this.</p> <p>A <code>NSTask</code> takes (among other things) a <code>launchPath</code> which points to your script. It can also take an array of <cod...
<h1>Pre Swift 3</h1> <p>You can use <code>NSTask</code> (<a href="https://developer.apple.com/reference/foundation/nstask" rel="noreferrer">API reference here</a>) for this.</p> <p>A <code>NSTask</code> takes (among other things) a <code>launchPath</code> which points to your script. It can also take an array of <cod...
390, 391, 994, 104797
cocoa, shell, swift, terminal
<h1>How to run a shell script from cocoa application using Swift?</h1> <p>How can I run a shell script from cocoa application using Swift?</p> <p>I have a shell script file.sh that I want to run from within my cocoa application. How can I do this using Swift?</p> <p>Any help appreciated! :)</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,545
bash
# How to run a shell script from cocoa application using Swift? How can I run a shell script from cocoa application using Swift? I have a shell script file.sh that I want to run from within my cocoa application. How can I do this using Swift? Any help appreciated! :)
# Pre Swift 3 You can use `NSTask` ([API reference here](https://developer.apple.com/reference/foundation/nstask)) for this. A `NSTask` takes (among other things) a `launchPath` which points to your script. It can also take an array of `arguments` and when you are ready to launch your task, you call `launch()` on it....
41023817
Check if a process is running and if not, restart it using Cron
6
2016-12-07 17:33:29
<p>I have created restart.sh with followin code </p> <pre><code>#!/bin/bash ps -aux | grep sidekiq &gt; /dev/null if [ $? -eq 0 ]; then echo "Process is running." else echo "Process is not running." fi </code></pre> <p>To check if sidekiq process is running or not. I will put this script in cron to run daily so i...
21,815
692,622
2017-11-30 18:36:45
41,023,934
13
2016-12-07 17:39:27
5,291,015
2016-12-07 17:47:03
https://stackoverflow.com/q/41023817
https://stackoverflow.com/a/41023934
<p>To exclude the <code>grep</code> result from the <code>ps</code> output. Do</p> <pre><code>ps -aux | grep -v grep | grep sidekiq </code></pre> <p>(or) do a <code>regEx</code> search of the process name, i.e. <code>s</code> followed by rest of the process name.</p> <pre><code>ps -aux | grep [s]idekiq </code></pre>...
<p>To exclude the <code>grep</code> result from the <code>ps</code> output. Do</p> <pre><code>ps -aux | grep -v grep | grep sidekiq </code></pre> <p>(or) do a <code>regEx</code> search of the process name, i.e. <code>s</code> followed by rest of the process name.</p> <pre><code>ps -aux | grep [s]idekiq </code></pre>...
34, 387, 390, 601, 990
awk, bash, cron, shell, unix
<h1>Check if a process is running and if not, restart it using Cron</h1> <p>I have created restart.sh with followin code </p> <pre><code>#!/bin/bash ps -aux | grep sidekiq &gt; /dev/null if [ $? -eq 0 ]; then echo "Process is running." else echo "Process is not running." fi </code></pre> <p>To check if sidekiq pr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,546
bash
# Check if a process is running and if not, restart it using Cron I have created restart.sh with followin code ``` #!/bin/bash ps -aux | grep sidekiq > /dev/null if [ $? -eq 0 ]; then echo "Process is running." else echo "Process is not running." fi ``` To check if sidekiq process is running or not. I will put t...
To exclude the `grep` result from the `ps` output. Do ``` ps -aux | grep -v grep | grep sidekiq ``` (or) do a `regEx` search of the process name, i.e. `s` followed by rest of the process name. ``` ps -aux | grep [s]idekiq ``` To avoid such conflicts in the search use process `grep` [`pgrep`](https://linux.die.net/m...
39813212
Looping through the result set
6
2016-10-02 02:08:00
<p>When I run this command:</p> <pre><code>$k = Get-Process | select Name -First 3 </code></pre> <p>I'm getting this output:</p> <pre>Name ---- AESTSr64 ApplicationFrameHost BtwRSupportService</pre> <p>I want to place each result in a separate variable of type string and get its length. I want to know how can I acc...
14,461
1,010,405
2016-10-02 13:32:32
39,814,895
13
2016-10-02 07:39:38
3,735,690
2016-10-02 07:39:38
https://stackoverflow.com/q/39813212
https://stackoverflow.com/a/39814895
<p>you can do it simply :)</p> <pre><code> get-process | select Name, @{Name="NameLength";expression={$_.Name.length}} -first 3 </code></pre> <p>if you want loop on result:</p> <pre><code> $list=get-process | select Name, @{Name="NameLength";expression={$_.Name.length}} -first 3 foreach ($item in $list) { ...
<p>you can do it simply :)</p> <pre><code> get-process | select Name, @{Name="NameLength";expression={$_.Name.length}} -first 3 </code></pre> <p>if you want loop on result:</p> <pre><code> $list=get-process | select Name, @{Name="NameLength";expression={$_.Name.length}} -first 3 foreach ($item in $list) { ...
526
powershell
<h1>Looping through the result set</h1> <p>When I run this command:</p> <pre><code>$k = Get-Process | select Name -First 3 </code></pre> <p>I'm getting this output:</p> <pre>Name ---- AESTSr64 ApplicationFrameHost BtwRSupportService</pre> <p>I want to place each result in a separate variable of type string and get ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,547
bash
# Looping through the result set When I run this command: ``` $k = Get-Process | select Name -First 3 ``` I'm getting this output: ``` Name ---- AESTSr64 ApplicationFrameHost BtwRSupportService ``` I want to place each result in a separate variable of type string and get its length. I want to know how can I access...
you can do it simply :) ``` get-process | select Name, @{Name="NameLength";expression={$_.Name.length}} -first 3 ``` if you want loop on result: ``` $list=get-process | select Name, @{Name="NameLength";expression={$_.Name.length}} -first 3 foreach ($item in $list) { write-host ("{0} {1}" -f $item.Name, $...
37529382
Getting bad flag in substitute command '/' for sed replacement
6
2016-05-30 15:36:12
<p>I am facing one issue while using replace in my sed command. I've a file named <code>a.txt</code>, I want to replace a single line with some other line but I am getting above mentioned error.</p> <p><strong>Code I want to replace:</strong></p> <pre><code>DOMAIN_LOCAL = "http://127.0.0.1:3000"; </code></pre> <p>I ...
13,890
5,436,986
2021-01-13 14:51:10
37,529,462
13
2016-05-30 15:40:58
887,539
2017-03-20 19:37:36
https://stackoverflow.com/q/37529382
https://stackoverflow.com/a/37529462
<p>You will need to use another delimiter. And escape the <code>$</code> or use single quotes: </p> <pre><code>% ip="http://127.1.1.2:3000" % sed 's~DOMAIN_LOCAL = .*$~DOMAIN_LOCAL = "'"$ip"'";~' a.txt DOMAIN_LOCAL = http://127.1.1.2:3000; </code></pre> <p>When you use <code>/</code> as a delimiter in the <code>s</co...
<p>You will need to use another delimiter. And escape the <code>$</code> or use single quotes: </p> <pre><code>% ip="http://127.1.1.2:3000" % sed 's~DOMAIN_LOCAL = .*$~DOMAIN_LOCAL = "'"$ip"'";~' a.txt DOMAIN_LOCAL = http://127.1.1.2:3000; </code></pre> <p>When you use <code>/</code> as a delimiter in the <code>s</co...
387, 5282
bash, sed
<h1>Getting bad flag in substitute command '/' for sed replacement</h1> <p>I am facing one issue while using replace in my sed command. I've a file named <code>a.txt</code>, I want to replace a single line with some other line but I am getting above mentioned error.</p> <p><strong>Code I want to replace:</strong></p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,548
bash
# Getting bad flag in substitute command '/' for sed replacement I am facing one issue while using replace in my sed command. I've a file named `a.txt`, I want to replace a single line with some other line but I am getting above mentioned error. **Code I want to replace:** ``` DOMAIN_LOCAL = "http://127.0.0.1:3000";...
You will need to use another delimiter. And escape the `$` or use single quotes: ``` % ip="http://127.1.1.2:3000" % sed 's~DOMAIN_LOCAL = .*$~DOMAIN_LOCAL = "'"$ip"'";~' a.txt DOMAIN_LOCAL = http://127.1.1.2:3000; ``` When you use `/` as a delimiter in the `s`ubstitute command it will be terminated at the first slash...
35732150
Django Shell image upload _io.BufferedReader no attribute size
6
2016-03-01 19:51:02
<p>My problem is that when I try to save image to my model using Django shell I get this error that I can't find solution anywere.</p> <p>models.py</p> <pre><code>class AdImage(models.Model): ad = models.ForeignKey(Ad) full_photo = models.ImageField(upload_to='uploads/', blank=True) </code></pre> <p>I import m...
7,608
3,412,846
2021-11-04 16:41:26
36,456,327
13
2016-04-06 15:59:32
85,461
2021-11-04 16:41:26
https://stackoverflow.com/q/35732150
https://stackoverflow.com/a/36456327
<p>The <code>FieldFile.save</code> method needs to be called with an instance of <code>django.core.files.File</code>, rather than a built-in python file handle. Change the save invocation to:</p> <pre class="lang-py prettyprint-override"><code>from django.core.files import File imagead.full_photo.save(&quot;NowHiring...
<p>The <code>FieldFile.save</code> method needs to be called with an instance of <code>django.core.files.File</code>, rather than a built-in python file handle. Change the save invocation to:</p> <pre class="lang-py prettyprint-override"><code>from django.core.files import File imagead.full_photo.save(&quot;NowHiring...
16, 243, 390
django, python, shell
<h1>Django Shell image upload _io.BufferedReader no attribute size</h1> <p>My problem is that when I try to save image to my model using Django shell I get this error that I can't find solution anywere.</p> <p>models.py</p> <pre><code>class AdImage(models.Model): ad = models.ForeignKey(Ad) full_photo = models.I...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,549
bash
# Django Shell image upload _io.BufferedReader no attribute size My problem is that when I try to save image to my model using Django shell I get this error that I can't find solution anywere. models.py ``` class AdImage(models.Model): ad = models.ForeignKey(Ad) full_photo = models.ImageField(upload_to='upload...
The `FieldFile.save` method needs to be called with an instance of `django.core.files.File`, rather than a built-in python file handle. Change the save invocation to: ``` from django.core.files import File imagead.full_photo.save("NowHiring.jpg", File(open("C:\\NowHiring.jpg", "rb"))) ``` Django docs reference for [...
34168397
How can I find files with more than one line in them with a given name?
6
2015-12-08 23:58:09
<p><strong>Question:</strong> How can I get all the files with name "interesting-file.txt" that have more than one line in them?</p> <p><strong>Background research:</strong></p> <ul> <li>I can find the files easly with <code>find . -name "interesting-file.txt"</code></li> <li>I believe I need to use some form of <cod...
4,150
863,846
2019-02-13 18:00:55
34,168,510
13
2015-12-09 00:08:42
2,088,135
2019-02-13 18:00:55
https://stackoverflow.com/q/34168397
https://stackoverflow.com/a/34168510
<p>I would go for something like this:</p> <pre><code>find . -name "interesting-file.txt" -exec awk 'END { if (NR &gt; 1) print FILENAME }' {} \; </code></pre> <p>All the files that are found are passed to awk, which prints the name if the number of lines <code>NR</code> is greater than 1.</p> <p>With GNU awk you ca...
<p>I would go for something like this:</p> <pre><code>find . -name "interesting-file.txt" -exec awk 'END { if (NR &gt; 1) print FILENAME }' {} \; </code></pre> <p>All the files that are found are passed to awk, which prints the name if the number of lines <code>NR</code> is greater than 1.</p> <p>With GNU awk you ca...
58, 387, 1231
bash, command-line, linux
<h1>How can I find files with more than one line in them with a given name?</h1> <p><strong>Question:</strong> How can I get all the files with name "interesting-file.txt" that have more than one line in them?</p> <p><strong>Background research:</strong></p> <ul> <li>I can find the files easly with <code>find . -name...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,550
bash
# How can I find files with more than one line in them with a given name? **Question:** How can I get all the files with name "interesting-file.txt" that have more than one line in them? **Background research:** - I can find the files easly with `find . -name "interesting-file.txt"` - I believe I need to use some fo...
I would go for something like this: ``` find . -name "interesting-file.txt" -exec awk 'END { if (NR > 1) print FILENAME }' {} \; ``` All the files that are found are passed to awk, which prints the name if the number of lines `NR` is greater than 1. With GNU awk you can take advantage of the `ENDFILE` block and use ...
34165464
Adding text after variable expansion - Fish
6
2015-12-08 20:32:14
<p>I want to add text after variable expansion, but fish thinks I'm referring to a different variable name e.g.</p> <pre><code>$ set dessert "cake" $ echo $dessert cake $ echo "I want 7 $desserts" I want 7 $ cat ./menu.txt | sed "s/$desserts/cookie/g" sed: first RE may not be empty </code></pre>
3,185
3,657,151
2015-12-08 22:17:40
34,165,593
13
2015-12-08 20:39:09
5,590,742
2015-12-08 22:17:40
https://stackoverflow.com/q/34165464
https://stackoverflow.com/a/34165593
<p>Looks like you want to put curly brackets around your vaiable, like "{$dessert}s." Example:</p> <pre><code>&gt; set xyz blarch &gt; echo $xyz blarch &gt; echo ${xyz} Variables cannot be bracketed. In fish, please use {$xyz}. fish: echo ${xyz} ^ &gt; echo {$xyz} blarch &gt; echo i like {$xyz}s i like bla...
<p>Looks like you want to put curly brackets around your vaiable, like "{$dessert}s." Example:</p> <pre><code>&gt; set xyz blarch &gt; echo $xyz blarch &gt; echo ${xyz} Variables cannot be bracketed. In fish, please use {$xyz}. fish: echo ${xyz} ^ &gt; echo {$xyz} blarch &gt; echo i like {$xyz}s i like bla...
390, 55824
fish, shell
<h1>Adding text after variable expansion - Fish</h1> <p>I want to add text after variable expansion, but fish thinks I'm referring to a different variable name e.g.</p> <pre><code>$ set dessert "cake" $ echo $dessert cake $ echo "I want 7 $desserts" I want 7 $ cat ./menu.txt | sed "s/$desserts/cookie/g" sed: first RE...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,551
bash
# Adding text after variable expansion - Fish I want to add text after variable expansion, but fish thinks I'm referring to a different variable name e.g. ``` $ set dessert "cake" $ echo $dessert cake $ echo "I want 7 $desserts" I want 7 $ cat ./menu.txt | sed "s/$desserts/cookie/g" sed: first RE may not be empty ``...
Looks like you want to put curly brackets around your vaiable, like "{$dessert}s." Example: ``` > set xyz blarch > echo $xyz blarch > echo ${xyz} Variables cannot be bracketed. In fish, please use {$xyz}. fish: echo ${xyz} ^ > echo {$xyz} blarch > echo i like {$xyz}s i like blarchs > ``` edit 2: Hmm... bo...
33236703
Group-Object in powershell, select first item in each group
6
2015-10-20 12:28:47
<p>Given the following script.</p> <pre><code>$module = # get path $code = get-childitem $module -recurse -include *.dll $list = $code | group-object -Property Name $list </code></pre> <p>I retreive the following:</p> <pre><code>Count Name Group ...
8,962
231,821
2015-10-20 12:40:11
33,236,942
13
2015-10-20 12:40:11
1,358
2015-10-20 12:40:11
https://stackoverflow.com/q/33236703
https://stackoverflow.com/a/33236942
<p>If I understand correctly, this should do it:</p> <pre><code>$list | %{$_.Group[0].FullName} </code></pre>
<p>If I understand correctly, this should do it:</p> <pre><code>$list | %{$_.Group[0].FullName} </code></pre>
526
powershell
<h1>Group-Object in powershell, select first item in each group</h1> <p>Given the following script.</p> <pre><code>$module = # get path $code = get-childitem $module -recurse -include *.dll $list = $code | group-object -Property Name $list </code></pre> <p>I retreive the following:</p> <pre><code>Count Name ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,552
bash
# Group-Object in powershell, select first item in each group Given the following script. ``` $module = # get path $code = get-childitem $module -recurse -include *.dll $list = $code | group-object -Property Name $list ``` I retreive the following: ``` Count Name Group ...
If I understand correctly, this should do it: ``` $list | %{$_.Group[0].FullName} ```
33063673
Bash script to backup data to google drive
6
2015-10-11 09:53:17
<p>I want to create a bash script that will log into my google drive account and backup my main folder. I've done a bit of research and I know we need some sort of OAuth for using the Google Drive API but I'm still fairly new so I thought I can get some solid guidance from the stack community.</p>
25,040
2,582,622
2019-11-12 02:44:15
33,063,790
13
2015-10-11 10:07:28
797,495
2019-11-12 02:44:15
https://stackoverflow.com/q/33063673
https://stackoverflow.com/a/33063790
<p>I guess you don't need to re-invent the wheel, use <a href="https://github.com/prasmussen/gdrive#downloads" rel="nofollow noreferrer">gdrive</a> and you're good to go</p> <p><strong>SETUP:</strong></p> <pre><code>wget -O drive "https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg" mv drive /usr/sbin/drive...
<p>I guess you don't need to re-invent the wheel, use <a href="https://github.com/prasmussen/gdrive#downloads" rel="nofollow noreferrer">gdrive</a> and you're good to go</p> <p><strong>SETUP:</strong></p> <pre><code>wget -O drive "https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg" mv drive /usr/sbin/drive...
387, 390, 90589
bash, google-drive-realtime-api, shell
<h1>Bash script to backup data to google drive</h1> <p>I want to create a bash script that will log into my google drive account and backup my main folder. I've done a bit of research and I know we need some sort of OAuth for using the Google Drive API but I'm still fairly new so I thought I can get some solid guidance...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,553
bash
# Bash script to backup data to google drive I want to create a bash script that will log into my google drive account and backup my main folder. I've done a bit of research and I know we need some sort of OAuth for using the Google Drive API but I'm still fairly new so I thought I can get some solid guidance from the...
I guess you don't need to re-invent the wheel, use [gdrive](https://github.com/prasmussen/gdrive#downloads) and you're good to go **SETUP:** ``` wget -O drive "https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg" mv drive /usr/sbin/drive chmod 755 /usr/sbin/drive ``` Now, simply run `drive` to start the ...
30820894
Remove duplicates from text file based on second text file
6
2015-06-13 16:23:36
<p>How can I remove all lines from a text file (<code>main.txt</code>) by checking a second textfile (<code>removethese.txt</code>). What is an <strong>efficient approach</strong> if files are greater than 10-100mb. [Using mac]</p> <h3>Example:</h3> <pre><code>main.txt 3 1 2 5 </code></pre> <p>Remove these lines</p> <p...
4,990
4,399,243
2015-06-21 13:32:00
30,863,875
13
2015-06-16 09:36:44
1,983,854
2015-06-16 09:36:44
https://stackoverflow.com/q/30820894
https://stackoverflow.com/a/30863875
<p>There are two standard ways to do this:</p> <p>With <code>grep</code>:</p> <pre><code>grep -vxFf removethese main </code></pre> <p>This uses:</p> <ul> <li><code>-v</code> to invert the match.</li> <li><code>-x</code> match whole line, to prevent, for example, <code>he</code> to match lines like <code>hello</code...
<p>There are two standard ways to do this:</p> <p>With <code>grep</code>:</p> <pre><code>grep -vxFf removethese main </code></pre> <p>This uses:</p> <ul> <li><code>-v</code> to invert the match.</li> <li><code>-x</code> match whole line, to prevent, for example, <code>he</code> to match lines like <code>hello</code...
18, 34, 387, 1469, 5025
bash, editor, regex, text, unix
<h1>Remove duplicates from text file based on second text file</h1> <p>How can I remove all lines from a text file (<code>main.txt</code>) by checking a second textfile (<code>removethese.txt</code>). What is an <strong>efficient approach</strong> if files are greater than 10-100mb. [Using mac]</p> <h3>Example:</h3> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,554
bash
# Remove duplicates from text file based on second text file How can I remove all lines from a text file (`main.txt`) by checking a second textfile (`removethese.txt`). What is an **efficient approach** if files are greater than 10-100mb. [Using mac] ### Example: ``` main.txt 3 1 2 5 ``` Remove these lines ``` rem...
There are two standard ways to do this: With `grep`: ``` grep -vxFf removethese main ``` This uses: - `-v` to invert the match. - `-x` match whole line, to prevent, for example, `he` to match lines like `hello` or `highway to hell`. - `-F` to use fixed strings, so that the parameter is taken as it is, not interpret...
30488308
get-website/get-webapplication associated directory
6
2015-05-27 16:34:26
<p>If I wanted to find the directory associated with an IIS site or application, how would I do that? </p> <p>I cannot seem to find anything on any properties of objects from <code>Get-Website</code> and <code>Get-WebApplication</code> that allow me to do so.</p>
8,493
1,054,637
2015-05-27 18:04:23
30,488,916
13
2015-05-27 17:05:09
66,169
2015-05-27 17:05:09
https://stackoverflow.com/q/30488308
https://stackoverflow.com/a/30488916
<p>Just look at the members of a web site:</p> <pre><code>get-website -Name "Default Web Site" | Get-Member </code></pre> <p>returns:</p> <pre><code>... password NoteProperty System.String password= physicalPath NoteProperty System.String physicalPath=%SystemDrive%\i...
<p>Just look at the members of a web site:</p> <pre><code>get-website -Name "Default Web Site" | Get-Member </code></pre> <p>returns:</p> <pre><code>... password NoteProperty System.String password= physicalPath NoteProperty System.String physicalPath=%SystemDrive%\i...
215, 526
iis, powershell
<h1>get-website/get-webapplication associated directory</h1> <p>If I wanted to find the directory associated with an IIS site or application, how would I do that? </p> <p>I cannot seem to find anything on any properties of objects from <code>Get-Website</code> and <code>Get-WebApplication</code> that allow me to do so...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,555
bash
# get-website/get-webapplication associated directory If I wanted to find the directory associated with an IIS site or application, how would I do that? I cannot seem to find anything on any properties of objects from `Get-Website` and `Get-WebApplication` that allow me to do so.
Just look at the members of a web site: ``` get-website -Name "Default Web Site" | Get-Member ``` returns: ``` ... password NoteProperty System.String password= physicalPath NoteProperty System.String physicalPath=%SystemDrive%\inetpub\wwwroot serverAutoStart ...
28580041
Run cmd.exe from PowerShell
6
2015-02-18 09:29:50
<p>I am trying to run some unit tests using PowerShell. I have a command that (sort of) works:</p> <pre><code>$output = &amp; $vsTestPath $TestAssembly $logger $TestCaseFilter 2&gt;&amp;1 </code></pre> <p>The problem with this is that the standard out and standard error streams don't come out in the right order - the...
50,679
1,158,174
2018-09-11 19:50:33
28,587,233
13
2015-02-18 15:26:37
4,003,407
2018-09-11 19:50:33
https://stackoverflow.com/q/28580041
https://stackoverflow.com/a/28587233
<p>When you run this PowerShell command,</p> <pre><code>&amp; cmd.exe /c $vsTestPath $TestAssembly 2`&gt;`&amp;1 </code></pre> <p>PowerShell produces this command line:</p> <pre><code>cmd.exe /c "C:\Program Files (x86)\BlaBlaBla.exe" "C:\IntegrationTesting\Test Application\BlaBlaBla.dll" 2&gt;&amp;1 </code></pre> <...
<p>When you run this PowerShell command,</p> <pre><code>&amp; cmd.exe /c $vsTestPath $TestAssembly 2`&gt;`&amp;1 </code></pre> <p>PowerShell produces this command line:</p> <pre><code>cmd.exe /c "C:\Program Files (x86)\BlaBlaBla.exe" "C:\IntegrationTesting\Test Application\BlaBlaBla.dll" 2&gt;&amp;1 </code></pre> <...
526, 2631
cmd, powershell
<h1>Run cmd.exe from PowerShell</h1> <p>I am trying to run some unit tests using PowerShell. I have a command that (sort of) works:</p> <pre><code>$output = &amp; $vsTestPath $TestAssembly $logger $TestCaseFilter 2&gt;&amp;1 </code></pre> <p>The problem with this is that the standard out and standard error streams do...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,556
bash
# Run cmd.exe from PowerShell I am trying to run some unit tests using PowerShell. I have a command that (sort of) works: ``` $output = & $vsTestPath $TestAssembly $logger $TestCaseFilter 2>&1 ``` The problem with this is that the standard out and standard error streams don't come out in the right order - they get m...
When you run this PowerShell command, ``` & cmd.exe /c $vsTestPath $TestAssembly 2`>`&1 ``` PowerShell produces this command line: ``` cmd.exe /c "C:\Program Files (x86)\BlaBlaBla.exe" "C:\IntegrationTesting\Test Application\BlaBlaBla.dll" 2>&1 ``` PowerShell encloses values of `$vsTestPath` and `$TestAssembly` in ...
28072190
Sed error "\1 not defined in the RE" on MacOSX 10.9.5
6
2015-01-21 16:31:00
<p>I am trying to build a generic formatter for my MP3 file names (very important) with bash, and a large part of this is being able to move text around using regex variables. For example I am trying to remove the parentheses () from around the ft. Kevin Parker.</p> <pre><code>oldfilename="Mark Ronson - 02 Summer Brea...
9,218
158,815
2015-01-21 16:51:34
28,072,266
13
2015-01-21 16:35:54
15,168
2015-01-21 16:51:34
https://stackoverflow.com/q/28072190
https://stackoverflow.com/a/28072266
<p>If you use <code>-E</code>, then <code>\(</code> and <code>\)</code> are actual parentheses; to capture, you'd use just <code>(</code> and <code>)</code>. Here, you want to remove parentheses, so you need to match a literal <code>(</code>, capture the content up to the next <code>)</code> and match but not capture ...
<p>If you use <code>-E</code>, then <code>\(</code> and <code>\)</code> are actual parentheses; to capture, you'd use just <code>(</code> and <code>)</code>. Here, you want to remove parentheses, so you need to match a literal <code>(</code>, capture the content up to the next <code>)</code> and match but not capture ...
18, 369, 387, 5282
bash, macos, regex, sed
<h1>Sed error "\1 not defined in the RE" on MacOSX 10.9.5</h1> <p>I am trying to build a generic formatter for my MP3 file names (very important) with bash, and a large part of this is being able to move text around using regex variables. For example I am trying to remove the parentheses () from around the ft. Kevin Pa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,557
bash
# Sed error "\1 not defined in the RE" on MacOSX 10.9.5 I am trying to build a generic formatter for my MP3 file names (very important) with bash, and a large part of this is being able to move text around using regex variables. For example I am trying to remove the parentheses () from around the ft. Kevin Parker. ``...
If you use `-E`, then `\(` and `\)` are actual parentheses; to capture, you'd use just `(` and `)`. Here, you want to remove parentheses, so you need to match a literal `(`, capture the content up to the next `)` and match but not capture the close `)`, and replace the whole lot with just the capture: ``` newfilename=...
26403064
Continue while from nested for-loop
6
2014-10-16 11:17:34
<p>I have the following loop structure:</p> <pre><code>while ($reader.Read() -eq $true) { $row = @{} for ($i = 0; $i -lt $reader.FieldCount; $i++) { if(something...) { #continue with while } } #do more stuff... } </code></pre> <p>Now, is there any way ...
10,054
1,537,195
2016-12-10 19:46:26
26,407,255
13
2014-10-16 14:43:20
4,137,916
2014-10-16 15:31:44
https://stackoverflow.com/q/26403064
https://stackoverflow.com/a/26407255
<p>Factoring out the inner loop to a function could improve readability, depending on how tangled up your variables are.</p> <pre class="lang-cs prettyprint-override"><code>function processRow($reader) { $row = @{} for ($i = 0; $i -lt $reader.FieldCount; $i++) { if(-not something...) { return $null...
<p>Factoring out the inner loop to a function could improve readability, depending on how tangled up your variables are.</p> <pre class="lang-cs prettyprint-override"><code>function processRow($reader) { $row = @{} for ($i = 0; $i -lt $reader.FieldCount; $i++) { if(-not something...) { return $null...
526, 2314
loops, powershell
<h1>Continue while from nested for-loop</h1> <p>I have the following loop structure:</p> <pre><code>while ($reader.Read() -eq $true) { $row = @{} for ($i = 0; $i -lt $reader.FieldCount; $i++) { if(something...) { #continue with while } } #do more stuff... ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,558
bash
# Continue while from nested for-loop I have the following loop structure: ``` while ($reader.Read() -eq $true) { $row = @{} for ($i = 0; $i -lt $reader.FieldCount; $i++) { if(something...) { #continue with while } } #do more stuff... } ``` Now, is th...
Factoring out the inner loop to a function could improve readability, depending on how tangled up your variables are. ``` function processRow($reader) { $row = @{} for ($i = 0; $i -lt $reader.FieldCount; $i++) { if(-not something...) { return $null } # process row } $row } while ($...
24628996
Powershell replace double quotes with single in a string
6
2014-07-08 10:02:30
<p>I just can't get it right</p> <p>The below statement throws an exception and I cannot get the correct format </p> <pre><code>$appendedQry = $appendedQry -replace "\"","'" </code></pre> <p>What would be the correct syntax?</p>
24,115
2,078,685
2017-10-18 07:07:36
24,629,190
13
2014-07-08 10:12:35
2,078,685
2014-07-08 10:12:35
https://stackoverflow.com/q/24628996
https://stackoverflow.com/a/24629190
<p>It should be</p> <pre><code>$appendedQry = $appendedQry -replace '"','''' </code></pre>
<p>It should be</p> <pre><code>$appendedQry = $appendedQry -replace '"','''' </code></pre>
526
powershell
<h1>Powershell replace double quotes with single in a string</h1> <p>I just can't get it right</p> <p>The below statement throws an exception and I cannot get the correct format </p> <pre><code>$appendedQry = $appendedQry -replace "\"","'" </code></pre> <p>What would be the correct syntax?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,559
bash
# Powershell replace double quotes with single in a string I just can't get it right The below statement throws an exception and I cannot get the correct format ``` $appendedQry = $appendedQry -replace "\"","'" ``` What would be the correct syntax?
It should be ``` $appendedQry = $appendedQry -replace '"','''' ```
23042428
How do I dynamically set the type of PowerShell variables?
6
2014-04-13 11:54:22
<p>Is it possible to get a System.Type from a string and then apply it to a variable?</p> <p>The following is the function that I tried to convert to make it safer (i.e. not involve invoking a string):</p> <pre><code>Function ParseLine($Type, $VariableName, $Value){ Invoke-Expression "[$Type] `$$VariableName = $V...
7,412
851,118
2017-01-13 15:43:36
23,045,679
13
2014-04-13 17:08:30
574,168
2017-01-13 15:43:36
https://stackoverflow.com/q/23042428
https://stackoverflow.com/a/23045679
<p>You can cast variables to a specific type using the <code>-as</code> operator:</p> <pre><code>Function ParseLine($Type, $VariableName, $Value){ Set-Variable $VariableName -Scope 1 -Value ($Value -as ($Type -as [type])) } </code></pre> <p>That will use <code>-as</code> to create a type from the <code>$Type</cod...
<p>You can cast variables to a specific type using the <code>-as</code> operator:</p> <pre><code>Function ParseLine($Type, $VariableName, $Value){ Set-Variable $VariableName -Scope 1 -Value ($Value -as ($Type -as [type])) } </code></pre> <p>That will use <code>-as</code> to create a type from the <code>$Type</cod...
526
powershell
<h1>How do I dynamically set the type of PowerShell variables?</h1> <p>Is it possible to get a System.Type from a string and then apply it to a variable?</p> <p>The following is the function that I tried to convert to make it safer (i.e. not involve invoking a string):</p> <pre><code>Function ParseLine($Type, $Variab...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,560
bash
# How do I dynamically set the type of PowerShell variables? Is it possible to get a System.Type from a string and then apply it to a variable? The following is the function that I tried to convert to make it safer (i.e. not involve invoking a string): ``` Function ParseLine($Type, $VariableName, $Value){ Invoke...
You can cast variables to a specific type using the `-as` operator: ``` Function ParseLine($Type, $VariableName, $Value){ Set-Variable $VariableName -Scope 1 -Value ($Value -as ($Type -as [type])) } ``` That will use `-as` to create a type from the `$Type` string, and then use that to cast `$Value`. I am not sur...
22102976
Set a Rails environment variable locally (Mac OS X)
6
2014-02-28 18:24:40
<p>I'm trying to set environment variables in Rails. I'm following these docs: <a href="http://railsapps.github.io/rails-environment-variables.html" rel="noreferrer">http://railsapps.github.io/rails-environment-variables.html</a></p> <p>One option it gives is to save environment variables in your <code>~/.bashrc</code...
4,068
1,001,938
2014-02-28 18:36:21
22,103,105
13
2014-02-28 18:32:34
1,377,943
2014-02-28 18:32:34
https://stackoverflow.com/q/22102976
https://stackoverflow.com/a/22103105
<p>I dont know which shell you are using. In case of <code>bash</code> , you can write this in your <code>~/.bashrc</code> file </p> <pre><code>export GMAIL_USERNAME=abc@bah.com </code></pre> <p>then do this in terminal </p> <pre><code> source ~/.bashrc </code></pre> <p>Now, check it console . I am sure it will be ...
<p>I dont know which shell you are using. In case of <code>bash</code> , you can write this in your <code>~/.bashrc</code> file </p> <pre><code>export GMAIL_USERNAME=abc@bah.com </code></pre> <p>then do this in terminal </p> <pre><code> source ~/.bashrc </code></pre> <p>Now, check it console . I am sure it will be ...
369, 387, 4984, 46495, 85786
bash, macos, ruby-on-rails, ruby-on-rails-4, rvm
<h1>Set a Rails environment variable locally (Mac OS X)</h1> <p>I'm trying to set environment variables in Rails. I'm following these docs: <a href="http://railsapps.github.io/rails-environment-variables.html" rel="noreferrer">http://railsapps.github.io/rails-environment-variables.html</a></p> <p>One option it gives i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,561
bash
# Set a Rails environment variable locally (Mac OS X) I'm trying to set environment variables in Rails. I'm following these docs: <http://railsapps.github.io/rails-environment-variables.html> One option it gives is to save environment variables in your `~/.bashrc`, using this syntax: ``` export GMAIL_USERNAME="mynam...
I dont know which shell you are using. In case of `bash` , you can write this in your `~/.bashrc` file ``` export GMAIL_USERNAME=abc@bah.com ``` then do this in terminal ``` source ~/.bashrc ``` Now, check it console . I am sure it will be there .
20903988
Unix command to search and replace text recursively
6
2014-01-03 12:44:20
<p>I am looking for a UNIX command that helps me to search for a text from all the files in a folder recursively and replace it with new value. After searching in internet I came across this command which worked for me.</p> <blockquote> <p>find ./myFolder -type f -print0 | xargs -0 sed -i 's/Application/whatever/g'<...
12,649
2,065,083
2020-06-25 20:15:19
20,904,020
13
2014-01-03 12:46:35
548,225
2016-07-18 12:38:29
https://stackoverflow.com/q/20903988
https://stackoverflow.com/a/20904020
<blockquote> <p><code>Also are there any alternate commands that provides same functionality in Unix</code></p> </blockquote> <p>Yes you can do all this in find itself:</p> <pre><code>find ./myFolder -type f -exec sed -i 's/Application/whatever/g' '{}' \; </code></pre> <p><code>-exec</code> option in <code>find</c...
<blockquote> <p><code>Also are there any alternate commands that provides same functionality in Unix</code></p> </blockquote> <p>Yes you can do all this in find itself:</p> <pre><code>find ./myFolder -type f -exec sed -i 's/Application/whatever/g' '{}' \; </code></pre> <p><code>-exec</code> option in <code>find</c...
18, 387, 390, 578, 5282
bash, recursion, regex, sed, shell
<h1>Unix command to search and replace text recursively</h1> <p>I am looking for a UNIX command that helps me to search for a text from all the files in a folder recursively and replace it with new value. After searching in internet I came across this command which worked for me.</p> <blockquote> <p>find ./myFolder ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,562
bash
# Unix command to search and replace text recursively I am looking for a UNIX command that helps me to search for a text from all the files in a folder recursively and replace it with new value. After searching in internet I came across this command which worked for me. > find ./myFolder -type f -print0 | xargs -0 se...
> `Also are there any alternate commands that provides same functionality in Unix` Yes you can do all this in find itself: ``` find ./myFolder -type f -exec sed -i 's/Application/whatever/g' '{}' \; ``` `-exec` option in `find` is for: > `-exec utility [argument ...] ;` > True if the program named utility returns...
20836612
What does ${1-1} in bash mean?
6
2013-12-30 09:20:05
<p>I'm reading the scripts from <a href="https://github.com/NapoleonWils0n/bashfinder/blob/master/.bash_macosx" rel="noreferrer">here</a> and trying to understand what's going on. This function performs changing the directory of a Finder window:</p> <pre><code>function ee { osascript -e 'set cwd to do shell script "...
6,563
1,867,715
2022-10-18 23:39:40
20,836,686
13
2013-12-30 09:25:06
551,045
2022-10-18 23:39:40
https://stackoverflow.com/q/20836612
https://stackoverflow.com/a/20836686
<p>This means that if argument 1 (<code>${1}</code>) is not set, it will be set to 1.</p> <p>See <a href="http://tldp.org/LDP/abs/html/parameter-substitution.html" rel="nofollow noreferrer">parameter substitution here</a>.</p> <pre><code> ${parameter-default}, ${parameter:-default} If parameter not set, use default....
<p>This means that if argument 1 (<code>${1}</code>) is not set, it will be set to 1.</p> <p>See <a href="http://tldp.org/LDP/abs/html/parameter-substitution.html" rel="nofollow noreferrer">parameter substitution here</a>.</p> <pre><code> ${parameter-default}, ${parameter:-default} If parameter not set, use default....
387, 15718
bash, osascript
<h1>What does ${1-1} in bash mean?</h1> <p>I'm reading the scripts from <a href="https://github.com/NapoleonWils0n/bashfinder/blob/master/.bash_macosx" rel="noreferrer">here</a> and trying to understand what's going on. This function performs changing the directory of a Finder window:</p> <pre><code>function ee { os...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,563
bash
# What does ${1-1} in bash mean? I'm reading the scripts from [here](https://github.com/NapoleonWils0n/bashfinder/blob/master/.bash_macosx) and trying to understand what's going on. This function performs changing the directory of a Finder window: ``` function ee { osascript -e 'set cwd to do shell script "pwd"'\ ...
This means that if argument 1 (`${1}`) is not set, it will be set to 1. See [parameter substitution here](http://tldp.org/LDP/abs/html/parameter-substitution.html). ``` ${parameter-default}, ${parameter:-default} If parameter not set, use default. ```
20269202
Remove files from .zip file with Powershell
6
2013-11-28 14:58:40
<p>I am going to write a Powershell script to remove files from a .zip file. In my .zip file, I have test.txt (latest) test1.txt (older) test2.txt .... testN.txt (oldest), all with different file sizes (or in powershell, it's called Length). I want to keep only 2G or smaller of them and remove the rest. It is r...
16,436
1,970,698
2016-11-17 21:53:11
20,276,205
13
2013-11-28 23:31:59
1,630,171
2016-11-17 21:53:11
https://stackoverflow.com/q/20269202
https://stackoverflow.com/a/20276205
<p>Adopting <a href="https://stackoverflow.com/a/20147320/1630171">this VBScript solution</a>:</p> <pre class="lang-psh prettyprint-override"><code>$zipfile = 'C:\path\to\your.zip' $files = 'some.file', 'other.file', ... $dst = 'C:\some\folder' $app = New-Object -COM 'Shell.Application' $app.NameSpace($zipfile)...
<p>Adopting <a href="https://stackoverflow.com/a/20147320/1630171">this VBScript solution</a>:</p> <pre class="lang-psh prettyprint-override"><code>$zipfile = 'C:\path\to\your.zip' $files = 'some.file', 'other.file', ... $dst = 'C:\some\folder' $app = New-Object -COM 'Shell.Application' $app.NameSpace($zipfile)...
526
powershell
<h1>Remove files from .zip file with Powershell</h1> <p>I am going to write a Powershell script to remove files from a .zip file. In my .zip file, I have test.txt (latest) test1.txt (older) test2.txt .... testN.txt (oldest), all with different file sizes (or in powershell, it's called Length). I want to keep on...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,564
bash
# Remove files from .zip file with Powershell I am going to write a Powershell script to remove files from a .zip file. In my .zip file, I have test.txt (latest) test1.txt (older) test2.txt .... testN.txt (oldest), all with different file sizes (or in powershell, it's called Length). I want to keep only 2G or smaller ...
Adopting [this VBScript solution](https://stackoverflow.com/a/20147320/1630171): ``` $zipfile = 'C:\path\to\your.zip' $files = 'some.file', 'other.file', ... $dst = 'C:\some\folder' $app = New-Object -COM 'Shell.Application' $app.NameSpace($zipfile).Items() | ? { $files -contains $_.Name } | % { $app.Namespac...
19585305
Why does python subprocess zip fail but running at shell works?
6
2013-10-25 08:50:52
<p>I'm on Mac OS X using Python 2.7; using <code>subprocess.call</code> with <code>zip</code> fails yet running the <em>same command</em> at the shell succeeds. Here's a copy of my terminal:</p> <pre><code>$ python Python 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-4...
5,663
9,642
2018-01-18 19:53:52
19,585,362
13
2013-10-25 08:53:30
100,297
2013-10-25 08:53:30
https://stackoverflow.com/q/19585305
https://stackoverflow.com/a/19585362
<p>Because running a command in the shell is not the same thing as running it with <code>subprocess.call()</code>; the shell expanded the <code>example/*</code> wildcard.</p> <p>Either expand the list of files with <code>os.listdir()</code> or the <code>glob</code> module yourself, or run the command through the shell...
<p>Because running a command in the shell is not the same thing as running it with <code>subprocess.call()</code>; the shell expanded the <code>example/*</code> wildcard.</p> <p>Either expand the list of files with <code>os.listdir()</code> or the <code>glob</code> module yourself, or run the command through the shell...
16, 390, 881
python, shell, zip
<h1>Why does python subprocess zip fail but running at shell works?</h1> <p>I'm on Mac OS X using Python 2.7; using <code>subprocess.call</code> with <code>zip</code> fails yet running the <em>same command</em> at the shell succeeds. Here's a copy of my terminal:</p> <pre><code>$ python Python 2.7.2 (default, Oct 11 2...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,565
bash
# Why does python subprocess zip fail but running at shell works? I'm on Mac OS X using Python 2.7; using `subprocess.call` with `zip` fails yet running the *same command* at the shell succeeds. Here's a copy of my terminal: ``` $ python Python 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang...
Because running a command in the shell is not the same thing as running it with `subprocess.call()`; the shell expanded the `example/*` wildcard. Either expand the list of files with `os.listdir()` or the `glob` module yourself, or run the command through the shell from Python; with the `shell=True` argument to `subpr...
19275530
Timeout issue in Backup-SQLDatabase cmdlet
6
2013-10-09 14:55:33
<p>I’m trying to take back-up of a large database using “Backup-SQLDatabase” cmdlet using following statement, but I’m getting time-out error after 10 minutes.</p> <pre><code>{Backup-SqlDatabase -ServerInstance $Server -Database $DatabaseName -BackupFile $BackUpFile -CompressionOption On -ConnectionTimeout 0 -Initiali...
5,948
1,495,361
2013-10-10 07:21:51
19,289,484
13
2013-10-10 07:21:51
1,495,361
2013-10-10 07:21:51
https://stackoverflow.com/q/19275530
https://stackoverflow.com/a/19289484
<p>I did some research on this and came around the following workaround : </p> <p><code>$serverConn = new-object ("Microsoft.SqlServer.Management.Smo.Server") $server $serverConn.ConnectionContext.StatementTimeout = 0</code></p> <pre><code>Backup-SqlDatabase -InputObject $serverConn -Database abc -BackupFile "L:\123\...
<p>I did some research on this and came around the following workaround : </p> <p><code>$serverConn = new-object ("Microsoft.SqlServer.Management.Smo.Server") $server $serverConn.ConnectionContext.StatementTimeout = 0</code></p> <pre><code>Backup-SqlDatabase -InputObject $serverConn -Database abc -BackupFile "L:\123\...
72, 493, 526, 3123
backup, powershell, smo, sql-server
<h1>Timeout issue in Backup-SQLDatabase cmdlet</h1> <p>I’m trying to take back-up of a large database using “Backup-SQLDatabase” cmdlet using following statement, but I’m getting time-out error after 10 minutes.</p> <pre><code>{Backup-SqlDatabase -ServerInstance $Server -Database $DatabaseName -BackupFile $BackUpFile ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,566
bash
# Timeout issue in Backup-SQLDatabase cmdlet I’m trying to take back-up of a large database using “Backup-SQLDatabase” cmdlet using following statement, but I’m getting time-out error after 10 minutes. ``` {Backup-SqlDatabase -ServerInstance $Server -Database $DatabaseName -BackupFile $BackUpFile -CompressionOption O...
I did some research on this and came around the following workaround : `$serverConn = new-object ("Microsoft.SqlServer.Management.Smo.Server") $server $serverConn.ConnectionContext.StatementTimeout = 0` ``` Backup-SqlDatabase -InputObject $serverConn -Database abc -BackupFile "L:\123\abc.bak" ``` When we pass Server...
17025450
Get latest dates from an array per object group in Powershell
6
2013-06-10 13:47:39
<p>I have an array <em>$data</em> :</p> <pre><code>PS&gt; $data Datum User Computer ----- --------- -------- 10/06/2013 13:10:56 geb1@TESTDOMAIN.COM DC1$ ...
26,357
1,816,781
2013-06-10 14:37:36
17,025,874
13
2013-06-10 14:09:34
9,833
2013-06-10 14:09:34
https://stackoverflow.com/q/17025450
https://stackoverflow.com/a/17025874
<pre><code>$data | Foreach-Object {$_.Datum = [DateTime]$_.Datum; $_} | Group-Object Computer | Foreach-Object {$_.Group | Sort-Object Datum | Select-Object -Last 1} </code></pre>
<pre><code>$data | Foreach-Object {$_.Datum = [DateTime]$_.Datum; $_} | Group-Object Computer | Foreach-Object {$_.Group | Sort-Object Datum | Select-Object -Last 1} </code></pre>
114, 526, 1263, 39333
arrays, datetime, greatest-n-per-group, powershell
<h1>Get latest dates from an array per object group in Powershell</h1> <p>I have an array <em>$data</em> :</p> <pre><code>PS&gt; $data Datum User Computer ----- --------- -------- ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,567
bash
# Get latest dates from an array per object group in Powershell I have an array *$data* : ``` PS> $data Datum User Computer ----- --------- -------- 10/06/2013 13:10:56 geb1@...
``` $data | Foreach-Object {$_.Datum = [DateTime]$_.Datum; $_} | Group-Object Computer | Foreach-Object {$_.Group | Sort-Object Datum | Select-Object -Last 1} ```
17021770
move line which matches pattern to previous line
6
2013-06-10 10:29:27
<p>I have a file with structure </p> <pre><code>12312 desc: bleh... 9938 desc: blah... desc: bloh... desc: blih... desc: bluh... 9912 desc: blah... </code></pre> <p>and i want to move line which matches pattern "desc:" to previous line or delete '\n' in line which goes before every pattern "desc:".</p> <p>desired ou...
6,866
2,394,449
2021-04-21 22:30:30
17,022,177
13
2013-06-10 10:52:27
2,428,361
2013-06-10 10:52:27
https://stackoverflow.com/q/17021770
https://stackoverflow.com/a/17022177
<p><code>sed</code> oneliner</p> <pre><code>sed ':a $!N;s/\ndesc/ desc/;ta P;D' </code></pre> <p>Will output</p> <pre><code>12312 desc: bleh... 9938 desc: blah... desc: bloh... desc: blih... desc: bluh... 9912 desc: blah... </code></pre>
<p><code>sed</code> oneliner</p> <pre><code>sed ':a $!N;s/\ndesc/ desc/;ta P;D' </code></pre> <p>Will output</p> <pre><code>12312 desc: bleh... 9938 desc: blah... desc: bloh... desc: blih... desc: bluh... 9912 desc: blah... </code></pre>
387, 990, 5282
awk, bash, sed
<h1>move line which matches pattern to previous line</h1> <p>I have a file with structure </p> <pre><code>12312 desc: bleh... 9938 desc: blah... desc: bloh... desc: blih... desc: bluh... 9912 desc: blah... </code></pre> <p>and i want to move line which matches pattern "desc:" to previous line or delete '\n' in line w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,568
bash
# move line which matches pattern to previous line I have a file with structure ``` 12312 desc: bleh... 9938 desc: blah... desc: bloh... desc: blih... desc: bluh... 9912 desc: blah... ``` and i want to move line which matches pattern "desc:" to previous line or delete '\n' in line which goes before every pattern "de...
`sed` oneliner ``` sed ':a $!N;s/\ndesc/ desc/;ta P;D' ``` Will output ``` 12312 desc: bleh... 9938 desc: blah... desc: bloh... desc: blih... desc: bluh... 9912 desc: blah... ```
17015137
OSX sed: how to use the escape character in the second field of a `s` operation?
6
2013-06-09 23:20:15
<p>On OSX:</p> <pre><code>bash-3.2$ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' ax1b[31mzx1b[mc </code></pre> <p>Whereas on Linux: </p> <pre><code>$ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' azc </code></pre> <p>and the z correctly shows up red.</p> <p>Is this a limitation of bash 3.2? My Linux test here runs bash 4.1.2...
3,907
340,947
2013-06-11 03:39:40
17,015,272
13
2013-06-09 23:43:18
89,817
2013-06-09 23:43:18
https://stackoverflow.com/q/17015137
https://stackoverflow.com/a/17015272
<p>OS X's version of sed doesn't do the escape substitutions you're asking for. You can get around this by using <code>$'...'</code> to have bash do the substitution before handing the string to sed:</p> <pre><code>$ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' ax1b[31mzx1b[mc $ echo "abc" | sed $'s/b/\x1b[31mz\x1b[m/' azc...
<p>OS X's version of sed doesn't do the escape substitutions you're asking for. You can get around this by using <code>$'...'</code> to have bash do the substitution before handing the string to sed:</p> <pre><code>$ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' ax1b[31mzx1b[mc $ echo "abc" | sed $'s/b/\x1b[31mz\x1b[m/' azc...
58, 369, 387, 390, 391
bash, linux, macos, shell, terminal
<h1>OSX sed: how to use the escape character in the second field of a `s` operation?</h1> <p>On OSX:</p> <pre><code>bash-3.2$ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' ax1b[31mzx1b[mc </code></pre> <p>Whereas on Linux: </p> <pre><code>$ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' azc </code></pre> <p>and the z correctly ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,569
bash
# OSX sed: how to use the escape character in the second field of a `s` operation? On OSX: ``` bash-3.2$ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' ax1b[31mzx1b[mc ``` Whereas on Linux: ``` $ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' azc ``` and the z correctly shows up red. Is this a limitation of bash 3.2? My Linux ...
OS X's version of sed doesn't do the escape substitutions you're asking for. You can get around this by using `$'...'` to have bash do the substitution before handing the string to sed: ``` $ echo "abc" | sed 's/b/\x1b[31mz\x1b[m/' ax1b[31mzx1b[mc $ echo "abc" | sed $'s/b/\x1b[31mz\x1b[m/' azc ``` (You'll have to tru...
16937788
Get the Number of Rows in Column of a worksheet
6
2013-06-05 10:40:46
<p>I have an Excel sheet as follows:</p> <pre><code>Id Name Address ------------------- 1 t1 Add1 2 Add2 3 </code></pre> <p>I want to get the count of non-empty cells in each column, i.e.:</p> <blockquote> <p>Column ID &rarr; 3 rows<br> Name &rarr; 1 row<br> Address &rarr; 2 rows</p> </blo...
33,655
1,905,690
2019-07-19 10:54:52
16,938,712
13
2013-06-05 11:27:09
1,630,171
2013-06-05 11:27:09
https://stackoverflow.com/q/16937788
https://stackoverflow.com/a/16938712
<p>Try something like this:</p> <pre><code>$xl = New-Object -COM "Excel.Application" $xl.Visible = $true $wb = $xl.Workbooks.Open("C:\path\to\your.xlsx") $ws = $wb.Sheets.Item(1) $rows = $ws.UsedRange.Rows.Count foreach ( $col in "A", "B", "C" ) { $xl.WorksheetFunction.CountIf($ws.Range($col + "1:" + $col + $rows...
<p>Try something like this:</p> <pre><code>$xl = New-Object -COM "Excel.Application" $xl.Visible = $true $wb = $xl.Workbooks.Open("C:\path\to\your.xlsx") $ws = $wb.Sheets.Item(1) $rows = $ws.UsedRange.Rows.Count foreach ( $col in "A", "B", "C" ) { $xl.WorksheetFunction.CountIf($ws.Range($col + "1:" + $col + $rows...
526
powershell
<h1>Get the Number of Rows in Column of a worksheet</h1> <p>I have an Excel sheet as follows:</p> <pre><code>Id Name Address ------------------- 1 t1 Add1 2 Add2 3 </code></pre> <p>I want to get the count of non-empty cells in each column, i.e.:</p> <blockquote> <p>Column ID &rarr; 3 rows<br> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
10,570
bash
# Get the Number of Rows in Column of a worksheet I have an Excel sheet as follows: ``` Id Name Address ------------------- 1 t1 Add1 2 Add2 3 ``` I want to get the count of non-empty cells in each column, i.e.: > Column ID → 3 rows > Name → 1 row > Address → 2 rows How do I do this in pow...
Try something like this: ``` $xl = New-Object -COM "Excel.Application" $xl.Visible = $true $wb = $xl.Workbooks.Open("C:\path\to\your.xlsx") $ws = $wb.Sheets.Item(1) $rows = $ws.UsedRange.Rows.Count foreach ( $col in "A", "B", "C" ) { $xl.WorksheetFunction.CountIf($ws.Range($col + "1:" + $col + $rows), "<>") - 1 }...