qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
734,833
<p>I'm trying to write a shell script that does the viginere cypher with a given text and key and can't figure out how to save the new ascii number for the converted char in a variable. Code down below:</p> <pre><code>function encode { local message=$1 local key=$2 local encoded=&quot;&quot; for ((i=0; i&lt;${#...
[ { "answer_id": 734829, "author": "telcoM", "author_id": 258991, "author_profile": "https://unix.stackexchange.com/users/258991", "pm_score": 0, "selected": false, "text": "<pre><code>Err:1 http.kali.org/kali kali-rolling/main amd64 gcc-12-base amd64 12.2.0-11 404 Not Found\n</code></pre>...
2023/02/08
[ "https://unix.stackexchange.com/questions/734833", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559948/" ]
I'm trying to write a shell script that does the viginere cypher with a given text and key and can't figure out how to save the new ascii number for the converted char in a variable. Code down below: ``` function encode { local message=$1 local key=$2 local encoded="" for ((i=0; i<${#message}; i++)); do lo...
You've probably broken your installation of Kali. (It's neither Debian nor Ubuntu, but a very specific distribution designed for professional pentesters who are familiar with Linux-based systems.) Trying removing `google-chrome.list` from `/etc/apt/sources.d`. If you're lucky you've not broken too much of your Kali di...
734,840
<p>Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).</p> <p>What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to...
[ { "answer_id": 734844, "author": "tink", "author_id": 24437, "author_profile": "https://unix.stackexchange.com/users/24437", "pm_score": 0, "selected": false, "text": "<p>That's not how you do aliases ... try</p>\n<pre><code>alias cwd=&quot;pwd | rev | cut -d '/' -f1 | rev&quot; \n</code...
2023/02/08
[ "https://unix.stackexchange.com/questions/734840", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/365584/" ]
Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...). What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to `python3...
### What is wrong with `$cwd`? When you use `cwd="pwd | rev | cut -d '/' -f1 | rev"` and then `$cwd` you are actually running `pwd` with arguments (you do not pipe the output). So basically you are running something like this: ```bash pwd '|' rev '|' cut '-d' "'/'" '-f1' '|' rev ``` You do not see any error because...
734,848
<p>Suppose I have this going:</p> <pre class="lang-bash prettyprint-override"><code>$ find ./src -name '*.txt' ./src/file1.txt ./src/subdir1/file2.txt ./src/subdir1/subsubdir1/file3.txt ./src/subdir2/file4.txt </code></pre> <p>I want to exclude the directory being searched, so something like:<br></p> <p><code>./file1.t...
[ { "answer_id": 734852, "author": "l0b0", "author_id": 3645, "author_profile": "https://unix.stackexchange.com/users/3645", "pm_score": 4, "selected": true, "text": "<p>Expanding on what <a href=\"https://unix.stackexchange.com/questions/734848/do-not-list-parent-directory-as-part-of-subd...
2023/02/09
[ "https://unix.stackexchange.com/questions/734848", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/553983/" ]
Suppose I have this going: ```bash $ find ./src -name '*.txt' ./src/file1.txt ./src/subdir1/file2.txt ./src/subdir1/subsubdir1/file3.txt ./src/subdir2/file4.txt ``` I want to exclude the directory being searched, so something like: `./file1.txt` instead of `./src/file1.txt` `./subdir1/file2.txt` instead of `./...
Expanding on what [@steeldriver said](https://unix.stackexchange.com/questions/734848/do-not-list-parent-directory-as-part-of-subdirectories-when-using-find#comment1395015_734848): ``` $ cd "$(mktemp --directory)" # create temporary directory direnv: unloading $ mkdir foo bar $ touch foo/1 bar/2 $ find foo bar -type f...
734,856
<pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;sys/select.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt; int main(int argc, char* argv[]){ if(argc &lt; 2){ puts(&quot;err argv&quot;); return -1; } int r_fd = open(argv[1],...
[ { "answer_id": 734889, "author": "Paul_Pedant", "author_id": 379287, "author_profile": "https://unix.stackexchange.com/users/379287", "pm_score": 0, "selected": false, "text": "<p>The problem appears to be in checking both r_set and w_set after a single select -- possibly a race conditio...
2023/02/09
[ "https://unix.stackexchange.com/questions/734856", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559979/" ]
``` #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/select.h> #include <fcntl.h> #include <unistd.h> int main(int argc, char* argv[]){ if(argc < 2){ puts("err argv"); return -1; } int r_fd = open(argv[1], O_RDWR); int w_fd = open(argv[1], O_RDWR); fd_...
``` if(FD_ISSET(w_fd, &w_set)){ write(w_fd, w_buf, sizeof(w_buf)); printf("write count:%d\n", write_count++); } ``` If `select` tells you an fd is writable, that means you can write *at least one byte*. The threshold may be higher than 1, depending on how the FIFO buffer i...
734,868
<p>Given inputs like:</p> <pre><code>input value #001 is [342] input value #002 is [8349] </code></pre> <p>How to carve out the values inside [...] so the output is below?</p> <pre><code>342 8349 </code></pre> <p>This should be easy with regular expressions that supports back reference (e.g., &quot;\1&quot;). But POSIX...
[ { "answer_id": 734869, "author": "Kusalananda", "author_id": 116858, "author_profile": "https://unix.stackexchange.com/users/116858", "pm_score": 1, "selected": false, "text": "<p>The following command uses <code>gsub</code> to delete all <code>[</code> and <code>]</code> characters from...
2023/02/09
[ "https://unix.stackexchange.com/questions/734868", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/38968/" ]
Given inputs like: ``` input value #001 is [342] input value #002 is [8349] ``` How to carve out the values inside [...] so the output is below? ``` 342 8349 ``` This should be easy with regular expressions that supports back reference (e.g., "\1"). But POSIX awk, which uses ERE, doesn't support that. For exampl...
You can use `match()` which sets `RSTART` to the start of the match and `RLENGTH` to its length (it also returns `RSTART`; or 0 if there's no match): ``` awk 'match($0, /\[[[:digit:]]+\]/) { print substr($0, RSTART, RLENGTH) }' ``` Or: ``` awk 'match($0, /\[[[:digit:]]+\]/) { print substr($0, RST...
734,895
<p>The first bcachefs supporting Kernel 6.1, are released on 2022-12-11. See follow sources:</p> <ul> <li><p><a href="https://evilpiepirate.org/git/bcachefs.git" rel="nofollow noreferrer">https://evilpiepirate.org/git/bcachefs.git</a></p> </li> <li><p><a href="https://web.archive.org/web/20230207003903/https://evilpiep...
[ { "answer_id": 734891, "author": "Marcus Müller", "author_id": 106650, "author_profile": "https://unix.stackexchange.com/users/106650", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>We call FTP a protocol, but speaking literally, FTP has a source code</p>\n</blockquote>\n<p...
2023/02/09
[ "https://unix.stackexchange.com/questions/734895", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/456207/" ]
The first bcachefs supporting Kernel 6.1, are released on 2022-12-11. See follow sources: * <https://evilpiepirate.org/git/bcachefs.git> * <https://web.archive.org/web/20230207003903/https://evilpiepirate.org/git/bcachefs.git> * <https://evilpiepirate.org/git/bcachefs.git/tag/?h=v6.1> * <https://web.archive.org/web/20...
You're mixing up FTP and `ftp`. * [FTP](https://en.wikipedia.org/wiki/File_Transfer_Protocol) translates to "File Transfer Protocol". It was introduced first 1971, current version is defined in [RFC959](https://datatracker.ietf.org/doc/html/rfc959). It's part of the [TCP/IP protocol suite](https://en.wikipedia.org/wik...
734,903
<p>I have 2 files (<code>mac</code> and <code>uid</code>) with data on a Linux machine, that I want to carry to a &quot;template&quot;, with a list, using <code>sed</code> to replace the data with variables.</p> <p><strong>list.txt:</strong></p> <pre><code>CP00 CP01 </code></pre> <p><strong>mac.txt:</strong></p> <pre><...
[ { "answer_id": 734909, "author": "Ed Morton", "author_id": 133219, "author_profile": "https://unix.stackexchange.com/users/133219", "pm_score": 2, "selected": true, "text": "<p>Using any awk:</p>\n<pre><code>$ cat tst.sh\n#!/usr/bin/env bash\n\ncd /tmp/cobbler &amp;&amp;\nawk '\nFILENAME...
2023/02/09
[ "https://unix.stackexchange.com/questions/734903", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560045/" ]
I have 2 files (`mac` and `uid`) with data on a Linux machine, that I want to carry to a "template", with a list, using `sed` to replace the data with variables. **list.txt:** ``` CP00 CP01 ``` **mac.txt:** ``` FF-AA-BB-AA-DD-AA 00-AA-11-AA-11-EE ``` **uid.txt:** ``` e3442342a e43342f0a ``` **template:** ```...
Using any awk: ``` $ cat tst.sh #!/usr/bin/env bash cd /tmp/cobbler && awk ' FILENAME == ARGV[1] { uids[FNR] = $1 } FILENAME == ARGV[2] { macs[FNR] = $1 } FILENAME == ARGV[3] { outs[FNR] = $1 } FILENAME == ARGV[4] { for ( outNr in outs ) { if ( $1 == "\"uid\":" ) { $2 = "\"" uids[++uidNr] "\",...
734,915
<p>I had a json</p> <pre><code>[ { &quot;name&quot;: &quot;type1&quot;, &quot;type&quot;: &quot;string&quot;, &quot;values&quot;: { &quot;set1&quot;: &quot;dataA1&quot;, &quot;set1&quot;: &quot;dataA2&quot; } }, { &quot;name&quot;: &quot;type2&...
[ { "answer_id": 734909, "author": "Ed Morton", "author_id": 133219, "author_profile": "https://unix.stackexchange.com/users/133219", "pm_score": 2, "selected": true, "text": "<p>Using any awk:</p>\n<pre><code>$ cat tst.sh\n#!/usr/bin/env bash\n\ncd /tmp/cobbler &amp;&amp;\nawk '\nFILENAME...
2023/02/09
[ "https://unix.stackexchange.com/questions/734915", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/543427/" ]
I had a json ``` [ { "name": "type1", "type": "string", "values": { "set1": "dataA1", "set1": "dataA2" } }, { "name": "type2", "type": "string", "values": { "set1": "dataB1", "set2": "dataB2" } ...
Using any awk: ``` $ cat tst.sh #!/usr/bin/env bash cd /tmp/cobbler && awk ' FILENAME == ARGV[1] { uids[FNR] = $1 } FILENAME == ARGV[2] { macs[FNR] = $1 } FILENAME == ARGV[3] { outs[FNR] = $1 } FILENAME == ARGV[4] { for ( outNr in outs ) { if ( $1 == "\"uid\":" ) { $2 = "\"" uids[++uidNr] "\",...
734,934
<p>I have file with this content :</p> <pre><code>Text1 , Text11 : APC signal 0 , prev=7 Text2 , Text22 : APC signal 1 , prev=0 Text3 , Text33 : APC signal 0 , prev=1 Text4 , Text44 : APC signal 1 , prev=0 Text5 , Text55 : APC signal 0 , prev=1 Text6 , Text66 : APC signal 1 , prev=0 </code></pre> <p>I want to ext...
[ { "answer_id": 734937, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 0, "selected": false, "text": "<p>Like this using <a href=\"/questions/tagged/awk\" class=\"post-tag\" title=\"show questions tagged &#39;awk&...
2023/02/09
[ "https://unix.stackexchange.com/questions/734934", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560084/" ]
I have file with this content : ``` Text1 , Text11 : APC signal 0 , prev=7 Text2 , Text22 : APC signal 1 , prev=0 Text3 , Text33 : APC signal 0 , prev=1 Text4 , Text44 : APC signal 1 , prev=0 Text5 , Text55 : APC signal 0 , prev=1 Text6 , Text66 : APC signal 1 , prev=0 ``` I want to extract the first and the t...
Using `awk`: ``` $ awk -F, '{sub(/.*:/, "", $2); }1' OFS="," file Text1 , APC signal 0 , prev=7 Text2 , APC signal 1 , prev=0 Text3 , APC signal 0 , prev=1 Text4 , APC signal 1 , prev=0 Text5 , APC signal 0 , prev=1 Text6 , APC signal 1 , prev=0 ``` The built-in `awk` function [sub](https://www.gnu.org/software/gawk...
734,943
<p>I have two strings</p> <pre><code>&quot;Some Special xn39432n4 (foo bar)&quot; &quot;Another thing goes 21 deer 14.5&quot; </code></pre> <p>with <code>sed</code>, I want this output</p> <pre><code>xn39432n4 21 deer 14.5 </code></pre> <p>means all space separated words containing numbers (from first to last occurrenc...
[ { "answer_id": 735047, "author": "terdon", "author_id": 22222, "author_profile": "https://unix.stackexchange.com/users/22222", "pm_score": 1, "selected": false, "text": "<p>You can do this with GNU <code>grep</code>:</p>\n<pre><code>$ grep -oP '\\w+[.\\d]+\\w+|[.\\d]+\\s+\\w+\\s+[.\\d]+'...
2023/02/09
[ "https://unix.stackexchange.com/questions/734943", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/543427/" ]
I have two strings ``` "Some Special xn39432n4 (foo bar)" "Another thing goes 21 deer 14.5" ``` with `sed`, I want this output ``` xn39432n4 21 deer 14.5 ``` means all space separated words containing numbers (from first to last occurrence) and non numerical words between them as well.
Maybe something like: ``` sed -n ' s/\([^[:space:]]*[[:digit:]][^[:space:]]*\(.*[[:digit:]][^[:space:]]*\)\{0,1\}\).*/\ \1/ s/.*\n//p' < your-file ``` Which matches a sequence of non-white`space` containing at least one `digit` optionally (`\{0,1\}`) followed by any sequence of characters followed by a digit and...
734,952
<p>I have a set of URLs and I'm really only interested in anything up to the first <code>/</code>.</p> <p>How can I capture this info to a text file?</p> <p>Input (<code>foo.txt</code>):</p> <pre><code>apple.com/nothing.js t1.msn.com/cookie=22 happy.net/whatever </code></pre> <p>Output (redirected to file: <code>fo...
[ { "answer_id": 734956, "author": "Yehuda", "author_id": 415533, "author_profile": "https://unix.stackexchange.com/users/415533", "pm_score": 0, "selected": false, "text": "<p>Your better option here is actually <code>sed</code>, because it edits the stream on a line by line basis.</p>\n<...
2023/02/09
[ "https://unix.stackexchange.com/questions/734952", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560113/" ]
I have a set of URLs and I'm really only interested in anything up to the first `/`. How can I capture this info to a text file? Input (`foo.txt`): ``` apple.com/nothing.js t1.msn.com/cookie=22 happy.net/whatever ``` Output (redirected to file: `foo_filter.txt`): ``` apple.com/ t1.msn.com/ happy.net/ `...
If you don't want the trailing slash, it's very straightforward ``` cut -d/ -f1 foo.txt awk -F/ '{print $1}' foo.txt sed 's!/.*!!' foo.txt ``` If you do want that trailing slash, then ``` awk -F/ '{print $1 "/"}' foo.txt sed 's!/.*!/!' foo.txt ``` All of these will write to *stdout* (your screen) so you can see t...
735,008
<pre><code>● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled) Drop-In: /usr/lib/systemd/system/rc-local.service.d └─debian.conf /etc/systemd/system/rc-local.service.d └─ttyoutput....
[ { "answer_id": 735010, "author": "Jimmy", "author_id": 444703, "author_profile": "https://unix.stackexchange.com/users/444703", "pm_score": 1, "selected": false, "text": "<p>Make sure you have this at the top of /etc/rc.local</p>\n<p><code>#!/bin/sh -e</code></p>\n<p>Make sure you have t...
2023/02/10
[ "https://unix.stackexchange.com/questions/735008", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560163/" ]
``` ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled) Drop-In: /usr/lib/systemd/system/rc-local.service.d └─debian.conf /etc/systemd/system/rc-local.service.d └─ttyoutput.conf ...
Make sure you have this at the top of /etc/rc.local `#!/bin/sh -e` Make sure you have this at the end of /etc/rc.local `exit 0`
735,048
<p>I have the following command to change periods to hyphens in file names recursively, so long as they have another period both before and after them:</p> <pre><code>find path/to/dir -depth -type f -name '*.*' -exec rename -n -d 's/(?&lt;=.)\.(?=.*\.)/-/g' {} + </code></pre> <p>However it cant be used effectively on a...
[ { "answer_id": 735049, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p>Maybe you could just use <code>zsh</code> and do:</p>\n<pre><code>autoload -Uz zmv\nzmv -n '(**/)(&lt;19...
2023/02/10
[ "https://unix.stackexchange.com/questions/735048", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525938/" ]
I have the following command to change periods to hyphens in file names recursively, so long as they have another period both before and after them: ``` find path/to/dir -depth -type f -name '*.*' -exec rename -n -d 's/(?<=.)\.(?=.*\.)/-/g' {} + ``` However it cant be used effectively on all filenames I wish to adju...
Maybe you could just use `zsh` and do: ``` autoload -Uz zmv zmv -n '(**/)(<1900-2100>).(<1-12>).(<1-31>)([^0-9]*)(#q.)' '$1$2-$3-$4$5' ``` To be explicit as to what you want to match (here file names starting with a YYYY.MM.DD¹ date in a given range). (`-n` for dry-run. Remove it to actually do it). --- ¹ technic...
735,061
<p>I have the following tree, where <code>f</code> are files while <code>src</code> and <code>d</code> are directories (<code>f</code> could be hidden or not):</p> <pre><code>src/f1 src/f2 ... src/d1 src/d2 src/d3 ... </code></pre> <p>I want to replicate the same structure in a <code>dst</code> folder, but exclude all ...
[ { "answer_id": 735066, "author": "user4089", "author_id": 157903, "author_profile": "https://unix.stackexchange.com/users/157903", "pm_score": 3, "selected": true, "text": "<p>man rsync say :</p>\n<blockquote>\n<p><code>option --filter=RULE, -f add a file-filtering RULE</code></p>...
2023/02/10
[ "https://unix.stackexchange.com/questions/735061", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525966/" ]
I have the following tree, where `f` are files while `src` and `d` are directories (`f` could be hidden or not): ``` src/f1 src/f2 ... src/d1 src/d2 src/d3 ... ``` I want to replicate the same structure in a `dst` folder, but exclude all files present in the `src` folder (that is `f1`, `f2`, etc. in the tree above, ...
man rsync say : > > `option --filter=RULE, -f add a file-filtering RULE` > > > So, try `rsync -avr -f"+ */" -f"- *" /src/ /dest/` `-f"+ */"` will add directories when `-f"- *"` will remove files everywhere. As @Kusalananda said, this will avoid any file in all subtree. `rsync -avr -f"+ */" -f"- /*" /src/ /des...
735,063
<p>VirtualBox is open source in parts and closed source in parts.</p> <p><strong>Sample for Open Source part:</strong></p> <ul> <li>VirtualBox manager</li> </ul> <p>The source code can be found on:</p> <pre><code>https://web.archive.org/web/20230215155445/https://github.com/mirror/vbox </code></pre> <p><strong>Sample f...
[ { "answer_id": 735064, "author": "Artem S. Tashkinov", "author_id": 260833, "author_profile": "https://unix.stackexchange.com/users/260833", "pm_score": 2, "selected": false, "text": "<blockquote>\n<p>Are there projects that replace the closed source part of Virtual Box and what are thei...
2023/02/10
[ "https://unix.stackexchange.com/questions/735063", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/449067/" ]
VirtualBox is open source in parts and closed source in parts. **Sample for Open Source part:** * VirtualBox manager The source code can be found on: ``` https://web.archive.org/web/20230215155445/https://github.com/mirror/vbox ``` **Sample for closed source part:** * the extension pack. **See also the follow f...
> > Are there projects that replace the closed source part of Virtual Box and what are their names? > > > No.
735,070
<p>I have a yaml config file(cli.yaml). with structure</p> <pre><code>database: host: &quot;IP&quot; </code></pre> <p>Now, I just want to replace the file content, Or more precisely THE <code>IP</code> string with my PC's current <code>IPV4</code> address.</p> <p>As I am not very good with terminals, I divided my wo...
[ { "answer_id": 735073, "author": "Amjad", "author_id": 560241, "author_profile": "https://unix.stackexchange.com/users/560241", "pm_score": 0, "selected": false, "text": "<p>I find the solution, but it is a bit the other way round. I am using the <code>REGEX</code> instead of the <code>I...
2023/02/10
[ "https://unix.stackexchange.com/questions/735070", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560241/" ]
I have a yaml config file(cli.yaml). with structure ``` database: host: "IP" ``` Now, I just want to replace the file content, Or more precisely THE `IP` string with my PC's current `IPV4` address. As I am not very good with terminals, I divided my work into several parts - Like: For getting the IP: `ipconfig ge...
You could consider using the [yq](https://github.com/kislyuk/yq) wrapper for `jq` to update the value: ``` $ yq -Y --arg ip '10.0.0.1' '.database.host |= $ARGS.named.ip' cli.yaml database: host: "10.0.0.1" ```
735,076
<p>I am using <a href="https://github.com/ggerganov/whisper.cpp/" rel="nofollow noreferrer">whisper.cpp</a> to transcribe some sound files. It is a very CPU heavy process so I try to find some optimal settings and therefore I have done some tests with the thread setting (-t) but the results are super confusing. This is...
[ { "answer_id": 735086, "author": "MC68020", "author_id": 426539, "author_profile": "https://unix.stackexchange.com/users/426539", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>I have done some tests with the thread setting (-t)</p>\n</blockquote>\n<p>That is indeed a pretty...
2023/02/10
[ "https://unix.stackexchange.com/questions/735076", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/32351/" ]
I am using [whisper.cpp](https://github.com/ggerganov/whisper.cpp/) to transcribe some sound files. It is a very CPU heavy process so I try to find some optimal settings and therefore I have done some tests with the thread setting (-t) but the results are super confusing. This is the command I execute: ``` date; time ...
Increasing the number of threads at some point makes the computation memory bound, so you stop gaining performance improvement. The CPU usage keeps increasing because in `whisper.cpp` we use busy loops to synchronise threads. This is much more CPU intensive and wastes a lot of CPU cycles, but helps reduce the latency b...
735,085
<pre><code>... | perl -pe &quot;s/([^$filespec]*)($filespec)/ ... </code></pre> <p>So I have a function where the above construction works fine if <code>$filespec</code> is most things. However <em>if there's a dash in the file name</em> I get an <code>Invalid [] range</code> message.</p> <p>How can I ensure that the v...
[ { "answer_id": 735086, "author": "MC68020", "author_id": 426539, "author_profile": "https://unix.stackexchange.com/users/426539", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>I have done some tests with the thread setting (-t)</p>\n</blockquote>\n<p>That is indeed a pretty...
2023/02/10
[ "https://unix.stackexchange.com/questions/735085", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/56145/" ]
``` ... | perl -pe "s/([^$filespec]*)($filespec)/ ... ``` So I have a function where the above construction works fine if `$filespec` is most things. However *if there's a dash in the file name* I get an `Invalid [] range` message. How can I ensure that the variable `$filespec` expands to a file name that is protect...
Increasing the number of threads at some point makes the computation memory bound, so you stop gaining performance improvement. The CPU usage keeps increasing because in `whisper.cpp` we use busy loops to synchronise threads. This is much more CPU intensive and wastes a lot of CPU cycles, but helps reduce the latency b...
735,098
<p>I have a service configured to log <code>StandardOutput</code> to a log location. Some users may delete the log path when gathering logs data. If I restart my service and the path does not exist, my service fails. Is there a way to work around it? The solutions in order of preference is</p> <pre><code>[Unit] Descrip...
[ { "answer_id": 735099, "author": "Luna", "author_id": 559103, "author_profile": "https://unix.stackexchange.com/users/559103", "pm_score": 0, "selected": false, "text": "<p>If you are looking for logs in journal, you need to set stdout to syslog <code>StandaedOutput=syslog</code> and res...
2023/02/10
[ "https://unix.stackexchange.com/questions/735098", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560271/" ]
I have a service configured to log `StandardOutput` to a log location. Some users may delete the log path when gathering logs data. If I restart my service and the path does not exist, my service fails. Is there a way to work around it? The solutions in order of preference is ``` [Unit] Description=Some service [Serv...
[`man systemd.exec`](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=) says: > > append:path is similar to file:path above, but it opens the file in append mode. > > > The file:path option ... If path refers to a regular file on the filesystem, it is opened (created if it doesn't e...
735,138
<p>Consider a file file2.txt having the following content:</p> <pre><code>P 89 24 -1.5388040474568784e+01 7.4421775186012660e+00 -1.3143195543234219e+03 1.3168884860257754e+03 8.0419002445999993e+01 44 0 0 -97 0 P 122 -4 -1.4869334602986523e+01 5.7316939411954255e+00 -1.3144161801429666e+03 1.3169704096915282e+03 8.041...
[ { "answer_id": 735140, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 3, "selected": false, "text": "<h4>Let's simplify a bit the regex:</h4>\n<pre><code>grep -E '^P [0-9]+ -?24\\b' file2.txt \n</code></pre>\n<p>...
2023/02/11
[ "https://unix.stackexchange.com/questions/735138", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/128780/" ]
Consider a file file2.txt having the following content: ``` P 89 24 -1.5388040474568784e+01 7.4421775186012660e+00 -1.3143195543234219e+03 1.3168884860257754e+03 8.0419002445999993e+01 44 0 0 -97 0 P 122 -4 -1.4869334602986523e+01 5.7316939411954255e+00 -1.3144161801429666e+03 1.3169704096915282e+03 8.0419002445999993...
.... what am I doing wrong? ... apart from making it far more complicated that it needs to be ... you are trying to match multiple spaces and leading spaces that are not in your strings in all of the cases for `-24` and in some of other cases too .... ``` P [0-9]+ 24 | ``` is fine `P` then then a series of digits `...
735,162
<p>I have a variable <code>var</code>. Want to print the lines after <code>Code:</code> in <code>blue</code> (but with the line specifying <code>Code:</code> removed), whilst the rest is printed in <code>green</code>. Am using a bash script that calls awk to do the variable processing running ubuntu.</p> <pre><code>s...
[ { "answer_id": 735168, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 2, "selected": false, "text": "<p>To colorizing a line with ANSI escape codes in awk say a line containing string &quot;WORD&quot;, you can do:</p>\n...
2023/02/11
[ "https://unix.stackexchange.com/questions/735162", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559749/" ]
I have a variable `var`. Want to print the lines after `Code:` in `blue` (but with the line specifying `Code:` removed), whilst the rest is printed in `green`. Am using a bash script that calls awk to do the variable processing running ubuntu. ``` sgr="$( tput sgr0 )" grn="$( tput bold; tput setaf 34 )" blu="$( tput b...
Based heavily on the answer at [using-awk-to-color-the-output-in-bash](https://stackoverflow.com/questions/64034385/using-awk-to-color-the-output-in-bash/64046525#64046525), this might be what you want for this and any similar situations where you need to change, potentially multiple, foreground and/or background color...
735,163
<p>The first bcachefs supporting Kernel 6.1, are released on 2022-12-11. See follow sources:</p> <ul> <li><p><a href="https://evilpiepirate.org/git/bcachefs.git" rel="nofollow noreferrer">https://evilpiepirate.org/git/bcachefs.git</a></p> </li> <li><p><a href="https://web.archive.org/web/20230207003903/https://evilpiep...
[ { "answer_id": 735168, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 2, "selected": false, "text": "<p>To colorizing a line with ANSI escape codes in awk say a line containing string &quot;WORD&quot;, you can do:</p>\n...
2023/02/11
[ "https://unix.stackexchange.com/questions/735163", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/456207/" ]
The first bcachefs supporting Kernel 6.1, are released on 2022-12-11. See follow sources: * <https://evilpiepirate.org/git/bcachefs.git> * <https://web.archive.org/web/20230207003903/https://evilpiepirate.org/git/bcachefs.git> * <https://evilpiepirate.org/git/bcachefs.git/tag/?h=v6.1> * <https://web.archive.org/web/20...
Based heavily on the answer at [using-awk-to-color-the-output-in-bash](https://stackoverflow.com/questions/64034385/using-awk-to-color-the-output-in-bash/64046525#64046525), this might be what you want for this and any similar situations where you need to change, potentially multiple, foreground and/or background color...
735,176
<p>I'm trying to write my own script to improve some auto-formatting before commiting to a remote repository. I use indenting guides in my IDE and the autoformatters available for my language (FORTRAN) do not support indenting empty lines. I essentially want to use <code>sed</code> to run through the lines of a file an...
[ { "answer_id": 735168, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 2, "selected": false, "text": "<p>To colorizing a line with ANSI escape codes in awk say a line containing string &quot;WORD&quot;, you can do:</p>\n...
2023/02/11
[ "https://unix.stackexchange.com/questions/735176", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560349/" ]
I'm trying to write my own script to improve some auto-formatting before commiting to a remote repository. I use indenting guides in my IDE and the autoformatters available for my language (FORTRAN) do not support indenting empty lines. I essentially want to use `sed` to run through the lines of a file and if the line ...
Based heavily on the answer at [using-awk-to-color-the-output-in-bash](https://stackoverflow.com/questions/64034385/using-awk-to-color-the-output-in-bash/64046525#64046525), this might be what you want for this and any similar situations where you need to change, potentially multiple, foreground and/or background color...
735,212
<p>I wonder if I can get some help with a project I'm working on. I have a Synology NAS. I found a Community Package that autoruns a script of my creation anytime a USB drive is plugged in to one of the drives. My script copies images and movie files to a given folder from all USB drives/Sandisk cards listed in the scr...
[ { "answer_id": 735214, "author": "J_H", "author_id": 245399, "author_profile": "https://unix.stackexchange.com/users/245399", "pm_score": 2, "selected": true, "text": "<p>You wrote</p>\n<pre><code>today=$(date +%m-%d-%Y-%s)\n...\n</code></pre>\n<p>It appears the answer could be as simple...
2023/02/11
[ "https://unix.stackexchange.com/questions/735212", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560357/" ]
I wonder if I can get some help with a project I'm working on. I have a Synology NAS. I found a Community Package that autoruns a script of my creation anytime a USB drive is plugged in to one of the drives. My script copies images and movie files to a given folder from all USB drives/Sandisk cards listed in the script...
You wrote ``` today=$(date +%m-%d-%Y-%s) ... ``` It appears the answer could be as simple as ``` today=$(date +%m-%d-%Y-%s) sleep 15 ... ``` --- Consider putting those `rsync`s inside a bash function named `sync_all`. Then you could run everything twice -- immediately, and after a delay. ``` sync_all sleep 15 ...
735,227
<p>I have tried:</p> <pre><code>gaspipe@kali:~/bashscripts$ ls ./ ../ addpath* autoinstaller gaspipe@kali:~/bashscripts$ cd .. gaspipe@kali:~$ addpath addpath: command not found gaspipe@kali:~$ addpath* addpath*: command not found gaspipe@kali:~$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin...
[ { "answer_id": 735230, "author": "telcoM", "author_id": 258991, "author_profile": "https://unix.stackexchange.com/users/258991", "pm_score": 1, "selected": false, "text": "<p>If you want a script to manipulate the environment of the current shell, you'll have to source the script:</p>\n<...
2023/02/12
[ "https://unix.stackexchange.com/questions/735227", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560400/" ]
I have tried: ``` gaspipe@kali:~/bashscripts$ ls ./ ../ addpath* autoinstaller gaspipe@kali:~/bashscripts$ cd .. gaspipe@kali:~$ addpath addpath: command not found gaspipe@kali:~$ addpath* addpath*: command not found gaspipe@kali:~$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lo...
Your local folder isn't delimited from the /usr/games directory: ``` gaspipe@kali:~$ echo $PATH ...:/bin:/usr/local/games:/usr/games/home/gaspipe/bashscripts ``` It should be: ``` gaspipe@kali:~$ echo $PATH ...:/bin:/usr/local/games:/usr/games:/home/gaspipe/bashscripts ``` (I cut the start of the PATH to make the...
735,285
<p><a href="https://unix.stackexchange.com/questions/735118/combine-csv-files-with-text-between-each-line" title="Combine .csv-files with text between each line">Here I asked already for a similar problem.</a></p> <p>Now I have 3 .csv-files but one of them has only 1 line.</p> <p><strong>file1.csv</strong></p> <pre><co...
[ { "answer_id": 735302, "author": "dhm", "author_id": 548011, "author_profile": "https://unix.stackexchange.com/users/548011", "pm_score": 3, "selected": true, "text": "<p>Here is another simple method:</p>\n<pre><code>$ paste -d, file1 file2 file3 | awk 'BEGIN{FS=OFS=&quot;,&quot;} {if(...
2023/02/12
[ "https://unix.stackexchange.com/questions/735285", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558210/" ]
[Here I asked already for a similar problem.](https://unix.stackexchange.com/questions/735118/combine-csv-files-with-text-between-each-line "Combine .csv-files with text between each line") Now I have 3 .csv-files but one of them has only 1 line. **file1.csv** ``` dog cats mouse ``` **file2.csv** ``` 001a 002a 00...
Here is another simple method: ``` $ paste -d, file1 file2 file3 | awk 'BEGIN{FS=OFS=","} {if(NR==1){w=$3} else {$3=w}}1' dog,001a,WORD cats,002a,WORD mouse,003c,WORD ```
735,288
<p>As I was reading the Android <a href="https://developer.android.com/guide/components/fundamentals?hl=en" rel="nofollow noreferrer">Developer Guides</a>, I was confronted with the following statements:</p> <blockquote> <p>The Android operating system is a multi-user Linux system in which each app is a different user...
[ { "answer_id": 735302, "author": "dhm", "author_id": 548011, "author_profile": "https://unix.stackexchange.com/users/548011", "pm_score": 3, "selected": true, "text": "<p>Here is another simple method:</p>\n<pre><code>$ paste -d, file1 file2 file3 | awk 'BEGIN{FS=OFS=&quot;,&quot;} {if(...
2023/02/12
[ "https://unix.stackexchange.com/questions/735288", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/549424/" ]
As I was reading the Android [Developer Guides](https://developer.android.com/guide/components/fundamentals?hl=en), I was confronted with the following statements: > > The Android operating system is a multi-user Linux system in which each app is a different user. > > > > > Each process has its own virtual machi...
Here is another simple method: ``` $ paste -d, file1 file2 file3 | awk 'BEGIN{FS=OFS=","} {if(NR==1){w=$3} else {$3=w}}1' dog,001a,WORD cats,002a,WORD mouse,003c,WORD ```
735,289
<p>I am trying to chop a 4TB (4,000,225,165,312 bytes) drive up into even partitions of 1TB.</p> <p>I want these partitions to be further dividable to at least 1^3 Byte (~1GB) (1000000000) partitions.</p> <p>Okay, so after hours of distilling, I've found a couple of conflicting conclusions:</p> <ul> <li>with Gparted I ...
[ { "answer_id": 735293, "author": "Artem S. Tashkinov", "author_id": 260833, "author_profile": "https://unix.stackexchange.com/users/260833", "pm_score": 2, "selected": false, "text": "<p>It's <strong>not</strong> advisable for partitions sizes to be multiples of 1'000'000'000 - this numb...
2023/02/12
[ "https://unix.stackexchange.com/questions/735289", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/346155/" ]
I am trying to chop a 4TB (4,000,225,165,312 bytes) drive up into even partitions of 1TB. I want these partitions to be further dividable to at least 1^3 Byte (~1GB) (1000000000) partitions. Okay, so after hours of distilling, I've found a couple of conflicting conclusions: * with Gparted I cannot make a 1000000000 ...
It's not possible to make partitions at byte resolution. Even if you could, it would leave you with no end of alignment issues. Sector size is either 512 or 4096, all partition sizes must be multiples of that. By convention, you should even stick to MiB alignment (multiple of 1048576 bytes) unless you have strong reas...
735,321
<p>I have a directory with many subfolders that look like the following, (keep in mind that FA and T1 content is paired and also ..._L, ..._R content). The quantity of folders named here by letters (a,b,c, etc) can vary a lot:</p> <pre><code>. ├── FA │   ├── CN │   │   ├── CN_L │   │   │   ├── GE_FSPGR │   │   │   │   ...
[ { "answer_id": 735293, "author": "Artem S. Tashkinov", "author_id": 260833, "author_profile": "https://unix.stackexchange.com/users/260833", "pm_score": 2, "selected": false, "text": "<p>It's <strong>not</strong> advisable for partitions sizes to be multiples of 1'000'000'000 - this numb...
2023/02/13
[ "https://unix.stackexchange.com/questions/735321", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560491/" ]
I have a directory with many subfolders that look like the following, (keep in mind that FA and T1 content is paired and also ...\_L, ...\_R content). The quantity of folders named here by letters (a,b,c, etc) can vary a lot: ``` . ├── FA │   ├── CN │   │   ├── CN_L │   │   │   ├── GE_FSPGR │   │   │   │   ├── a │   │...
It's not possible to make partitions at byte resolution. Even if you could, it would leave you with no end of alignment issues. Sector size is either 512 or 4096, all partition sizes must be multiples of that. By convention, you should even stick to MiB alignment (multiple of 1048576 bytes) unless you have strong reas...
735,327
<p>I wonder how I can upgrade the data from an existing PostgreSQL 14 installation to 15.</p> <p>I automatically got PG 15 installed via apt, so I see</p> <pre><code># dpkg -l || grep ii | cut -d&quot; &quot; -f3 | grep postgresql-1 postgresql-14 postgresql-15 </code></pre> <p>But the data is still all in PG 14.</p> <...
[ { "answer_id": 735328, "author": "rubo77", "author_id": 20661, "author_profile": "https://unix.stackexchange.com/users/20661", "pm_score": 1, "selected": false, "text": "<p>Be sure you are still running on the old 14 cluster, Then <strong>backup your data</strong> with</p>\n<pre><code>pg...
2023/02/13
[ "https://unix.stackexchange.com/questions/735327", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/20661/" ]
I wonder how I can upgrade the data from an existing PostgreSQL 14 installation to 15. I automatically got PG 15 installed via apt, so I see ``` # dpkg -l || grep ii | cut -d" " -f3 | grep postgresql-1 postgresql-14 postgresql-15 ``` But the data is still all in PG 14. There are two services ``` service postgres...
Be sure you are still running on the old 14 cluster, Then **backup your data** with ``` pg_dumpall -F t > ~/backup_postgres_all_dbs.tar ``` Stop the still empty default installed postgreSQL 15 cluster and drop it. ``` pg_dropcluster 15 main --stop ``` Upgrade the 14 cluster to the latest version (which is 15 at t...
735,329
<p>I have downloaded some sequences from a publicly available database in <code>.fa</code> format. I want to generate a <code>.csv</code> file that contains the name of the sequence, and its length, separated by a comma. This is how the input file is:</p> <pre><code>&gt;cel-let-7-5p MIMAT0000001 Caenorhabditis elegans ...
[ { "answer_id": 735336, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>With <a href=\"/questions/tagged/awk\" class=\"post-tag\" title=\"show questions tagged &#39;awk&#39;\" aria...
2023/02/13
[ "https://unix.stackexchange.com/questions/735329", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/531431/" ]
I have downloaded some sequences from a publicly available database in `.fa` format. I want to generate a `.csv` file that contains the name of the sequence, and its length, separated by a comma. This is how the input file is: ``` >cel-let-7-5p MIMAT0000001 Caenorhabditis elegans let-7-5p UGAGGUAGUAGGUUGUAUAGUU >cel-l...
With [awk](/questions/tagged/awk "show questions tagged 'awk'") ([avoid the use of `getline()`](http://awk.freeshell.org/AllAboutGetline) where's it's not absolutely required): ``` $ awk ' /^>/{sub(/^>/, "");printf "%s,", $1;next} # process lines starting with '>' {print length()} ...
735,342
<p>I have a text file with about 50 URLs Am trying to curl each of the URLs in the text file and grep to output a couple of lines from the GREP Match</p> <p>I cannot understand why it wont work, as if i echo each line, it displays the URL correctly. If i run the CURL manually with a URL and Grep it works. But once in t...
[ { "answer_id": 735347, "author": "Gunnar Knutson", "author_id": 560531, "author_profile": "https://unix.stackexchange.com/users/560531", "pm_score": -1, "selected": false, "text": "<p>using input redirection and a <code>while</code> loop here is probably over-complicating things. Using <...
2023/02/13
[ "https://unix.stackexchange.com/questions/735342", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/150130/" ]
I have a text file with about 50 URLs Am trying to curl each of the URLs in the text file and grep to output a couple of lines from the GREP Match I cannot understand why it wont work, as if i echo each line, it displays the URL correctly. If i run the CURL manually with a URL and Grep it works. But once in the loop i...
#### Using [xidel](/questions/tagged/xidel "show questions tagged 'xidel'") and [xpath](/questions/tagged/xpath "show questions tagged 'xpath'"): If you want to keep the most of your code: ``` dos2unix links.txt ``` then ``` while IFS= read -r url; do xidel -e '//p[contains(., "Telephone")]/a/text()' -s "$url...
735,356
<p>I have a big .txt file in below format</p> <pre><code> Pin name=&quot;AR_OP&quot; status=&quot;f&quot; Pref x=997.6800 y=2327.0400 side=N width=0.0400 depth=0.3750 / Layer id=1 -- Pin name=&quot;AW_OP&quot; status=&quot;f&quot; Pref x=997.6800 y=2327.0400 side=S width=0.0400 depth=0.3750 / ...
[ { "answer_id": 735357, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 0, "selected": false, "text": "<h4>Using <a href=\"/questions/tagged/xidel\" class=\"post-tag\" title=\"show questions tagged &#39;xidel&#39;\...
2023/02/13
[ "https://unix.stackexchange.com/questions/735356", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/436992/" ]
I have a big .txt file in below format ``` Pin name="AR_OP" status="f" Pref x=997.6800 y=2327.0400 side=N width=0.0400 depth=0.3750 / Layer id=1 -- Pin name="AW_OP" status="f" Pref x=997.6800 y=2327.0400 side=S width=0.0400 depth=0.3750 / Layer id=2 ``` I want the output as below: ``...
Replace all spaces by newlines, then pull out lines that are `Pin`, or that start with either `name=` or `side=`. This gives us lines in groups of three. Reformat each group of three lines into a single line with spaces as delimiters. ```bash $ tr ' ' '\n' <file | grep -e '^Pin$' -e '^name=' -e '^side=' | paste -d ' '...
735,359
<p>I want to use grep to only see a certain column from the output of a Linux command. When I use this command, I get the following output:</p> <pre><code>$ ps ax | grep sshd | grep 'priv' | sort -k 3 4886 ? Ss 0:00 sshd: vpnuser002 [priv] 10637 ? Ss 0:00 sshd: vpnuser003 [priv] ...
[ { "answer_id": 735357, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 0, "selected": false, "text": "<h4>Using <a href=\"/questions/tagged/xidel\" class=\"post-tag\" title=\"show questions tagged &#39;xidel&#39;\...
2023/02/13
[ "https://unix.stackexchange.com/questions/735359", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559110/" ]
I want to use grep to only see a certain column from the output of a Linux command. When I use this command, I get the following output: ``` $ ps ax | grep sshd | grep 'priv' | sort -k 3 4886 ? Ss 0:00 sshd: vpnuser002 [priv] 10637 ? Ss 0:00 sshd: vpnuser003 [priv] 10651 ? ...
Replace all spaces by newlines, then pull out lines that are `Pin`, or that start with either `name=` or `side=`. This gives us lines in groups of three. Reformat each group of three lines into a single line with spaces as delimiters. ```bash $ tr ' ' '\n' <file | grep -e '^Pin$' -e '^name=' -e '^side=' | paste -d ' '...
735,375
<p>I am trying to update the grub config on a Debian 11 VM. I was using the update-grub command, but this doesn't see to work anymore. I also tried grub-mkconfig &gt; /boot/grub/grub.cfg command, which also failed.Both commands fail with this error:</p> <pre><code>/usr/sbin/grub-mkconfig: 38: /etc/default/grub.d/grub.c...
[ { "answer_id": 735357, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 0, "selected": false, "text": "<h4>Using <a href=\"/questions/tagged/xidel\" class=\"post-tag\" title=\"show questions tagged &#39;xidel&#39;\...
2023/02/13
[ "https://unix.stackexchange.com/questions/735375", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/550314/" ]
I am trying to update the grub config on a Debian 11 VM. I was using the update-grub command, but this doesn't see to work anymore. I also tried grub-mkconfig > /boot/grub/grub.cfg command, which also failed.Both commands fail with this error: ``` /usr/sbin/grub-mkconfig: 38: /etc/default/grub.d/grub.cfg: function: no...
Replace all spaces by newlines, then pull out lines that are `Pin`, or that start with either `name=` or `side=`. This gives us lines in groups of three. Reformat each group of three lines into a single line with spaces as delimiters. ```bash $ tr ' ' '\n' <file | grep -e '^Pin$' -e '^name=' -e '^side=' | paste -d ' '...
735,386
<p>Having issues with trying to set variable (example: <code>str_pattern</code>) with multiple values and then using those in <code>sed</code> command to match range in reverse to previous blank line or back to <code>ExecuteThread</code>.</p> <ul> <li>Example script snippet <pre class="lang-bash prettyprint-override"><...
[ { "answer_id": 735406, "author": "cas", "author_id": 7696, "author_profile": "https://unix.stackexchange.com/users/7696", "pm_score": 1, "selected": false, "text": "<p>I'd use perl for this because it has an option (<code>-00</code>) for handling input in paragraphs (separated by one-or-...
2023/02/13
[ "https://unix.stackexchange.com/questions/735386", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560556/" ]
Having issues with trying to set variable (example: `str_pattern`) with multiple values and then using those in `sed` command to match range in reverse to previous blank line or back to `ExecuteThread`. * Example script snippet ```bash str_pattern="String1 String2" tac $file | sed -n '/'"$str_pattern"'/,/^$/p' | tac...
I'd use perl for this because it has an option (`-00`) for handling input in paragraphs (separated by one-or-more blank lines) and good multi-line string handling. Perl's `-n` option makes it work like `sed -n` (read and process the input without automatically printing each input line)....and `sed -p` makes it work li...
735,418
<p>I am trying to understand the difference between <code>command | getline var</code> and <code>command |&amp; getline var</code>. Which one should I normally use? Have been reading about coprocesses and two-way pipes, but need some explanation because things are becoming quite confusing.</p> <p>In actual practical ...
[ { "answer_id": 735425, "author": "Ed Morton", "author_id": 133219, "author_profile": "https://unix.stackexchange.com/users/133219", "pm_score": 2, "selected": false, "text": "<p>There is no coprocess in the code in your question - what you have is simply spawning a subshell to call <code...
2023/02/13
[ "https://unix.stackexchange.com/questions/735418", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559749/" ]
I am trying to understand the difference between `command | getline var` and `command |& getline var`. Which one should I normally use? Have been reading about coprocesses and two-way pipes, but need some explanation because things are becoming quite confusing. In actual practical terms, I am using ``` kmd=sprintf("%...
No, you should continue using simple "|". if your task is: give some data to external tool and use the result provided by that tool. Then a simple one-directional pipe is enough. The bi-directional pipe is needed only if: * you want to keep the same instance of the external tool in memory for the whole life-time of y...
735,421
<p>I have many markdown files which are hardwrapped to 80 characters. I would like to copy these to paste into textareas (<code>xclip -sel clipboard &lt; file</code>), but want them to wordwrap normally. This is simple w/o paragraphs - <code>tr &quot;\n&quot; &quot; &quot; &lt; file | xclip -sel clipboard</code>, but t...
[ { "answer_id": 735423, "author": "Iiridayn", "author_id": 9583, "author_profile": "https://unix.stackexchange.com/users/9583", "pm_score": 0, "selected": false, "text": "<p><code>tr &quot;\\n&quot; &quot; &quot; &lt; file | sed 's/ /\\n/g;s/ $//'</code> might work adequately. It require...
2023/02/13
[ "https://unix.stackexchange.com/questions/735421", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/9583/" ]
I have many markdown files which are hardwrapped to 80 characters. I would like to copy these to paste into textareas (`xclip -sel clipboard < file`), but want them to wordwrap normally. This is simple w/o paragraphs - `tr "\n" " " < file | xclip -sel clipboard`, but turns all text into a run-on paragraph which still r...
You could use `perl`: For example, using the following hard-wrapped example input file: ``` $ cat input.txt Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ...
735,440
<p>I have tried to use these rules with <code>iptables</code> but after I have used same rules in <code>ip6tables</code>, it has blocked everything.</p> <p>Why do my <code>ip6tables</code> rules block everything?</p> <pre><code>iptables -F OUTPUT iptables -A OUTPUT -j ACCEPT -m owner --uid-owner debian-tor iptables -A...
[ { "answer_id": 735423, "author": "Iiridayn", "author_id": 9583, "author_profile": "https://unix.stackexchange.com/users/9583", "pm_score": 0, "selected": false, "text": "<p><code>tr &quot;\\n&quot; &quot; &quot; &lt; file | sed 's/ /\\n/g;s/ $//'</code> might work adequately. It require...
2023/02/14
[ "https://unix.stackexchange.com/questions/735440", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560622/" ]
I have tried to use these rules with `iptables` but after I have used same rules in `ip6tables`, it has blocked everything. Why do my `ip6tables` rules block everything? ``` iptables -F OUTPUT iptables -A OUTPUT -j ACCEPT -m owner --uid-owner debian-tor iptables -A OUTPUT -j ACCEPT -o lo iptables -P OUTPUT DROP ip6t...
You could use `perl`: For example, using the following hard-wrapped example input file: ``` $ cat input.txt Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ...
735,444
<p>I'm using rsync to copy a file to a device:</p> <pre><code>sshpass -p &lt;password&gt; rsync -avzP &lt;file&gt; &lt;user&gt;@&lt;IP address&gt;:&lt;folder&gt; </code></pre> <p>This has worked fine in the past but I was trying to copy to a new device and got:</p> <pre><code>Host key verification failed. rsync error: ...
[ { "answer_id": 735449, "author": "Dr.Sherif Omran", "author_id": 284061, "author_profile": "https://unix.stackexchange.com/users/284061", "pm_score": 1, "selected": false, "text": "<p>You need to remove the <code>known_hosts</code> file located in this path <code>~/.ssh/known_hosts</code...
2023/02/14
[ "https://unix.stackexchange.com/questions/735444", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/18571/" ]
I'm using rsync to copy a file to a device: ``` sshpass -p <password> rsync -avzP <file> <user>@<IP address>:<folder> ``` This has worked fine in the past but I was trying to copy to a new device and got: ``` Host key verification failed. rsync error: unexplained error (code 255) at rsync.c(703) [sender=3.2.3] ```...
If `StrictHostKeyChecking` is set to `accept-new` or `no`, new hosts are automatically added to the `~/.ssh/known_hosts` file. The default is to `ask`. If a host key changes, you will get a warning message that begins like this ``` @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST ...
735,480
<p>There was a case where an scp command returned response code &gt; 0 but the files where successfully copied and finally loaded in a db which means that they were not corrupted.</p> <p>Does Unix SCP command continues to copy files althouth the response code is &gt; 0? If resp &gt; 0 the files should the files be corr...
[ { "answer_id": 735449, "author": "Dr.Sherif Omran", "author_id": 284061, "author_profile": "https://unix.stackexchange.com/users/284061", "pm_score": 1, "selected": false, "text": "<p>You need to remove the <code>known_hosts</code> file located in this path <code>~/.ssh/known_hosts</code...
2023/02/14
[ "https://unix.stackexchange.com/questions/735480", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560672/" ]
There was a case where an scp command returned response code > 0 but the files where successfully copied and finally loaded in a db which means that they were not corrupted. Does Unix SCP command continues to copy files althouth the response code is > 0? If resp > 0 the files should the files be corrupted or not even ...
If `StrictHostKeyChecking` is set to `accept-new` or `no`, new hosts are automatically added to the `~/.ssh/known_hosts` file. The default is to `ask`. If a host key changes, you will get a warning message that begins like this ``` @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST ...
735,489
<p>My USB device (a OnePlus 10T smartphone) connected to a CentOS 7 server occasionally shows up with &quot;wrong&quot; (Google's) vendor:product IDs in <em>lsusb</em> output upon reboot:</p> <pre><code>Bus 002 Device 003: ID 18d1:4ee8 Google Inc. Nexus/Pixel Device (MIDI) </code></pre> <p>When I disconnect and reconne...
[ { "answer_id": 735491, "author": "Marcus Müller", "author_id": 106650, "author_profile": "https://unix.stackexchange.com/users/106650", "pm_score": 1, "selected": false, "text": "<p>You can't. That's a fundamental property of the USB device. It's not under control of your PC.</p>\n<p>Wha...
2023/02/14
[ "https://unix.stackexchange.com/questions/735489", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/442785/" ]
My USB device (a OnePlus 10T smartphone) connected to a CentOS 7 server occasionally shows up with "wrong" (Google's) vendor:product IDs in *lsusb* output upon reboot: ``` Bus 002 Device 003: ID 18d1:4ee8 Google Inc. Nexus/Pixel Device (MIDI) ``` When I disconnect and reconnect its USB cable they usually change to t...
No, you can't do that. This information is read from the device by the hardware during device recognition and then made available to the kernel. What you can do is you can force some driver to recognize this device: ``` echo 2-7:1.0 > /sys/bus/usb/drivers/<drivername>/bind ``` This `2-7:1.0` is a USB bus address of...
735,495
<p>I use MacOS and I have variable <code>date</code> in format</p> <pre><code>3.Jan.2023, 12.Nov.2017, 9.Apr.2022, ... </code></pre> <p>I need to change in</p> <pre><code>03.01.2023, 12.11.2017, 09.04.2022, ... </code></pre>
[ { "answer_id": 735498, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 2, "selected": false, "text": "<p>You can use <code>awk</code> to convert from one format to the other:</p>\n<pre><code>awk -F. '\n BEGIN { m[&q...
2023/02/14
[ "https://unix.stackexchange.com/questions/735495", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560687/" ]
I use MacOS and I have variable `date` in format ``` 3.Jan.2023, 12.Nov.2017, 9.Apr.2022, ... ``` I need to change in ``` 03.01.2023, 12.11.2017, 09.04.2022, ... ```
MacOS [`date`](https://www.unix.com/man-page/osx/1/date/) allows you specify input and output formats for conversions: ``` for inp in "3.Jan.2023" "12.Nov.2017" "9.Apr.2022"; do date -j -f "%d.%b.%Y" "$inp" "+%d.%m.%Y" done ``` According to [`strptime()`](https://pubs.opengroup.org/onlinepubs/007904875/functions...
735,505
<p>I am trying to write a script which has a condition based on a <a href="https://stackoverflow.com/questions/8063228/check-if-a-variable-exists-in-a-list-in-bash">variable appearing in a list</a>:</p> <pre><code>#!/bin/bash LIST=`ls` function listcontains() { [[ $1 =~ (^|[[:space:]])$2($|[[:space:]]) ]] &amp;&a...
[ { "answer_id": 735498, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 2, "selected": false, "text": "<p>You can use <code>awk</code> to convert from one format to the other:</p>\n<pre><code>awk -F. '\n BEGIN { m[&q...
2023/02/14
[ "https://unix.stackexchange.com/questions/735505", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/9178/" ]
I am trying to write a script which has a condition based on a [variable appearing in a list](https://stackoverflow.com/questions/8063228/check-if-a-variable-exists-in-a-list-in-bash): ``` #!/bin/bash LIST=`ls` function listcontains() { [[ $1 =~ (^|[[:space:]])$2($|[[:space:]]) ]] && return 0 || return 1 } if [...
MacOS [`date`](https://www.unix.com/man-page/osx/1/date/) allows you specify input and output formats for conversions: ``` for inp in "3.Jan.2023" "12.Nov.2017" "9.Apr.2022"; do date -j -f "%d.%b.%Y" "$inp" "+%d.%m.%Y" done ``` According to [`strptime()`](https://pubs.opengroup.org/onlinepubs/007904875/functions...
735,518
<p>Let’s say I have two containers X and Y (two containers in the same Kubernetes pod, actually) that share a volume. On that volume is a named pipe <code>/foo</code> that I want attached to a bash process on container Y. As container X sends data to container Y, I want it to work the same way the e.g., <code>ssh</code...
[ { "answer_id": 735552, "author": "telometto", "author_id": 469646, "author_profile": "https://unix.stackexchange.com/users/469646", "pm_score": 2, "selected": false, "text": "<p>To attach a bash shell to a named pipe, you can use the <code>exec</code> command to replace the current shell...
2023/02/14
[ "https://unix.stackexchange.com/questions/735518", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/157130/" ]
Let’s say I have two containers X and Y (two containers in the same Kubernetes pod, actually) that share a volume. On that volume is a named pipe `/foo` that I want attached to a bash process on container Y. As container X sends data to container Y, I want it to work the same way the e.g., `ssh` works: the command shou...
OK, with the help of telometto, Kamil and Greg A. Woods, I arrived at the following solution, which seems to meet my needs: * On the shared volume, create *three* named pipes, `stdin`, `stdout` and `stderr` * On machine Y, run `while true; do bash -s < stdin 2> stderr > stdout ; done` * On machine X I created a helper...
735,572
<p>When I look at the groups that user 'wim' is a member of, <code>www-data</code> group does not show. When I look at the members of <code>www-data</code>, user <code>wim</code> is listed.</p> <pre><code>$ groups wim adm cdrom sudo dip plugdev lpadmin sambashare $ members wim wim $ members www-data www-data wim </code...
[ { "answer_id": 735582, "author": "anatak", "author_id": 60871, "author_profile": "https://unix.stackexchange.com/users/60871", "pm_score": 0, "selected": false, "text": "<p>Restarting my system solved this problem.</p>\n" }, { "answer_id": 735602, "author": "ctrl-alt-delor", ...
2023/02/15
[ "https://unix.stackexchange.com/questions/735572", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/60871/" ]
When I look at the groups that user 'wim' is a member of, `www-data` group does not show. When I look at the members of `www-data`, user `wim` is listed. ``` $ groups wim adm cdrom sudo dip plugdev lpadmin sambashare $ members wim wim $ members www-data www-data wim ``` When trying to rename a file that is owned by ...
Permission to create a file (used by the `mv` command), is given by the directory. You have not shown the mode of the directory, so we can not say more on this. Adding a user to a group, just changes a file (`/etc/groups`). I process inherits groups from its parent, or is given groups by the login process (the login p...
735,587
<p>I have ssh keypair on my ansible_host, which I want to copy to multiple user's authorized keys on target host.</p> <p>I'm trying with-item construct, but it complaints about .pub key not an invalid key here's what I'm trying.</p> <pre><code>- authorized_key: user: &quot;{{ item.user }}&quot; key: &quot;{{ it...
[ { "answer_id": 735589, "author": "Mr. Diba", "author_id": 519184, "author_profile": "https://unix.stackexchange.com/users/519184", "pm_score": 2, "selected": false, "text": "<p>This is because you are inserting the key as a string into the key field.</p>\n<p>You should use the <a href=\"...
2023/02/15
[ "https://unix.stackexchange.com/questions/735587", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/117409/" ]
I have ssh keypair on my ansible\_host, which I want to copy to multiple user's authorized keys on target host. I'm trying with-item construct, but it complaints about .pub key not an invalid key here's what I'm trying. ``` - authorized_key: user: "{{ item.user }}" key: "{{ item.key }}" with_items: ...
If you only need to copy your key to multiple users you can do it like that : ```yaml - authorized_key: user: "{{ item.user }}" key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}" with_items: - { user: "user1" } - { user: "user2" } ```
735,591
<p>How can I share my <code>.bashrc</code> file but only relevant part?</p> <p>For example I created 5 functions in <code>.bashrc</code>:</p> <pre class="lang-bash prettyprint-override"><code>f1() { ... } f2() { f1 ... } f3() { f2 ... } f4() { f1 f3 ... } f5() { ... } </code></pre> <p>Case ...
[ { "answer_id": 735589, "author": "Mr. Diba", "author_id": 519184, "author_profile": "https://unix.stackexchange.com/users/519184", "pm_score": 2, "selected": false, "text": "<p>This is because you are inserting the key as a string into the key field.</p>\n<p>You should use the <a href=\"...
2023/02/15
[ "https://unix.stackexchange.com/questions/735591", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/189721/" ]
How can I share my `.bashrc` file but only relevant part? For example I created 5 functions in `.bashrc`: ```bash f1() { ... } f2() { f1 ... } f3() { f2 ... } f4() { f1 f3 ... } f5() { ... } ``` Case 1: I want to share `f5()` with my colleagues, so I only have to copy `f5()` and paste to...
If you only need to copy your key to multiple users you can do it like that : ```yaml - authorized_key: user: "{{ item.user }}" key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}" with_items: - { user: "user1" } - { user: "user2" } ```
735,607
<p>I am debugging an embedded server that outputs a continuous single line of text to a specified network port. There is no newline anywhere in the stream but it is text data and I would like to format it as it outputs. I have tried using tr (translate) to swap a character in the stream for a newline which works, howev...
[ { "answer_id": 735614, "author": "terdon", "author_id": 22222, "author_profile": "https://unix.stackexchange.com/users/22222", "pm_score": 3, "selected": false, "text": "<p>That's what <code>fold</code> is for:</p>\n<pre><code>NAME\n fold - wrap each input line to fit in specified ...
2023/02/15
[ "https://unix.stackexchange.com/questions/735607", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/53886/" ]
I am debugging an embedded server that outputs a continuous single line of text to a specified network port. There is no newline anywhere in the stream but it is text data and I would like to format it as it outputs. I have tried using tr (translate) to swap a character in the stream for a newline which works, however ...
Solution worked out as ``` stdbuf -o0 ncat -ul 51002 | stdbuf -o0 fold | sed "s/\[15/\&\[15/g" -u | stdbuf -o0 tr -d '\n' | tr "&" "\n" ``` Where [15 was the pattern I wanted to prepend a newline to. A bit of a workaround but it worked well.
735,635
<p>In a file manager you can usually select a file, then hold <kbd>Shift</kbd> and select another file. Every file in between will be selected.</p> <p><strong>I want to do the <code>bash</code> / <code>zsh</code> equivalent of this.</strong></p> <p>I.e: I want to give 2 filenames and have every filename in between (in ...
[ { "answer_id": 735676, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 3, "selected": false, "text": "<p>Using a bash function:</p>\n<pre><code>sfiles ()\n(\n # run this in a subshell, so we don't have to care if nu...
2023/02/15
[ "https://unix.stackexchange.com/questions/735635", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560850/" ]
In a file manager you can usually select a file, then hold `Shift` and select another file. Every file in between will be selected. **I want to do the `bash` / `zsh` equivalent of this.** I.e: I want to give 2 filenames and have every filename in between (in alphabetical order - the way `ls` outputs them). I am awar...
Using a bash function: ``` sfiles () ( # run this in a subshell, so we don't have to care if nullglob/dotglob were enabled or not [ $# -eq 0 ] && exit local nullsep=0 if [ "$1" = "-0" ]; then nullsep=1; shift fi local first=$1 shift $(($# -1)) local last=$1 local files=( ) ...
735,653
<p>The following script demonstrates my problem, which is to determine if the <code>sox_user_auditd_v2r -c</code> process is running:</p> <pre><code>$ cat ./pgrep_stackexchange_sample.bash #!/bin/bash -xv quoted=&quot;\'$@\'&quot; #if pgrep -x -f $@ &gt; /dev/null; then #if pgrep -x -f $quoted &gt; /dev/null; then #i...
[ { "answer_id": 735659, "author": "ilkkachu", "author_id": 170373, "author_profile": "https://unix.stackexchange.com/users/170373", "pm_score": 2, "selected": false, "text": "<blockquote>\n<pre><code>quoted=&quot;\\'$@\\'&quot;\n</code></pre>\n</blockquote>\n<p>This concatenates the posit...
2023/02/15
[ "https://unix.stackexchange.com/questions/735653", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/111201/" ]
The following script demonstrates my problem, which is to determine if the `sox_user_auditd_v2r -c` process is running: ``` $ cat ./pgrep_stackexchange_sample.bash #!/bin/bash -xv quoted="\'$@\'" #if pgrep -x -f $@ > /dev/null; then #if pgrep -x -f $quoted > /dev/null; then #if pgrep -f $quoted > /dev/null; then #if...
> > > ``` > quoted="\'$@\'" > > ``` > > This concatenates the positional parameters (arguments to the script), joined with spaces, and adds those backslashes and single quotes at the start and end. So you get e.g. `\'sox_user_auditd_v2r -c\'` > > > ``` > pgrep -x -- $quoted > > ``` > > This splits the stri...
735,657
<p>Running an update with the following command :</p> <p><code>apt-get update</code></p> <p>returns :</p> <pre><code>Hit:1 http://kali.download/kali kali-rolling InRelease Traceback (most recent call last): File &quot;/usr/lib/cnf-update-db&quot;, line 27, in &lt;module&gt; col.create(db) File &quot;/usr/share/...
[ { "answer_id": 735669, "author": "Stephen Kitt", "author_id": 86440, "author_profile": "https://unix.stackexchange.com/users/86440", "pm_score": 2, "selected": false, "text": "<p>Kali has a new section, <code>non-free-firmware</code>, but the version of <code>command-not-found</code> you...
2023/02/15
[ "https://unix.stackexchange.com/questions/735657", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560877/" ]
Running an update with the following command : `apt-get update` returns : ``` Hit:1 http://kali.download/kali kali-rolling InRelease Traceback (most recent call last): File "/usr/lib/cnf-update-db", line 27, in <module> col.create(db) File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 95...
Kali has a new section, `non-free-firmware`, but the version of `command-not-found` you have doesn’t know about it (it was [added in version 23.04.0](https://tracker.debian.org/news/1411346/accepted-command-not-found-23040-1-source-into-unstable/)). To fix this, disable the hook: ``` sudo mv /etc/apt/apt.conf.d/50com...
735,658
<p>Once I list the backup files from a server, It throws me the output as follows:</p> <pre><code>{ &quot;backupFiles&quot;: [ &quot;XYZ_Backup_2.0.0.0-417_2022_08_14_12_10.gz&quot;, &quot;XYZ_Backup_2.0.0.0-417_2022_08_13_11_20.gz&quot;, &quot;XYZ_Backup_2.0.0.0-417_2022_08_13_15_11.gz&quot...
[ { "answer_id": 735662, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 1, "selected": false, "text": "<p>The canonical way to go with your <a href=\"/questions/tagged/json\" class=\"post-tag\" title=\"show questio...
2023/02/15
[ "https://unix.stackexchange.com/questions/735658", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560884/" ]
Once I list the backup files from a server, It throws me the output as follows: ``` { "backupFiles": [ "XYZ_Backup_2.0.0.0-417_2022_08_14_12_10.gz", "XYZ_Backup_2.0.0.0-417_2022_08_13_11_20.gz", "XYZ_Backup_2.0.0.0-417_2022_08_13_15_11.gz", ], "total": 3 } ``` I stored the output ...
While this is indeed broken JSON, it's (at least as far as I can tell) valid YAML (which is mostly a superset of JSON, so wide it's hard to tell what's valid or not. I wish it wasn't.). So, tools written for YAML can deal with it. I use [`yq`](https://kislyuk.github.io/yq/), which is but a wrapper around `jq`, which c...
735,664
<p>Without having access to the physical display, how can I know if my computer is being booted by grub or systemd-boot?</p> <p>As I have writted on the tittle I have both <code>/boot/grub/</code> and <code>/boot/efi/EFI/systemd/</code> folders.</p> <p>On the other hand <code>dd if=/dev/sda bs=512 count=1 2&gt;/dev/nul...
[ { "answer_id": 735675, "author": "ron", "author_id": 154426, "author_profile": "https://unix.stackexchange.com/users/154426", "pm_score": -1, "selected": false, "text": "<p><a href=\"https://itsfoss.com/check-uefi-or-bios/\" rel=\"nofollow noreferrer\">https://itsfoss.com/check-uefi-or-b...
2023/02/15
[ "https://unix.stackexchange.com/questions/735664", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/444593/" ]
Without having access to the physical display, how can I know if my computer is being booted by grub or systemd-boot? As I have writted on the tittle I have both `/boot/grub/` and `/boot/efi/EFI/systemd/` folders. On the other hand `dd if=/dev/sda bs=512 count=1 2>/dev/null | strings` returns the following: ``` ZRr=...
The fact that `efibootmgr -v` works proves your system has UEFI runtime services enabled, which can only happen when the system is booted in UEFI mode. (As Marcus Müller said in the comments, the reverse inference cannot be made: it would be possible to boot in UEFI mode even without UEFI runtime services being enable...
735,666
<p>Assume I have many <code>*.txt</code> files on directory <code>texts</code> with the below contents.</p> <pre><code>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam tincidunt mauris eu risus. Vestibulum auctor dapibus neque. </code></pre> <p>And I want to replace them with the following contents <st...
[ { "answer_id": 735686, "author": "Peregrino69", "author_id": 90878, "author_profile": "https://unix.stackexchange.com/users/90878", "pm_score": 0, "selected": false, "text": "<p>Here's one way, done in Debian 11:</p>\n<ul>\n<li>bash v.5.1.4(1)</li>\n<li>tr (GNU Coreutils) v.8.32</li>\n<l...
2023/02/15
[ "https://unix.stackexchange.com/questions/735666", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/530972/" ]
Assume I have many `*.txt` files on directory `texts` with the below contents. ``` Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam tincidunt mauris eu risus. Vestibulum auctor dapibus neque. ``` And I want to replace them with the following contents **recursively**. ``` Vestibulum commodo felis qu...
I'd use perl instead of sed (or awk): ``` find texts/ -name '*.txt' \ -exec perl -0777 -p -i.bak -e ' BEGIN { $search = q{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam tincidunt mauris eu risus. Vestibulum auctor dapibus neque}; $replace = q{Vestibulum commodo felis quis tortor. ...
735,688
<p>I found this question and it solved 99% of my issue but I can't figure out to match the end pattern with <code>^</code>. <a href="https://unix.stackexchange.com/questions/228699/sed-print-lines-matched-by-a-pattern-range-if-one-line-matches-a-condition">sed - Print lines matched by a pattern range if one line matche...
[ { "answer_id": 735691, "author": "don_crissti", "author_id": 22142, "author_profile": "https://unix.stackexchange.com/users/22142", "pm_score": 2, "selected": false, "text": "<p>When you are accumulating lines in the pattern space you can no longer use <code>^</code> to match the beginn...
2023/02/15
[ "https://unix.stackexchange.com/questions/735688", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560914/" ]
I found this question and it solved 99% of my issue but I can't figure out to match the end pattern with `^`. [sed - Print lines matched by a pattern range if one line matches a condition](https://unix.stackexchange.com/questions/228699/sed-print-lines-matched-by-a-pattern-range-if-one-line-matches-a-condition) Here a...
When you are accumulating lines in the pattern space you can no longer use `^` to match the beginning of subsequent lines and have to use `\n` (embedded newline) instead: ``` sed -n '/(/{:a;N;/\n)/!ba; /Device=A/p}' infile ``` although I very much prefer [Costas' solution](https://unix.stackexchange.com/a/228737) ov...
735,690
<p>Edit:: With the help of people, I realised I misunderstood the text and thought the creators Ubuntu also created <code>sudo</code>, which is not the case! So the question should be something like how forcing people to use <code>sudo</code> instead of <code>su</code> improve the level of security?</p> <hr /> <p>I am ...
[ { "answer_id": 735691, "author": "don_crissti", "author_id": 22142, "author_profile": "https://unix.stackexchange.com/users/22142", "pm_score": 2, "selected": false, "text": "<p>When you are accumulating lines in the pattern space you can no longer use <code>^</code> to match the beginn...
2023/02/16
[ "https://unix.stackexchange.com/questions/735690", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/560916/" ]
Edit:: With the help of people, I realised I misunderstood the text and thought the creators Ubuntu also created `sudo`, which is not the case! So the question should be something like how forcing people to use `sudo` instead of `su` improve the level of security? --- I am reading *The Linux Command Line* by *William...
When you are accumulating lines in the pattern space you can no longer use `^` to match the beginning of subsequent lines and have to use `\n` (embedded newline) instead: ``` sed -n '/(/{:a;N;/\n)/!ba; /Device=A/p}' infile ``` although I very much prefer [Costas' solution](https://unix.stackexchange.com/a/228737) ov...
735,757
<p>I have the following JSON file located at <code>/tmp/target.json</code>:</p> <pre><code>{ &quot;compileOnSave&quot;: false, &quot;compilerOptions&quot;: { &quot;baseUrl&quot;: &quot;./&quot;, ... } } </code></pre> <p>I want to add a new key value pair so it will be as follows:</p> <pre><code>{ &quot;...
[ { "answer_id": 735762, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this:</p>\n<pre><code>$ jq '.compilerOptions.skipLibCheck=true' file.json\n{\n &quot;compileOnSave&quo...
2023/02/16
[ "https://unix.stackexchange.com/questions/735757", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/255545/" ]
I have the following JSON file located at `/tmp/target.json`: ``` { "compileOnSave": false, "compilerOptions": { "baseUrl": "./", ... } } ``` I want to add a new key value pair so it will be as follows: ``` { "compileOnSave": false, "compilerOptions": { "skipLibCheck": true, "baseUrl": "./...
The easiest way to add the key with its value has been covered [in another answer](https://unix.stackexchange.com/a/735762/116858). That answer adds the key to the end of the list of keys in the `compilerOptions` object. Normally, the ordering of the keys does not matter, and if you need things ordered in a particular ...
735,760
<p>I'm currently coding a network configuration role used by Ansible to customize our fresh new virtual machine that came from our Debian 11 template.</p> <p>I got a weird issue while I try to set up and configure 2 physical network interfaces. When i deploy a new VM from my template, it has 2 separate vmnics, from a d...
[ { "answer_id": 735762, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this:</p>\n<pre><code>$ jq '.compilerOptions.skipLibCheck=true' file.json\n{\n &quot;compileOnSave&quo...
2023/02/16
[ "https://unix.stackexchange.com/questions/735760", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555134/" ]
I'm currently coding a network configuration role used by Ansible to customize our fresh new virtual machine that came from our Debian 11 template. I got a weird issue while I try to set up and configure 2 physical network interfaces. When i deploy a new VM from my template, it has 2 separate vmnics, from a debian per...
The easiest way to add the key with its value has been covered [in another answer](https://unix.stackexchange.com/a/735762/116858). That answer adds the key to the end of the list of keys in the `compilerOptions` object. Normally, the ordering of the keys does not matter, and if you need things ordered in a particular ...
735,807
<p>I used to bind mount my <code>/usr</code> from another volume, as my root volume is almost full. However, with KUbuntu 22.04.1 LTS, I.e., <code>systemd</code> ver 249.11, I found it impossible now.</p> <p>Here is how I did it before in <code>/etc/fstab</code>:</p> <pre><code>LABEL=bigvol /bigvol auto defa...
[ { "answer_id": 735762, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this:</p>\n<pre><code>$ jq '.compilerOptions.skipLibCheck=true' file.json\n{\n &quot;compileOnSave&quo...
2023/02/16
[ "https://unix.stackexchange.com/questions/735807", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/374303/" ]
I used to bind mount my `/usr` from another volume, as my root volume is almost full. However, with KUbuntu 22.04.1 LTS, I.e., `systemd` ver 249.11, I found it impossible now. Here is how I did it before in `/etc/fstab`: ``` LABEL=bigvol /bigvol auto defaults,noatime,nodiratime,barrier=1,ro 0 2 /bigvol/d-...
The easiest way to add the key with its value has been covered [in another answer](https://unix.stackexchange.com/a/735762/116858). That answer adds the key to the end of the list of keys in the `compilerOptions` object. Normally, the ordering of the keys does not matter, and if you need things ordered in a particular ...
735,824
<p>When I installed Linux I set my locale to <code>en_US.UTF-8</code>. However I want to override some but not all of the settings in that locale. Specifically, I would like the <code>Measurement</code> to be <code>Metric</code> instead of <code>Imperial</code> and the <code>Date</code> to be <code>DD/MM/YYYY</code> i...
[ { "answer_id": 735762, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this:</p>\n<pre><code>$ jq '.compilerOptions.skipLibCheck=true' file.json\n{\n &quot;compileOnSave&quo...
2023/02/17
[ "https://unix.stackexchange.com/questions/735824", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561105/" ]
When I installed Linux I set my locale to `en_US.UTF-8`. However I want to override some but not all of the settings in that locale. Specifically, I would like the `Measurement` to be `Metric` instead of `Imperial` and the `Date` to be `DD/MM/YYYY` instead of `MM/DD/YYYY`. How can I do this?
The easiest way to add the key with its value has been covered [in another answer](https://unix.stackexchange.com/a/735762/116858). That answer adds the key to the end of the list of keys in the `compilerOptions` object. Normally, the ordering of the keys does not matter, and if you need things ordered in a particular ...
735,838
<p>I have a file with below content, where few lines are of length 15 while rest are less than 15.</p> <pre><code>AAAAAAAAAAAAA BBBBBBBB cccc </code></pre> <p>I need an output in below way.</p> <p>Delete Subscriber:</p> <pre><code>AAAAAAAAAAAAA </code></pre> <p>in</p> <pre><code>IMSI=AAAAAAAAAAAAA,dc=imsi,ou=NPSD,serv=...
[ { "answer_id": 735762, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this:</p>\n<pre><code>$ jq '.compilerOptions.skipLibCheck=true' file.json\n{\n &quot;compileOnSave&quo...
2023/02/17
[ "https://unix.stackexchange.com/questions/735838", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/510444/" ]
I have a file with below content, where few lines are of length 15 while rest are less than 15. ``` AAAAAAAAAAAAA BBBBBBBB cccc ``` I need an output in below way. Delete Subscriber: ``` AAAAAAAAAAAAA ``` in ``` IMSI=AAAAAAAAAAAAA,dc=imsi,ou=NPSD,serv=CSPS,ou=servCommonData,dc=te ``` Delete Subscriber: `BBBBBB...
The easiest way to add the key with its value has been covered [in another answer](https://unix.stackexchange.com/a/735762/116858). That answer adds the key to the end of the list of keys in the `compilerOptions` object. Normally, the ordering of the keys does not matter, and if you need things ordered in a particular ...
735,859
<p>I am trying to automate a shell script that use Xdotol (press B key with random interval -sec.milsec).</p> <p>I am unable to to run script random number of times (right now it is limited to 25 times by count). I am looking for a way o get random number for a count (in range 20-45) or any other idea how can I get ran...
[ { "answer_id": 735762, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this:</p>\n<pre><code>$ jq '.compilerOptions.skipLibCheck=true' file.json\n{\n &quot;compileOnSave&quo...
2023/02/17
[ "https://unix.stackexchange.com/questions/735859", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561149/" ]
I am trying to automate a shell script that use Xdotol (press B key with random interval -sec.milsec). I am unable to to run script random number of times (right now it is limited to 25 times by count). I am looking for a way o get random number for a count (in range 20-45) or any other idea how can I get random numbe...
The easiest way to add the key with its value has been covered [in another answer](https://unix.stackexchange.com/a/735762/116858). That answer adds the key to the end of the list of keys in the `compilerOptions` object. Normally, the ordering of the keys does not matter, and if you need things ordered in a particular ...
735,863
<p>I have one file which is gets details from ldapsearch command and create file as below</p> <pre><code># lschuler, people, pl.s2-eu.XXXXXXXXX.local dn: uid=lschuler,ou=people,dc=pl,dc=s2-eu,dc=XXXXXXXXX,dc=local objectClass: posixAccount objectClass: inetOrgPerson objectClass: organizationalPerson objectClass: person...
[ { "answer_id": 735762, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this:</p>\n<pre><code>$ jq '.compilerOptions.skipLibCheck=true' file.json\n{\n &quot;compileOnSave&quo...
2023/02/17
[ "https://unix.stackexchange.com/questions/735863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/434257/" ]
I have one file which is gets details from ldapsearch command and create file as below ``` # lschuler, people, pl.s2-eu.XXXXXXXXX.local dn: uid=lschuler,ou=people,dc=pl,dc=s2-eu,dc=XXXXXXXXX,dc=local objectClass: posixAccount objectClass: inetOrgPerson objectClass: organizationalPerson objectClass: person loginShell: ...
The easiest way to add the key with its value has been covered [in another answer](https://unix.stackexchange.com/a/735762/116858). That answer adds the key to the end of the list of keys in the `compilerOptions` object. Normally, the ordering of the keys does not matter, and if you need things ordered in a particular ...
735,873
<p>I am trying to secure my Apache2 installation on my Ubuntu 22.04 server, using OWASP rules with ModSecurity, but when I installed the v3.3.4 rules and activated modsecurity, Apache2 won't start.</p> <p>Packages installed:</p> <pre><code>apache2 2.4.52-1ubuntu4.3 apache2-bin ...
[ { "answer_id": 735884, "author": "Romeo Ninov", "author_id": 101265, "author_profile": "https://unix.stackexchange.com/users/101265", "pm_score": 1, "selected": false, "text": "<p>As you can read in config file:</p>\n<blockquote>\n<p>It requires ModSecurity version 2.9.6 or 3.0.8</p>\n</...
2023/02/17
[ "https://unix.stackexchange.com/questions/735873", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/444051/" ]
I am trying to secure my Apache2 installation on my Ubuntu 22.04 server, using OWASP rules with ModSecurity, but when I installed the v3.3.4 rules and activated modsecurity, Apache2 won't start. Packages installed: ``` apache2 2.4.52-1ubuntu4.3 apache2-bin 2.4.5...
The problem in short is that the mod security packages are outdated even in the latest Ubuntu releases (22.04 at the time). I found a closed issue here: <https://github.com/coreruleset/coreruleset/issues/3129> which suggests to use this repo <https://modsecurity.digitalwave.hu/> to upgrade/install the packages `libap...
735,914
<p>We have a platform on which multiple people can be working on the same packages. As such we would like to maintain each persons individual git credentials so it's not just one person's sshkey and one person all over the commit history.</p> <p>We had an idea that there could be users such that:</p> <ul> <li><code>pla...
[ { "answer_id": 735926, "author": "Marcus Müller", "author_id": 106650, "author_profile": "https://unix.stackexchange.com/users/106650", "pm_score": 2, "selected": false, "text": "<blockquote>\n<p>As such we would like to maintain each persons individual git credentials so it's not just o...
2023/02/17
[ "https://unix.stackexchange.com/questions/735914", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/424227/" ]
We have a platform on which multiple people can be working on the same packages. As such we would like to maintain each persons individual git credentials so it's not just one person's sshkey and one person all over the commit history. We had an idea that there could be users such that: * `platform_name` is the main ...
> > As such we would like to maintain each persons individual git credentials so it's not just one person's sshkey and one person all over the commit history. > > > Yes, that's the standard use case: git is a distributed version control system. Everybody works on their own, local copy. Cooperation happens by them ...
735,925
<p>I want to change the text colour in a shell. I can use <code>tput</code> to get the correct escape codes. For example,</p> <pre class="lang-bash prettyprint-override"><code>echo &quot;$(tput setaf 5)My text$(tput sgr0)&quot; </code></pre> <p>outputs <code>My text</code> in a pink-ish tone.</p> <p>This works fine on ...
[ { "answer_id": 735937, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 1, "selected": false, "text": "<p>Standard expectations from as far back as I can remember using <code>tput</code> on a variety of UNIX-type system...
2023/02/17
[ "https://unix.stackexchange.com/questions/735925", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/422587/" ]
I want to change the text colour in a shell. I can use `tput` to get the correct escape codes. For example, ```bash echo "$(tput setaf 5)My text$(tput sgr0)" ``` outputs `My text` in a pink-ish tone. This works fine on Linux, macOS, FreeBSD, NetBSD, and Solaris. On OpenBSD 7.2, however, I get the following error: ...
Standard expectations from as far back as I can remember using `tput` on a variety of UNIX-type systems (two decades? probably more) are: * The `tput setaf` requires a single number following that indicates the ANSI colour number to use. *Anything else is likely to be a bug.* * `tput sgr0` requires no parameter. * You...
735,927
<p>Is there a way to display aliases <em>after</em> bash has made the substitutions?</p> <p><strong>Background:</strong><br /> I have a long alias that performs actions on a directory.</p> <pre><code>alias do_it='cd my_working_dir; do_stuff' </code></pre> <p>This works fine, but the alias is quite long and <code>my_wor...
[ { "answer_id": 735937, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 1, "selected": false, "text": "<p>Standard expectations from as far back as I can remember using <code>tput</code> on a variety of UNIX-type system...
2023/02/17
[ "https://unix.stackexchange.com/questions/735927", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/10721/" ]
Is there a way to display aliases *after* bash has made the substitutions? **Background:** I have a long alias that performs actions on a directory. ``` alias do_it='cd my_working_dir; do_stuff' ``` This works fine, but the alias is quite long and `my_working_dir` changes often. Rather than do a in-depth search ...
Standard expectations from as far back as I can remember using `tput` on a variety of UNIX-type systems (two decades? probably more) are: * The `tput setaf` requires a single number following that indicates the ANSI colour number to use. *Anything else is likely to be a bug.* * `tput sgr0` requires no parameter. * You...
735,930
<p>At wit's end, I am working with:</p> <p>debian-11.6.0-amd64-netinst.iso, and Dell Latitude 7390 with Win10 Pro</p> <p>Installer does not see the laptop's disk</p> <p>I have tried:</p> <ol> <li>Standard procedure for installer to partition</li> <li>Pre-preparing partitions with W10</li> <li>Turning off Secure boot</l...
[ { "answer_id": 735938, "author": "telcoM", "author_id": 258991, "author_profile": "https://unix.stackexchange.com/users/258991", "pm_score": 2, "selected": false, "text": "<p>As expected with modern laptops, the &quot;disk&quot; is actually a SSD. <a href=\"https://dl.dell.com/topicspdf/...
2023/02/17
[ "https://unix.stackexchange.com/questions/735930", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561195/" ]
At wit's end, I am working with: debian-11.6.0-amd64-netinst.iso, and Dell Latitude 7390 with Win10 Pro Installer does not see the laptop's disk I have tried: 1. Standard procedure for installer to partition 2. Pre-preparing partitions with W10 3. Turning off Secure boot 4. Change from default RAID to AHCI, W10 won...
As expected with modern laptops, the "disk" is actually a SSD. [The hardware vendor's SSD replacement documentation](https://dl.dell.com/topicspdf/latitude-13-7390-laptop_install-guide2_en-us.pdf) identifies its physical form as a M.2 2230 SSD. It is probably a NVMe SSD, so it will require that the `nvme` module is lo...
735,939
<p>I have a folder with subdirectories and those subdirectories have more subdirectories where I want the command to be executed. The code below is the script I have made so far.</p> <pre><code>#!/bin/bash for i in `ls -d ./*/`; do cd &quot;$i&quot; for x in `ls -d ./*/` cd &quot;$x&quot; gzip -d *.mol2.gz mv *.mol...
[ { "answer_id": 735943, "author": "Killian Fortman", "author_id": 561186, "author_profile": "https://unix.stackexchange.com/users/561186", "pm_score": 0, "selected": false, "text": "<p>You can use <code>find</code> instead.</p>\n<pre><code>find . -name &quot;*.mol12.gz&quot; -exec gzip -d...
2023/02/17
[ "https://unix.stackexchange.com/questions/735939", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561204/" ]
I have a folder with subdirectories and those subdirectories have more subdirectories where I want the command to be executed. The code below is the script I have made so far. ``` #!/bin/bash for i in `ls -d ./*/`; do cd "$i" for x in `ls -d ./*/` cd "$x" gzip -d *.mol2.gz mv *.mol2 /path/to/directory cd .. done...
I think you're simply asking for this: ``` gunzip */*/*.mol2.gz mv */*/*.mol2 /path/to/directory ``` No need for any loops, and let the shell do the heavy lifting
735,952
<pre><code>cdcl() { vlog -source -lint +define+&quot;${1:-DEBUG}&quot; -sv &quot;${2:-*.sv}&quot;; } </code></pre> <p>Above is my fucnction, i defined it in .bashrc file. Below is my command line</p> <pre><code>% cdcl 'RANDOM' 'abc.sv' </code></pre> <p>This give me &gt;&gt; <code>vlog -source -lint +define+RAN...
[ { "answer_id": 735955, "author": "Valentin Bajrami", "author_id": 43380, "author_profile": "https://unix.stackexchange.com/users/43380", "pm_score": 0, "selected": false, "text": "<p>If I understand your question correctly you want to skip providing the first argument to the script so it...
2023/02/17
[ "https://unix.stackexchange.com/questions/735952", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561213/" ]
``` cdcl() { vlog -source -lint +define+"${1:-DEBUG}" -sv "${2:-*.sv}"; } ``` Above is my fucnction, i defined it in .bashrc file. Below is my command line ``` % cdcl 'RANDOM' 'abc.sv' ``` This give me >> `vlog -source -lint +define+RANDOM -sv abc.sv` Is there a way, where i can skip giving the 1st place...
Since the function uses the default value expansion with the colon, i.e. `"${1:-DEBUG}"` and not `"${1-DEBUG}"`, an empty value will also trigger the use of the default value. You can pass an empty value with `""` or `''`, so ``` cdcl "" abc.sv ``` should result in the function running ``` vlog -source -lint +defin...
735,978
<p>I was horrified to reboot Debian Buster after a recent update to find that there is a log of previous copy-and-pastes, including passwords. Isn't that kind of thing supposed to live only in the RAM?</p> <p>A quick search reveals there probably has been some kind of re-write :</p> <p><a href="https://www.reddit.com/r...
[ { "answer_id": 735955, "author": "Valentin Bajrami", "author_id": 43380, "author_profile": "https://unix.stackexchange.com/users/43380", "pm_score": 0, "selected": false, "text": "<p>If I understand your question correctly you want to skip providing the first argument to the script so it...
2023/02/18
[ "https://unix.stackexchange.com/questions/735978", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/188451/" ]
I was horrified to reboot Debian Buster after a recent update to find that there is a log of previous copy-and-pastes, including passwords. Isn't that kind of thing supposed to live only in the RAM? A quick search reveals there probably has been some kind of re-write : <https://www.reddit.com/r/linux/comments/1134lcm...
Since the function uses the default value expansion with the colon, i.e. `"${1:-DEBUG}"` and not `"${1-DEBUG}"`, an empty value will also trigger the use of the default value. You can pass an empty value with `""` or `''`, so ``` cdcl "" abc.sv ``` should result in the function running ``` vlog -source -lint +defin...
735,992
<p>I've got massive file looking similar to that:</p> <pre><code>H2,3,5,9,ef,ty,i; H2,7,5,6,rt,hg,j; T2,5,5,0,207,3.7,00,...,2023:46:18:14:31,76; T2,5,5,0,207,3.5,00,...,2023:46:18:14:31,76; T2,5,5,0,119,3.5,00,...,2023:46:18:14:32,10; T2,5,5,0,207,3.5,00,...,2023:46:18:14:32,15; T2,5,5,0,186,3.4,00,...,2023:46:18:14:3...
[ { "answer_id": 735995, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 3, "selected": true, "text": "<h4>Try this:</h4>\n<pre><code>$ awk -F, '!seen[$1,$2,$3,$4,$5,$8]++' file\n</code></pre>\n<h4>Output</h4>\n<pre...
2023/02/18
[ "https://unix.stackexchange.com/questions/735992", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/531977/" ]
I've got massive file looking similar to that: ``` H2,3,5,9,ef,ty,i; H2,7,5,6,rt,hg,j; T2,5,5,0,207,3.7,00,...,2023:46:18:14:31,76; T2,5,5,0,207,3.5,00,...,2023:46:18:14:31,76; T2,5,5,0,119,3.5,00,...,2023:46:18:14:32,10; T2,5,5,0,207,3.5,00,...,2023:46:18:14:32,15; T2,5,5,0,186,3.4,00,...,2023:46:18:14:32,16; T2,5,5,...
#### Try this: ``` $ awk -F, '!seen[$1,$2,$3,$4,$5,$8]++' file ``` #### Output ``` H2,3,5,9,ef,ty,i; H2,7,5,6,rt,hg,j; T2,5,5,0,207,3.7,00,...,2023:46:18:14:31,76; T2,5,5,0,119,3.5,00,...,2023:46:18:14:32,10; T2,5,5,0,186,3.4,00,...,2023:46:18:14:32,16; ``` #### Explanations * the default behavior of `awk` on a ...
736,050
<p>I'm writing a Bash script to convert Arch Linux packages into a format for a package manager I'm writing, and I have to convert some metadata files into file format <code>.toml</code>. Previously, I've been using <code>sed</code>, but I just need something I can implement into a Bash script. The conversion should lo...
[ { "answer_id": 736055, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 1, "selected": false, "text": "<p>Using <code>awk</code>:</p>\n<pre><code>awk -F' = ' '\n $1 == &quot;depends&quot; {\n printf &quot;%s %...
2023/02/19
[ "https://unix.stackexchange.com/questions/736050", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561308/" ]
I'm writing a Bash script to convert Arch Linux packages into a format for a package manager I'm writing, and I have to convert some metadata files into file format `.toml`. Previously, I've been using `sed`, but I just need something I can implement into a Bash script. The conversion should look like shown below. Inp...
Using `awk`: ``` awk -F' = ' ' $1 == "depends" { printf "%s %s", (flag!=1 ? "depends = [" : ","), $2 flag=1 next } flag { print " ]" flag=0 } { print } END { if (flag) print " ]" } ' file ``` Input: ``` ... other stuff ... depends = "some-d...
736,052
<p>I often find myself in the situation where I need to look up the syntax and logic for a configuration file of some program on my computer. While I can do <code>man mosquitto</code>, this will not necessarily yield the help section for the file /etc/mosquitto.conf.</p> <p>What I am searching for is something like <co...
[ { "answer_id": 736053, "author": "Peregrino69", "author_id": 90878, "author_profile": "https://unix.stackexchange.com/users/90878", "pm_score": 4, "selected": true, "text": "<p>TL/DR: There's no centralized repository of information. Most up-to-date source of information of a an applicat...
2023/02/19
[ "https://unix.stackexchange.com/questions/736052", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/465412/" ]
I often find myself in the situation where I need to look up the syntax and logic for a configuration file of some program on my computer. While I can do `man mosquitto`, this will not necessarily yield the help section for the file /etc/mosquitto.conf. What I am searching for is something like `man /etc/mosquitto.con...
TL/DR: There's no centralized repository of information. Most up-to-date source of information of a an application / tool / etc. is in its documentation. Otherwise there are man pages, info pages, tldr pages, html documentation, literature, internet... --- Man pages are just one form of software documentation. The fa...
736,098
<p>Given the following configuration file:</p> <pre><code> shape { visible: true type: rectangle ... } shape { type: circle visible: isRound === &quot;true&quot; ... } shape { // comment: &quot;visible&quot; not set, default &quot;true...
[ { "answer_id": 736053, "author": "Peregrino69", "author_id": 90878, "author_profile": "https://unix.stackexchange.com/users/90878", "pm_score": 4, "selected": true, "text": "<p>TL/DR: There's no centralized repository of information. Most up-to-date source of information of a an applicat...
2023/02/19
[ "https://unix.stackexchange.com/questions/736098", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/221551/" ]
Given the following configuration file: ``` shape { visible: true type: rectangle ... } shape { type: circle visible: isRound === "true" ... } shape { // comment: "visible" not set, default "true" } ``` How to set using `bash` all the...
TL/DR: There's no centralized repository of information. Most up-to-date source of information of a an application / tool / etc. is in its documentation. Otherwise there are man pages, info pages, tldr pages, html documentation, literature, internet... --- Man pages are just one form of software documentation. The fa...
736,116
<p>Is there a command to copy and compile a c file to another directory? So if I have Ticker.c in the home directory, I want to copy it and compile it in another directory called Task</p>
[ { "answer_id": 736053, "author": "Peregrino69", "author_id": 90878, "author_profile": "https://unix.stackexchange.com/users/90878", "pm_score": 4, "selected": true, "text": "<p>TL/DR: There's no centralized repository of information. Most up-to-date source of information of a an applicat...
2023/02/19
[ "https://unix.stackexchange.com/questions/736116", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561408/" ]
Is there a command to copy and compile a c file to another directory? So if I have Ticker.c in the home directory, I want to copy it and compile it in another directory called Task
TL/DR: There's no centralized repository of information. Most up-to-date source of information of a an application / tool / etc. is in its documentation. Otherwise there are man pages, info pages, tldr pages, html documentation, literature, internet... --- Man pages are just one form of software documentation. The fa...
736,178
<p>Basically I am trying to get something similar to command search with <code>$PATH</code>, but with a different list of directories and the file I'm searching for is not executable.</p> <p>The list of directories is fixed (I can pack it in a variable in the same format as PATH, or whatever), and I don't want to desce...
[ { "answer_id": 736257, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 1, "selected": false, "text": "<p>You could use a bash function as wrapper for GNU <code>find</code>:</p>\n<pre><code>filepath () {\n local fp_p...
2023/02/20
[ "https://unix.stackexchange.com/questions/736178", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/23344/" ]
Basically I am trying to get something similar to command search with `$PATH`, but with a different list of directories and the file I'm searching for is not executable. The list of directories is fixed (I can pack it in a variable in the same format as PATH, or whatever), and I don't want to descend in subdirectories...
`find` already supports multiple search paths ``` find . /etc ~/lib ~/bin -maxdepth 1 -name '*foo*' ``` Alternatively use [`fd`](https://github.com/sharkdp/fd) which is significantly faster and far more featureful and more beautiful than find ``` fd --max-depth=1 foo . /etc ~/lib ~/bin ```
736,183
<p>I've tried to install Wine on my chromebook but I continued to get an error message. Did some digging and realized ARM CPUs can't run that. I did more research and seem to be going in a loop. I was told that using Box64 could be a solution. I'm lost can anyone shed some light on this?</p>
[ { "answer_id": 736257, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 1, "selected": false, "text": "<p>You could use a bash function as wrapper for GNU <code>find</code>:</p>\n<pre><code>filepath () {\n local fp_p...
2023/02/20
[ "https://unix.stackexchange.com/questions/736183", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561475/" ]
I've tried to install Wine on my chromebook but I continued to get an error message. Did some digging and realized ARM CPUs can't run that. I did more research and seem to be going in a loop. I was told that using Box64 could be a solution. I'm lost can anyone shed some light on this?
`find` already supports multiple search paths ``` find . /etc ~/lib ~/bin -maxdepth 1 -name '*foo*' ``` Alternatively use [`fd`](https://github.com/sharkdp/fd) which is significantly faster and far more featureful and more beautiful than find ``` fd --max-depth=1 foo . /etc ~/lib ~/bin ```
736,193
<p>On Stackoverflow, I just saw a question concerning the <code>PS1</code> environment variable, which is responsible for the Linux terminal prompt.</p> <p>My prompt looks as follows:</p> <pre><code>username@PORT-usr:/dir </code></pre> <ul> <li><code>username</code> is the username I use when logging into my WSL.</li> ...
[ { "answer_id": 736196, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 2, "selected": false, "text": "<p>The syntax of <code>PS1</code> is a language of its own and cannot be just <code>echo</code> printed.</p>\n<p>...
2023/02/20
[ "https://unix.stackexchange.com/questions/736193", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/152061/" ]
On Stackoverflow, I just saw a question concerning the `PS1` environment variable, which is responsible for the Linux terminal prompt. My prompt looks as follows: ``` username@PORT-usr:/dir ``` * `username` is the username I use when logging into my WSL. * `PORT-usr` is the name of my laptop. * `/dir` is my current...
The `PS1` shell variable (which may or may not be also an environment variable) does not contain a regular shell command. It is expanded into a prompt using a special procedure specific to the variety of shell you're using. It is likely to include special sequences that are not recognized by the plain `echo` command. ...
736,209
<p>Suppose I have two modules: A and B. I would like to start A before B.</p> <ol> <li>Is only A config file enough?</li> </ol> <pre><code>[Unit] Before=B </code></pre> <ol start="2"> <li>Is only B config file enough?</li> </ol> <pre><code>[Unit] Requires=A After=A </code></pre> <ol start="3"> <li>Or maybe dependencies...
[ { "answer_id": 736196, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 2, "selected": false, "text": "<p>The syntax of <code>PS1</code> is a language of its own and cannot be just <code>echo</code> printed.</p>\n<p>...
2023/02/20
[ "https://unix.stackexchange.com/questions/736209", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561503/" ]
Suppose I have two modules: A and B. I would like to start A before B. 1. Is only A config file enough? ``` [Unit] Before=B ``` 2. Is only B config file enough? ``` [Unit] Requires=A After=A ``` 3. Or maybe dependencies need to be defined symmetrically in both files? config A ``` [Unit] Before=B ``` config B...
The `PS1` shell variable (which may or may not be also an environment variable) does not contain a regular shell command. It is expanded into a prompt using a special procedure specific to the variety of shell you're using. It is likely to include special sequences that are not recognized by the plain `echo` command. ...
736,216
<p>This question is related to the previously answered - <a href="https://unix.stackexchange.com/questions/662903/awk-split-by-delimiter-and-take-first-entry">Awk split by delimiter and take first entry</a> -</p> <p>For a VCF file, which is a tab-separated format:</p> <pre><code>chr1 28374C T 0.0 PAS...
[ { "answer_id": 736219, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 3, "selected": true, "text": "<h4>Let's simplify with one pipe to <a href=\"/questions/tagged/gnu\" class=\"post-tag\" title=\"show questions ...
2023/02/20
[ "https://unix.stackexchange.com/questions/736216", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561502/" ]
This question is related to the previously answered - [Awk split by delimiter and take first entry](https://unix.stackexchange.com/questions/662903/awk-split-by-delimiter-and-take-first-entry) - For a VCF file, which is a tab-separated format: ``` chr1 28374C T 0.0 PASS AF=0.730769;AO=19;DP=26; ...
#### Let's simplify with one pipe to [gnu](/questions/tagged/gnu "show questions tagged 'gnu'") [grep](/questions/tagged/grep "show questions tagged 'grep'"): ``` $ awk '{print $6 | "grep -oP \042[A-Z]+(?==)\042"}' file ``` or ``` $ awk '{print $6}' file | grep -oP '[A-Z]+(?==)' AF AO DP AF AO DP ALLELEID ID AF AO ...
736,217
<p>I am trying to log every time a command fails (by sending an HTTP request to my VPS) to see how many times I have messed up.</p> <p>I've tried: <code>some_command || curl &lt;my-vps&gt;</code>. Is there a better way?</p>
[ { "answer_id": 736221, "author": "Killian Fortman", "author_id": 561186, "author_profile": "https://unix.stackexchange.com/users/561186", "pm_score": 3, "selected": false, "text": "<p>You can create a Trap for error handling.</p>\n<p>For example:</p>\n<pre><code>trap 'echo &quot;Error: $...
2023/02/20
[ "https://unix.stackexchange.com/questions/736217", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/549786/" ]
I am trying to log every time a command fails (by sending an HTTP request to my VPS) to see how many times I have messed up. I've tried: `some_command || curl <my-vps>`. Is there a better way?
You can create a Trap for error handling. For example: ``` trap 'echo "Error: $? occurred" >> log.txt' ERR some_command some_bad_command some_command ``` Or you can use this in a script like so. ```bash #!/bin/bash trap 'error_handler $? $LINENO' ERR error_handler () { echo "Error: $1 occurred on line $2" }...
736,231
<p>So, I have a file array list in a bash shell, and I want to sort all the files in the array by the date modified, starting with the oldest being the first one in the array. However, I don't want to sort and modify the original array, and instead want to have the sorted result be in a different array. I saw <a href="...
[ { "answer_id": 736240, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 1, "selected": false, "text": "<p>Using a <a href=\"/questions/tagged/perl\" class=\"post-tag\" title=\"show questions tagged &#39;perl&#39;\"...
2023/02/20
[ "https://unix.stackexchange.com/questions/736231", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561191/" ]
So, I have a file array list in a bash shell, and I want to sort all the files in the array by the date modified, starting with the oldest being the first one in the array. However, I don't want to sort and modify the original array, and instead want to have the sorted result be in a different array. I saw [this thread...
With newer versions of GNU `ls` and `bash`, you can do: ``` readarray -td '' new_array < <( ls --zero -dt -- "${array_list[@]}") ``` That doesn't bypass the `execve()` limit on the length of arguments+environment though as we *are* executing `ls` with that list of arguments. You could pass that list to a function ...
736,274
<h1>The problem</h1> <p>The output of <code>grep -A 4 davidson file.txt</code> gives me:</p> <pre><code>davidson 0 27 |r|= 0.00244 e= [-0.04073962 0.42777949 0.44157777 0.45997235 0.45997235 0.51613738 0.55005554 0.5538866 0.5538866 0.57108874 0.63182267 0.68741162 0.68741186 0.69608 0.78013465 ...
[ { "answer_id": 736276, "author": "tink", "author_id": 24437, "author_profile": "https://unix.stackexchange.com/users/24437", "pm_score": 2, "selected": false, "text": "<p>Unfortunately you didn't give us a sample of the original data, but playing with your output above this may do what y...
2023/02/21
[ "https://unix.stackexchange.com/questions/736274", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/78288/" ]
The problem =========== The output of `grep -A 4 davidson file.txt` gives me: ``` davidson 0 27 |r|= 0.00244 e= [-0.04073962 0.42777949 0.44157777 0.45997235 0.45997235 0.51613738 0.55005554 0.5538866 0.5538866 0.57108874 0.63182267 0.68741162 0.68741186 0.69608 0.78013465 0.78013465 0.78042...
Unfortunately you didn't give us a sample of the original data, but playing with your output above this may do what you want? Rather than `grep -A4 ...` try this: ``` awk '/davidson/{h=NR;line=$0} NR==h+4{print line;print $0}' file.txt ```
736,296
<pre><code>TMW_yyyymm=`date +%Y%m --date='tomorrow'` YDY_yyyymmdd=`date +%Y%m%d --date='yesterday'` YDY_yyyymm=`date +%Y%m --date='yesterday'` TODAY=`date +'%Y%m%d'` SRC_LOG=&quot;/home/user/bin/abc.log.${YDY_yyyymmdd}&quot; HOMEDIR=&quot;/home/user/bin&quot; DEST=&quot;/log/user/abc&quot; </code></pre> <p>Above is pa...
[ { "answer_id": 736276, "author": "tink", "author_id": 24437, "author_profile": "https://unix.stackexchange.com/users/24437", "pm_score": 2, "selected": false, "text": "<p>Unfortunately you didn't give us a sample of the original data, but playing with your output above this may do what y...
2023/02/21
[ "https://unix.stackexchange.com/questions/736296", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561588/" ]
``` TMW_yyyymm=`date +%Y%m --date='tomorrow'` YDY_yyyymmdd=`date +%Y%m%d --date='yesterday'` YDY_yyyymm=`date +%Y%m --date='yesterday'` TODAY=`date +'%Y%m%d'` SRC_LOG="/home/user/bin/abc.log.${YDY_yyyymmdd}" HOMEDIR="/home/user/bin" DEST="/log/user/abc" ``` Above is part of the old script I got from former colleague...
Unfortunately you didn't give us a sample of the original data, but playing with your output above this may do what you want? Rather than `grep -A4 ...` try this: ``` awk '/davidson/{h=NR;line=$0} NR==h+4{print line;print $0}' file.txt ```
736,313
<p>I have a few directories which have a Makefile in them.</p> <p>I've make this script to run those Makefiles if they exist:</p> <pre class="lang-bash prettyprint-override"><code>find . -name &quot;Makefile&quot; -exec sh -c 'make re -C &quot;$1&quot; $(dirname &quot;$0&quot;)' {} \; </code></pre> <p>But it doesn't se...
[ { "answer_id": 736276, "author": "tink", "author_id": 24437, "author_profile": "https://unix.stackexchange.com/users/24437", "pm_score": 2, "selected": false, "text": "<p>Unfortunately you didn't give us a sample of the original data, but playing with your output above this may do what y...
2023/02/21
[ "https://unix.stackexchange.com/questions/736313", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561608/" ]
I have a few directories which have a Makefile in them. I've make this script to run those Makefiles if they exist: ```bash find . -name "Makefile" -exec sh -c 'make re -C "$1" $(dirname "$0")' {} \; ``` But it doesn't seem to work, I get this error: ``` make: the `-C' option requires a non-empty string argument U...
Unfortunately you didn't give us a sample of the original data, but playing with your output above this may do what you want? Rather than `grep -A4 ...` try this: ``` awk '/davidson/{h=NR;line=$0} NR==h+4{print line;print $0}' file.txt ```
736,371
<p>I'm trying to get my terminal (macOS) to print the previous commands that I've used, as well as the timestamps to go with them.</p> <p>I know that if I use <code>history man</code>, it will give me a list of the past 1000 or so, and if I use <code>history -E</code>, it will give commands with timestamps though only ...
[ { "answer_id": 736372, "author": "Killian Fortman", "author_id": 561186, "author_profile": "https://unix.stackexchange.com/users/561186", "pm_score": 0, "selected": false, "text": "<p><strong>This is for running with a Bash terminal, not zsh</strong></p>\n<p>You can set HISTTIMEFORMAT.</...
2023/02/21
[ "https://unix.stackexchange.com/questions/736371", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525646/" ]
I'm trying to get my terminal (macOS) to print the previous commands that I've used, as well as the timestamps to go with them. I know that if I use `history man`, it will give me a list of the past 1000 or so, and if I use `history -E`, it will give commands with timestamps though only about 20 or so. Is there any w...
In the `zsh` shell, to get *all* the history for the current shell session with timestamps ("in the European `dd.mm.yyyy hh:mm` format"), use ```bash history -E 1 ``` The `1` at the end signifies that you'd like to see the history from the first (to the last) entry. Note that to get the shell to store the timestamp...
736,387
<p>If I LUKS encrypted a hard drive using linux machine A, can I read the data on it using machine B? Of course assuming I know the passphrase of the disk. Thanks.</p>
[ { "answer_id": 736372, "author": "Killian Fortman", "author_id": 561186, "author_profile": "https://unix.stackexchange.com/users/561186", "pm_score": 0, "selected": false, "text": "<p><strong>This is for running with a Bash terminal, not zsh</strong></p>\n<p>You can set HISTTIMEFORMAT.</...
2023/02/21
[ "https://unix.stackexchange.com/questions/736387", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/232895/" ]
If I LUKS encrypted a hard drive using linux machine A, can I read the data on it using machine B? Of course assuming I know the passphrase of the disk. Thanks.
In the `zsh` shell, to get *all* the history for the current shell session with timestamps ("in the European `dd.mm.yyyy hh:mm` format"), use ```bash history -E 1 ``` The `1` at the end signifies that you'd like to see the history from the first (to the last) entry. Note that to get the shell to store the timestamp...
736,399
<p>how to uninstall Julia completely in linux? <code>sudo apt uninstall julia</code> doesn't seem to work. I want to remove everything julia related</p>
[ { "answer_id": 736408, "author": "arnle", "author_id": 526246, "author_profile": "https://unix.stackexchange.com/users/526246", "pm_score": -1, "selected": false, "text": "<p>The answer is just to remove the <code>~/.julia</code> directory.</p>\n<p><a href=\"https://julialang.org/downloa...
2023/02/21
[ "https://unix.stackexchange.com/questions/736399", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/526246/" ]
how to uninstall Julia completely in linux? `sudo apt uninstall julia` doesn't seem to work. I want to remove everything julia related
The command is ``` sudo apt remove julia ``` not ``` sudo apt uninstall julia ``` A variant, which also removes configuration files, is ``` sudo apt purge julia ```
736,407
<p>I have a scenario where in need to unpivot the data to achieve the parent child relationship. My source data is as below:</p> <p><strong>Key_Col|Hierarchy</strong></p> <p>1|a,b,c,d</p> <p>2|a,b,c,d,e</p> <p>My Expected Output below:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Key Col...
[ { "answer_id": 736576, "author": "Kusalananda", "author_id": 116858, "author_profile": "https://unix.stackexchange.com/users/116858", "pm_score": 2, "selected": true, "text": "<p>Things like these are usually easier to do with a language made for processing text or structured data. Below...
2023/02/22
[ "https://unix.stackexchange.com/questions/736407", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/288268/" ]
I have a scenario where in need to unpivot the data to achieve the parent child relationship. My source data is as below: **Key\_Col|Hierarchy** 1|a,b,c,d 2|a,b,c,d,e My Expected Output below: | Key Col | Child | Parent | | --- | --- | --- | | 1 | d | c | | 1 | c | b | | 1 | b | a | | 1 | a | null | | 2 | e | d | ...
Things like these are usually easier to do with a language made for processing text or structured data. Below is a solution using the standard text-processing utility `awk` and one using [Miller](https://miller.readthedocs.io/en/latest/) (`mlr`), a tool specifically used for processing structured data (your data looks ...
736,472
<p>I have a text file with output like this:</p> <pre><code>file_0108.json 2023-02-22T01:15:05.531+0000 connected to: mongodb://[**REDACTED**]@localhost 2023-02-22T01:15:08.531+0000 [######..................] db.coll 64.7MB/255MB (25.4%) 2023-02-22T01:15:11.531+0000 [############............] db.coll 128MB/2...
[ { "answer_id": 736576, "author": "Kusalananda", "author_id": 116858, "author_profile": "https://unix.stackexchange.com/users/116858", "pm_score": 2, "selected": true, "text": "<p>Things like these are usually easier to do with a language made for processing text or structured data. Below...
2023/02/22
[ "https://unix.stackexchange.com/questions/736472", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561781/" ]
I have a text file with output like this: ``` file_0108.json 2023-02-22T01:15:05.531+0000 connected to: mongodb://[**REDACTED**]@localhost 2023-02-22T01:15:08.531+0000 [######..................] db.coll 64.7MB/255MB (25.4%) 2023-02-22T01:15:11.531+0000 [############............] db.coll 128MB/255MB (50.3%) ...
Things like these are usually easier to do with a language made for processing text or structured data. Below is a solution using the standard text-processing utility `awk` and one using [Miller](https://miller.readthedocs.io/en/latest/) (`mlr`), a tool specifically used for processing structured data (your data looks ...
736,487
<p>I use this Vagrantfile:</p> <pre><code>Vagrant.configure(&quot;2&quot;) do |config| config.vm.box = &quot;jonatasbaldin/solaris11&quot; config.vm.box_version = &quot;1.0.0&quot; end </code></pre> <p>The <code>vagrant up</code> is successful, but <code>vagrant ssh</code> exit with 255 return code with no outp...
[ { "answer_id": 736822, "author": "bk2204", "author_id": 388876, "author_profile": "https://unix.stackexchange.com/users/388876", "pm_score": 2, "selected": true, "text": "<p>In the SSH protocol, there are different types of keys and each type of key allows one or more signature algorithm...
2023/02/22
[ "https://unix.stackexchange.com/questions/736487", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/307939/" ]
I use this Vagrantfile: ``` Vagrant.configure("2") do |config| config.vm.box = "jonatasbaldin/solaris11" config.vm.box_version = "1.0.0" end ``` The `vagrant up` is successful, but `vagrant ssh` exit with 255 return code with no output at all. To debug, I do ``` $ ssh -v vagrant@localhost -p 2222 ``` I get:...
In the SSH protocol, there are different types of keys and each type of key allows one or more signature algorithms. The type of keys that are used here on the server side are RSA (`ssh-rsa`) and DSA (`ssh-dss`) keys. With RSA keys, there are three kinds of signatures: `ssh-rsa` (SHA-1), `rsa-sha2-256` (SHA-256), and `...
736,505
<p>I want to match lines that have foo unless the next line contains bar. So given a file containing:</p> <pre><code>1 foo 1 foo 2 baz bar bap </code></pre> <p>only <code>1 foo 1</code> would print. I got this to work using a negative lookahead <code>/foo(?!.*\n.*bar)/</code> on <a href="https://regex101.com/r/ZMZsiN...
[ { "answer_id": 736509, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 1, "selected": false, "text": "<h4>With <code>grep</code>:</h4>\n<p>(regex hardened with <em>word boundaries</em>)</p>\n<pre><code>grep -Pzo '...
2023/02/22
[ "https://unix.stackexchange.com/questions/736505", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/86629/" ]
I want to match lines that have foo unless the next line contains bar. So given a file containing: ``` 1 foo 1 foo 2 baz bar bap ``` only `1 foo 1` would print. I got this to work using a negative lookahead `/foo(?!.*\n.*bar)/` on <https://regex101.com/r/ZMZsiN/1> but getting this to work on the command line with g...
`grep` or `perl -n` works on one line at a time so the thing the regexp matches on is just the contents of one line (with the line delimiter not even included with `grep` or `perl` with `-l`). You could use `pcregrep` (the `-P` option that GNU `grep` can be built to support uses PCRE as well) which has a multiline mod...
736,524
<p>The implicit rules in &quot;make&quot; are defined on <a href="https://www.gnu.org/software/make/manual/make.html#toc-Using-Implicit-Rules" rel="nofollow noreferrer">https://www.gnu.org/software/make/manual/make.html#toc-Using-Implicit-Rules</a>. I was unable to find the default recipe for shared objects in there. I...
[ { "answer_id": 736527, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 0, "selected": false, "text": "<p>No, there is no such implicit rule.</p>\n<p>But if you want, you can do:</p>\n<pre><code># my_favorite_recipe....
2023/02/22
[ "https://unix.stackexchange.com/questions/736524", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557371/" ]
The implicit rules in "make" are defined on <https://www.gnu.org/software/make/manual/make.html#toc-Using-Implicit-Rules>. I was unable to find the default recipe for shared objects in there. Is there a default recipe when building shared objects? I was unable to run ``` foo: foo.so ``` with error message "no rule ...
In the GNU Make manual you linked, just after Chapter 10.1, *Using Implicit Rules*, there is [Chapter 10.2, *Catalogue of Built-In Rules*](https://www.gnu.org/software/make/manual/make.html#Catalogue-of-Rules). As Andy Dalton notes, it says: > > To see the full list of default rules and variables available in your ve...
736,546
<p>I have a bit of an issue with the following command which extracts a tar file &amp; prints how many files have been extracted every second:</p> <pre><code>tar -xvf some_tar.tar -C a/directory | awk 'systime() &gt; lasttime { lasttime = systime(); printf &quot;%d files\n&quot;, NR; fflush(stdout) }' </code></pre> <p>...
[ { "answer_id": 736549, "author": "Eric Marceau", "author_id": 438420, "author_profile": "https://unix.stackexchange.com/users/438420", "pm_score": 2, "selected": false, "text": "<p>I would suggest you add &quot;<strong>2&gt;&amp;1</strong>&quot; on the tar command, then, in the awk, move...
2023/02/23
[ "https://unix.stackexchange.com/questions/736546", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/321024/" ]
I have a bit of an issue with the following command which extracts a tar file & prints how many files have been extracted every second: ``` tar -xvf some_tar.tar -C a/directory | awk 'systime() > lasttime { lasttime = systime(); printf "%d files\n", NR; fflush(stdout) }' ``` Even if the tar command fails, the awk co...
If you just want to see if any command in the pipeline failed, set the `pipefail` option. It's supported in ksh, zsh and Busybox (at least), in addition to Bash. With that option set, the exit status of a pipeline is the leftmost non-zero exit status returned by the commands involved. ``` $ set -o pipefail $ (exit 123...
736,560
<p>I have a folder of folders of folders of files. I'm trying to copy all the files to their parent. The following command doesn't work because <code>dirname &quot;{}&quot;</code> executes before the find command. What could be done instead please?</p> <pre><code>find . -name &quot;*&quot; -type f | xargs -I &quot;{}&q...
[ { "answer_id": 736561, "author": "DopeGhoti", "author_id": 20246, "author_profile": "https://unix.stackexchange.com/users/20246", "pm_score": 2, "selected": true, "text": "<p>To move all files from the directory tree descending from the current working directory into each file's parent d...
2023/02/23
[ "https://unix.stackexchange.com/questions/736560", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/561887/" ]
I have a folder of folders of folders of files. I'm trying to copy all the files to their parent. The following command doesn't work because `dirname "{}"` executes before the find command. What could be done instead please? ``` find . -name "*" -type f | xargs -I "{}" cp "{}" `dirname "{}"` ```
To move all files from the directory tree descending from the current working directory into each file's parent directory, you don't even need to break out `xargs` or `dirname`; `find` can do this for you: ``` $ tree . +--- dir1 | +--- somefile +--- dir2 | +--- someotherfile $ find . -type f -execdir mv "{}" ../ \...
736,629
<p>I have an variable in my script which I want to change:</p> <pre class="lang-bash prettyprint-override"><code>read -p &quot;Enter the name of city: &quot; city if [[ $city =~ Liverpool ]]; then sed -i -e &quot;/\$type\_of\_city =/ s/= .*/= ${city}/&quot; /cities echo -e &quot;Liverpool: `grep '$name_of_cit...
[ { "answer_id": 736561, "author": "DopeGhoti", "author_id": 20246, "author_profile": "https://unix.stackexchange.com/users/20246", "pm_score": 2, "selected": true, "text": "<p>To move all files from the directory tree descending from the current working directory into each file's parent d...
2023/02/23
[ "https://unix.stackexchange.com/questions/736629", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557045/" ]
I have an variable in my script which I want to change: ```bash read -p "Enter the name of city: " city if [[ $city =~ Liverpool ]]; then sed -i -e "/\$type\_of\_city =/ s/= .*/= ${city}/" /cities echo -e "Liverpool: `grep '$name_of_city' cities" fi ``` And in the city file there is a variable with `#` whi...
To move all files from the directory tree descending from the current working directory into each file's parent directory, you don't even need to break out `xargs` or `dirname`; `find` can do this for you: ``` $ tree . +--- dir1 | +--- somefile +--- dir2 | +--- someotherfile $ find . -type f -execdir mv "{}" ../ \...
736,645
<p>I'm getting an error in a script that attempts to mount an external USB drive during service startup:</p> <blockquote> <p>sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?</p> </blockquote> <p>(Note that the mount action must b...
[ { "answer_id": 736664, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 1, "selected": false, "text": "<p>Start with a status check:</p>\n<pre><code>systemctl show syncthing@admin.service | grep -E 'ProtectSystem|NoNewP...
2023/02/23
[ "https://unix.stackexchange.com/questions/736645", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/254854/" ]
I'm getting an error in a script that attempts to mount an external USB drive during service startup: > > sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges? > > > (Note that the mount action must be synchronous, so putting it...
Your script has `if ! grep -qs '/dev/sda1' /proc/mounts; then`, which I assume is to address the issue of running this script for each instance of `syncthing@.service`. If another instance is running (or ran in the past), then the mount will already exist, and so this check is necessary or your `ExecStartPre=` will fai...
736,646
<p>I dual booted my laptop and installed EndeavourOS (while other OS being windows 10)</p> <p>Due to this, my hardware and system clock both show the wrong time.</p> <p>I have set the correct time zone (UTC+5:30), still it shows the wrong time.</p> <img src="https://i.stack.imgur.com/avbxW.png"> <p><code>timedatctl </...
[ { "answer_id": 736662, "author": "symcbean", "author_id": 9178, "author_profile": "https://unix.stackexchange.com/users/9178", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>Due to this, my hardware and system clock both show the wrong time.</p>\n</blockquote>\n<p>Hmmm. That...
2023/02/23
[ "https://unix.stackexchange.com/questions/736646", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558807/" ]
I dual booted my laptop and installed EndeavourOS (while other OS being windows 10) Due to this, my hardware and system clock both show the wrong time. I have set the correct time zone (UTC+5:30), still it shows the wrong time. ![](https://i.stack.imgur.com/avbxW.png) `timedatctl` ``` Local time: Sat 2023-02-25 0...
So your UTC time is about 17 minutes off. ``` System clock synchronized: no NTP service: active ``` Although the NTP service is active, the `System clock synchronized: no` indicates it has not succeeded in getting accurate time information from the NTP servers it may be configured to contact. You should look at the...