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
732,793
<p>I'm using the <code>-e</code> flag.</p> <p>Usage:</p> <pre><code>#!/bin/bash -e </code></pre> <p>Explained:</p> <pre><code>-e Exit immediately if a simple command (see SHELL GRAMMAR above) exits with a non-zero status </code></pre> <p>When a command in the script fails, the script exits and doesn't continue to ...
[ { "answer_id": 732803, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 1, "selected": false, "text": "<p>Find which command is failing, add <code>set -x</code> before it, run the script again.</p>\n<p>If you do not ...
2023/01/23
[ "https://unix.stackexchange.com/questions/732793", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/6272/" ]
I'm using the `-e` flag. Usage: ``` #!/bin/bash -e ``` Explained: ``` -e Exit immediately if a simple command (see SHELL GRAMMAR above) exits with a non-zero status ``` When a command in the script fails, the script exits and doesn't continue to execute the rest of the commands, which is exactly what I want...
You can use a `trap` to identify the failing command (and its line number). Here's an example ``` #!/bin/bash -e # This script can be used to fail intentionally and exit # Declare an error handler trapERR() { ss=$? bc="$BASH_COMMAND" ln="$BASH_LINENO" echo ">> Failing command is '$bc' on line $ln and status i...
732,798
<p>Following are the contents of the config file</p> <pre><code>{ &quot;Line1&quot;: true, &quot;Line2&quot;: &quot;\/\/{hostname}\/&quot;, &quot;version&quot;: &quot;2.8.9&quot;, &quot;Line4&quot;: true, &quot;Line5&quot;: true } </code></pre> <p>I am using Linux, and I need to find semantic version number 2...
[ { "answer_id": 732801, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 1, "selected": false, "text": "<h2>Ways to parse JSON</h2>\n<h4>Disclaimer, was reading to fast, this is not a search&amp;replace response.</h...
2023/01/23
[ "https://unix.stackexchange.com/questions/732798", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/346851/" ]
Following are the contents of the config file ``` { "Line1": true, "Line2": "\/\/{hostname}\/", "version": "2.8.9", "Line4": true, "Line5": true } ``` I am using Linux, and I need to find semantic version number 2.8.9 above and store in one variable and replace it with either major, minor or patch version ...
If you are only after the version number then grep could do a better job than sed: ``` $ grep -o '[0-9]\+\.[0-9]\+\.[0-9]+' infile 2.8.9 ``` But if you are looking to find and replace the version number then try this: ``` $ sed 's/[0-9]\+\.[0-9]\+\.[0-9]\+/REPLACEMENT/' infile { "Line1": true, "Line2": "\/\/...
732,812
<p>I want to see the current available disk space as well as how much the folder I am in is using. Is there some du/df command that not only tells me the size of my folder but also how much is still available in this directory ?</p>
[ { "answer_id": 732841, "author": "joe90", "author_id": 557716, "author_profile": "https://unix.stackexchange.com/users/557716", "pm_score": 1, "selected": false, "text": "<p>You can get the size of the disk usage of the current folder with the du command, using the &quot;s&quot; (summari...
2023/01/23
[ "https://unix.stackexchange.com/questions/732812", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557824/" ]
I want to see the current available disk space as well as how much the folder I am in is using. Is there some du/df command that not only tells me the size of my folder but also how much is still available in this directory ?
I think using `df -h /YourDiskLocation` will resolve your problem, and here's an example of `df` command: ``` $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 29G 11G 17G 39% / devtmpfs 325M 0 325M 0% /dev tmpfs 455M 0 455M 0% /dev/shm tmpfs 182M ...
732,887
<p>I just installed oh-my-zsh. Things worked fine. Then I tried commenting out <code>export ZSH=&quot;~/.oh-my-zsh&quot;</code></p> <p>After this, when I uncommented the line back, I keep getting the below error. However, &quot;oh-my-zsh.sh&quot; is present</p> <pre><code>(base) abc@def-MacBook-Pro .oh-my-zsh % source ...
[ { "answer_id": 732889, "author": "SyncMaster", "author_id": 53123, "author_profile": "https://unix.stackexchange.com/users/53123", "pm_score": 0, "selected": false, "text": "<p>I am still now sure as to why this happened. However, reinstalling oh-my-zsh fixes the issue though.</p>\n" }...
2023/01/24
[ "https://unix.stackexchange.com/questions/732887", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/53123/" ]
I just installed oh-my-zsh. Things worked fine. Then I tried commenting out `export ZSH="~/.oh-my-zsh"` After this, when I uncommented the line back, I keep getting the below error. However, "oh-my-zsh.sh" is present ``` (base) abc@def-MacBook-Pro .oh-my-zsh % source $ZSH/oh-my-zsh.sh source: no such file or director...
That's because `~` is not expanded to the value of the `$HOME` variable when you quote it (with any type of quoting mechanism including single, double quotes, backslash, `$'...'`). Thus you can use these commands instead: ```bash export ZSH=~"/.oh-my-zsh" ``` or ```bash export ZSH=~/.oh-my-zsh ``` or ```bash ex...
732,895
<p>I want to do below -</p> <pre><code>bash-shell&gt;echo (*).prop ; echo \1 </code></pre> <p>Obviously above does not work. But want to know if it is possible and what would be the working equivalent.</p> <p>I want <code>*</code> (for shell this the wild card) to match all the files in the current directory. And ofco...
[ { "answer_id": 732897, "author": "Kusalananda", "author_id": 116858, "author_profile": "https://unix.stackexchange.com/users/116858", "pm_score": 0, "selected": false, "text": "<p>Using GNU <code>basename</code> (or <code>basename</code> on FreeBSD or any other implementation that gives ...
2023/01/24
[ "https://unix.stackexchange.com/questions/732895", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/243342/" ]
I want to do below - ``` bash-shell>echo (*).prop ; echo \1 ``` Obviously above does not work. But want to know if it is possible and what would be the working equivalent. I want `*` (for shell this the wild card) to match all the files in the current directory. And ofcourse limit the above search to only files en...
ksh93 is the only shell that supports back references in globs AFAIK, and ksh93 and zsh support capture groups which is more like what you're looking for here, but even then, you couldn't use it as you propose. That `\1` (ksh93) or `$match[1]` (zsh) would need refer to what was captured for each matching file. In ksh9...
732,916
<p>I manage to SSH to a remote host after opening the GNOME terminal by doing the following:</p> <pre><code>gnome-terminal -- bash -c &quot;ssh -i ~/.ssh/virtual_machines remote@remotehost; exec bash;&quot; </code></pre> <p>However, once I have SSH into the remote host, I want to switch user by doing a <code>sudo su te...
[ { "answer_id": 732930, "author": "Gillanius", "author_id": 557934, "author_profile": "https://unix.stackexchange.com/users/557934", "pm_score": 0, "selected": false, "text": "<p>The <code>exec bash</code> behind the ssh command does not do anything. The semicolon separates the commands i...
2023/01/24
[ "https://unix.stackexchange.com/questions/732916", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/62551/" ]
I manage to SSH to a remote host after opening the GNOME terminal by doing the following: ``` gnome-terminal -- bash -c "ssh -i ~/.ssh/virtual_machines remote@remotehost; exec bash;" ``` However, once I have SSH into the remote host, I want to switch user by doing a `sudo su test`. I have already added the command i...
Assuming you want to start a `gnome-terminal` window/tab inside which is started a login shell session running as `test` on `remotehost`, that would be: ``` gnome-terminal -- ssh -i ~/.ssh/virtual_machines -t remote@remotehost 'exec sudo -iu test' ``` Using `su` in combination with `sudo` sounds a bit silly to me. `...
732,966
<p>I'm looking for a way to edit files with a script that will provide an alternate definition for a variable in C and this redefinition is controlled by a compiler D-flag using a POSIX application that I write a script for. So for example, imagine the token <code>nice_var</code> should be renamed to <code>cool_var</co...
[ { "answer_id": 732987, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 3, "selected": true, "text": "<p>This is a &quot;best effort&quot; solution that provides a naïve substitution without awareness of language syntax...
2023/01/24
[ "https://unix.stackexchange.com/questions/732966", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/411390/" ]
I'm looking for a way to edit files with a script that will provide an alternate definition for a variable in C and this redefinition is controlled by a compiler D-flag using a POSIX application that I write a script for. So for example, imagine the token `nice_var` should be renamed to `cool_var` like so: Sample inpu...
This is a "best effort" solution that provides a naïve substitution without awareness of language syntax, regardless of whether the text is a variable, in a comment line (`/* don't change nice_var here */`), quoted in a string (`char *p = "I've got nice_var here"`), or even part of another word (`int quitenice_vartoo`)...
732,978
<p>I have a FASTA file of 536 DNA sequences containing multiple species, but it is not necessarily in order according to species name.</p> <p>My headers with the sequences look like</p> <pre><code>&gt;COLFG678-14|MZ630002|Agabus|adpressus|AEC6988|COI-5P AATC &gt;INRMA1514-14|NA|Agabus|thomsoni|ABZ7453|COI-5P ATTT &gt;C...
[ { "answer_id": 732994, "author": "Aditya", "author_id": 547914, "author_profile": "https://unix.stackexchange.com/users/547914", "pm_score": 0, "selected": false, "text": "<pre><code>sort -t'|' -k3 -k4 fasta.txt\n</code></pre>\n<p>Output:</p>\n<pre><code>&quot;&gt;COLFG678-14|MZ630002|Ag...
2023/01/24
[ "https://unix.stackexchange.com/questions/732978", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/511899/" ]
I have a FASTA file of 536 DNA sequences containing multiple species, but it is not necessarily in order according to species name. My headers with the sequences look like ``` >COLFG678-14|MZ630002|Agabus|adpressus|AEC6988|COI-5P AATC >INRMA1514-14|NA|Agabus|thomsoni|ABZ7453|COI-5P ATTT >CONOR053-14|NA|Agabus|sturmii...
You simply need to sort the lines by fields of 3 and 4. Fields separated by | ``` $ sed 'N;s/\n/#/g' infile | sort -t '|' -k3,4 | tr '#' '\n' >COLFG676-14|MZ631238|Agabus|adpressus|AEC6988|COI-5P AATG >COLFG678-14|MZ630002|Agabus|adpressus|AEC6988|COI-5P AATC >CONOR053-14|NA|Agabus|sturmii|AAJ1337|COI-5P ACAA >INRMA1...
733,021
<p>I am getting confused about setting local variables in bash functions.</p> <p>It seems that using</p> <pre><code> local dgt local ltr local braces local da </code></pre> <p>could be safer than using</p> <pre><code> local dgt ltr braces da </code></pre> <p>I am worried about the possibility of a variable not ...
[ { "answer_id": 733018, "author": "forest", "author_id": 164143, "author_profile": "https://unix.stackexchange.com/users/164143", "pm_score": 6, "selected": false, "text": "<p>A signal handler is just a function within a given process' address space. This function is executed whenever the...
2023/01/25
[ "https://unix.stackexchange.com/questions/733021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/540882/" ]
I am getting confused about setting local variables in bash functions. It seems that using ``` local dgt local ltr local braces local da ``` could be safer than using ``` local dgt ltr braces da ``` I am worried about the possibility of a variable not getting defined as local, or not having the value s...
A signal handler is just a function within a given process' address space. This function is executed whenever the signal is received. There's nothing special about it (although there are certain actions that should not be performed within a signal handler), and it does not reside in a special thread. While signals are...
733,038
<p>I want to filter all the lines that match exactly with ALL the patterns in the text file contain the next lines:</p> <pre><code>c1 and c2 and c15 =&gt; r1 c1 and c3 and c11 =&gt; r2 c1 and c2 =&gt; r3 c2 and c16 =&gt; r4 </code></pre> <p>I have tried with <code>grep</code> using:</p> <pre><code>grep -w &quot;c1&quot...
[ { "answer_id": 733045, "author": "stoney", "author_id": 239465, "author_profile": "https://unix.stackexchange.com/users/239465", "pm_score": 0, "selected": false, "text": "<p>If your <code>grep</code> has PCRE-support, try something like:</p>\n<pre><code>grep -P '(?=.*c1 )(?=.*c2)' file\...
2023/01/25
[ "https://unix.stackexchange.com/questions/733038", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/519710/" ]
I want to filter all the lines that match exactly with ALL the patterns in the text file contain the next lines: ``` c1 and c2 and c15 => r1 c1 and c3 and c11 => r2 c1 and c2 => r3 c2 and c16 => r4 ``` I have tried with `grep` using: ``` grep -w "c1" file | grep -w "c2" ``` It returns the correct answer: ``` c1 ...
Using `awk` : ``` awk -v arrayvar="c1,c2" ' { split(arrayvar, a, ",") for(i in a){ r="(^|" FS ")" a[i] "($|" FS ")" if($0 !~ r) next } print }' input ``` We are using the [`split()`](https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html) function. > > `split(s, a ...
733,063
<p>Eve though in dconf the profiles i installed are shown</p> <pre><code>&gt; dconf list /org/gnome/terminal/legacy/profiles:/ :3fab5042-3b59-44c2-b86e-df287109b3d7/ :93be6823-4719-4dea-be06-ebf0ae9091d8/ :Aci/ :Wild-cherry/ :b1dcc9dd-5262-4d8d-a863-c897e6d979b9/ default list </code></pre> <p>In my terminal preference...
[ { "answer_id": 733045, "author": "stoney", "author_id": 239465, "author_profile": "https://unix.stackexchange.com/users/239465", "pm_score": 0, "selected": false, "text": "<p>If your <code>grep</code> has PCRE-support, try something like:</p>\n<pre><code>grep -P '(?=.*c1 )(?=.*c2)' file\...
2023/01/25
[ "https://unix.stackexchange.com/questions/733063", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557795/" ]
Eve though in dconf the profiles i installed are shown ``` > dconf list /org/gnome/terminal/legacy/profiles:/ :3fab5042-3b59-44c2-b86e-df287109b3d7/ :93be6823-4719-4dea-be06-ebf0ae9091d8/ :Aci/ :Wild-cherry/ :b1dcc9dd-5262-4d8d-a863-c897e6d979b9/ default list ``` In my terminal preferences they are not shown so tha...
Using `awk` : ``` awk -v arrayvar="c1,c2" ' { split(arrayvar, a, ",") for(i in a){ r="(^|" FS ")" a[i] "($|" FS ")" if($0 !~ r) next } print }' input ``` We are using the [`split()`](https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html) function. > > `split(s, a ...
733,064
<p>Assume two files with the following content:</p> <pre><code>$ cat ttest1.txt x = 1 x = 3 y = 5 $ cat ttest2.txt x = 4 x = 10 y = 3 </code></pre> <p>I would like to recursively grep the files for <code>x</code> and print the last instance in each file. So, the desired output is</p> <pre><code>ttest1.txt:x = 3 ttest...
[ { "answer_id": 733065, "author": "Ljm Dullaart", "author_id": 237080, "author_profile": "https://unix.stackexchange.com/users/237080", "pm_score": 3, "selected": true, "text": "<p>When you do</p>\n<pre><code>grep -r x ttest* \n</code></pre>\n<p>you get a single stream with</p>\n<pre><cod...
2023/01/25
[ "https://unix.stackexchange.com/questions/733064", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/118395/" ]
Assume two files with the following content: ``` $ cat ttest1.txt x = 1 x = 3 y = 5 $ cat ttest2.txt x = 4 x = 10 y = 3 ``` I would like to recursively grep the files for `x` and print the last instance in each file. So, the desired output is ``` ttest1.txt:x = 3 ttest2.txt:x = 10 ``` The following combination ...
When you do ``` grep -r x ttest* ``` you get a single stream with ``` ttest1.txt:x = 1 ttest1.txt:x = 3 ttest2.txt:x = 4 ttest2.txt:x = 10 ``` If you `tail -1` that, you get the `ttest2.txt:x = 10`. That is as expected. But you want the `grep | tail` combination done on each separate file, not on the consolidat...
733,134
<p>We have a set of Centos7 machines that were configured with 100GB <code>/tmp</code> and 400GB <code>/scratch</code> partitions. The tools we're using are consuming more <code>/tmp</code> space than anticipated so we need to re-allocate some <code>/scratch</code> space to <code>/tmp</code>.</p> <p>Our systems are set...
[ { "answer_id": 733065, "author": "Ljm Dullaart", "author_id": 237080, "author_profile": "https://unix.stackexchange.com/users/237080", "pm_score": 3, "selected": true, "text": "<p>When you do</p>\n<pre><code>grep -r x ttest* \n</code></pre>\n<p>you get a single stream with</p>\n<pre><cod...
2023/01/26
[ "https://unix.stackexchange.com/questions/733134", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/411417/" ]
We have a set of Centos7 machines that were configured with 100GB `/tmp` and 400GB `/scratch` partitions. The tools we're using are consuming more `/tmp` space than anticipated so we need to re-allocate some `/scratch` space to `/tmp`. Our systems are set up with two 1TB NVME drives in RAID-1; relevant lsblk output: ...
When you do ``` grep -r x ttest* ``` you get a single stream with ``` ttest1.txt:x = 1 ttest1.txt:x = 3 ttest2.txt:x = 4 ttest2.txt:x = 10 ``` If you `tail -1` that, you get the `ttest2.txt:x = 10`. That is as expected. But you want the `grep | tail` combination done on each separate file, not on the consolidat...
733,184
<p>I have a <strong>file.csv</strong></p> <pre><code>&quot;ItemNo&quot;,&quot;Name&quot;,&quot;Weight&quot; &quot;a001&quot;,&quot;Item a&quot;,&quot;1.1&quot; &quot;a002&quot;,&quot;Item x&quot;,&quot;1.2&quot; &quot;a003&quot;,&quot;Item_4&quot;,&quot;1.0&quot; &quot;a004&quot;,&quot;Item b&quot;,&quot;1.1&quot; &quo...
[ { "answer_id": 733261, "author": "Ed Morton", "author_id": 133219, "author_profile": "https://unix.stackexchange.com/users/133219", "pm_score": 1, "selected": false, "text": "<p>Using any awk:</p>\n<pre><code>$ awk -F, '{sub(/\\r$/,&quot;&quot;)} NR==FNR{a[$1]; next} $1 in a{print $2}' i...
2023/01/26
[ "https://unix.stackexchange.com/questions/733184", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558210/" ]
I have a **file.csv** ``` "ItemNo","Name","Weight" "a001","Item a","1.1" "a002","Item x","1.2" "a003","Item_4","1.0" "a004","Item b","1.1" "a005","Itemb2","2.0" "a006","a004","2.0" ``` Also I have a few **itemno.csv** ``` "a003" "a001" "a004" ``` I am looking for a command to create a list of the "Names" that are...
Now I know what my problem was. The **itemno.csv** was: ``` "a003"\r "a001"\r "a004" ``` Without the \r at the end of each line, the command ``` grep -f itemno.csv file.csv | awk -F, '{print $2}' ``` is working better and the **output** is ``` "Item_4" "Item a" "Item b" "a004" ``` --- Without the \r at the e...
733,207
<p>How can I check if a string has any whitespace characters in it? I do not have to worry about things outside of ASCII for example unicode zero width characters etc. You can assume that the string is stored in a shell variable, e.g. <code>$string</code>.</p> <p>Example of behavior:</p> <p><code>abc </code> has a spac...
[ { "answer_id": 733213, "author": "AdminBee", "author_id": 377345, "author_profile": "https://unix.stackexchange.com/users/377345", "pm_score": 1, "selected": false, "text": "<p>Let's assume your string is stored in a shell variable <code>$string</code>. In that case, since you have indic...
2023/01/26
[ "https://unix.stackexchange.com/questions/733207", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/124109/" ]
How can I check if a string has any whitespace characters in it? I do not have to worry about things outside of ASCII for example unicode zero width characters etc. You can assume that the string is stored in a shell variable, e.g. `$string`. Example of behavior: `abc` has a space so it would return true `\tabc` ha...
In POSIX sh syntax: ``` case $string in (*[[:blank:]]*) echo "string contains at least one character classified as blank";; (*[[:space:]]*) echo "string contains at least one character classified as whitespace (but not blank)";; (*) echo no character classified as whitespace;; esac ``` `[:blank:]` is required ...
733,227
<p>I exported all my pictures from Mac to my PC (Windows 11, but also running Ubuntu through PowerShell). The export created every directory (1000s of folders) in formats like the following and stripped out the original creation date:</p> <pre><code>April 1, 2004 Amsterdam, September 18, 2018 Anderson Arb...
[ { "answer_id": 733232, "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=\"https://unix.stackexchange.com/questions/730894/what-about-rename-different-versions-and-us...
2023/01/26
[ "https://unix.stackexchange.com/questions/733227", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558245/" ]
I exported all my pictures from Mac to my PC (Windows 11, but also running Ubuntu through PowerShell). The export created every directory (1000s of folders) in formats like the following and stripped out the original creation date: ``` April 1, 2004 Amsterdam, September 18, 2018 Anderson Arbor, March 24, ...
With `zsh`: ``` $ autoload -Uz zmv $ zmodload zsh/datetime $ zmv -n '(|(*), )([^ ]## <1-31>, <->)' \ '$(strftime %F $(strftime -r "%B %d, %Y" $3))${2:+ $2}' mv -- 'Amsterdam, September 18, 2018' '2018-09-18 Amsterdam' mv -- 'Anderson Arbor, March 24, 2011' '2011-03-24 Anderson Arbor' mv -- 'April 1, 2004' 200...
733,240
<p>I tried a lot of ways how to exclude <strong>.Library</strong> directory from <code>find</code> while trying to find something in my home directory, but it anyway prints me tons of lines with <em>&quot;Permission denied&quot;</em> from <strong>Library</strong> directory.</p> <p><a href="https://i.stack.imgur.com/IAn...
[ { "answer_id": 733244, "author": "telometto", "author_id": 469646, "author_profile": "https://unix.stackexchange.com/users/469646", "pm_score": 0, "selected": false, "text": "<p>You need the following syntax <code>find . -not -path '*/Library' -type f -name '*kate*'</code>. I don't know ...
2023/01/26
[ "https://unix.stackexchange.com/questions/733240", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557857/" ]
I tried a lot of ways how to exclude **.Library** directory from `find` while trying to find something in my home directory, but it anyway prints me tons of lines with *"Permission denied"* from **Library** directory. [![errors](https://i.stack.imgur.com/IAnFd.png)](https://i.stack.imgur.com/IAnFd.png) I did it with ...
Looks like you want `find` not to traverse the `Library` directory in the current working directory, in which case, that would be: ``` find . -path ./Library -prune -o -name '*kate*' -print ``` If it's any directory called `Library` you want to prune, not just the one in the current working directory (under `.`): `...
733,272
<p>I am using <code>read</code> for user input to perform some operation. The selector uses a two character test to print the appropriate information, without requiring the user to press <code>ENTER</code> after his input. Would it be possible to accept the <code>q</code> value to exit, because it is not composed of ...
[ { "answer_id": 733276, "author": "Edgar Magallon", "author_id": 414186, "author_profile": "https://unix.stackexchange.com/users/414186", "pm_score": 3, "selected": true, "text": "<p>I don't believe the bash <code>read</code> built-in has that functionality. However you can implement a cu...
2023/01/27
[ "https://unix.stackexchange.com/questions/733272", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/540882/" ]
I am using `read` for user input to perform some operation. The selector uses a two character test to print the appropriate information, without requiring the user to press `ENTER` after his input. Would it be possible to accept the `q` value to exit, because it is not composed of a two character selector. ``` local...
I don't believe the bash `read` built-in has that functionality. However you can implement a custom read *command* or *function* to achieve that. For example, you can use this function: ```bash read_or_quit(){ x=0; while ((++x<=2)); do read -n 1 if [[ $REPLY = q ]]; then echo q break else ...
733,275
<p>It might seem very easy, but I'm stuck at this.</p> <p>I have a string that is CSV and the length of items is unknown.</p> <pre><code>&quot;item1,item2,item3,...&quot; </code></pre> <p>I want to cut it, and loop over its items.</p> <p>I tried:</p> <pre><code>while IFS=, read item; do echo $item done &lt;&lt;&lt; ...
[ { "answer_id": 733281, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 2, "selected": false, "text": "<p>You could also use <code>awk</code> as following (Assuming that <code>$csvString</code> contains strings of a Simpl...
2023/01/27
[ "https://unix.stackexchange.com/questions/733275", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/168855/" ]
It might seem very easy, but I'm stuck at this. I have a string that is CSV and the length of items is unknown. ``` "item1,item2,item3,..." ``` I want to cut it, and loop over its items. I tried: ``` while IFS=, read item; do echo $item done <<< $csvString ``` But it just gave me the entire string once. And...
You could also use `awk` as following (Assuming that `$csvString` contains strings of a Simple-csv format): ``` awk -v itmStr="$csvString" ' BEGIN{ itmNr=split(itmStr, items, /,/) for (i=1; i<=itmNr; i++) print items[i] }' ```
733,306
<p>After SFTP logins were no longer working with error 127 we found that the SSH connection created some output by a script installed in /etc/profile.d/.</p> <p>Previous versions of sshd had an option available called &quot;UseLogin&quot; which by default was set to &quot;no&quot;, thus did not execute stuff from profi...
[ { "answer_id": 733317, "author": "Marki", "author_id": 40285, "author_profile": "https://unix.stackexchange.com/users/40285", "pm_score": 2, "selected": false, "text": "<p>Never mind.</p>\n<p>Someone dropped <code>LD_LIBRARY_PATH=/some/path</code> into <code>/etc/profile.d/xxx</code>, wi...
2023/01/27
[ "https://unix.stackexchange.com/questions/733306", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/40285/" ]
After SFTP logins were no longer working with error 127 we found that the SSH connection created some output by a script installed in /etc/profile.d/. Previous versions of sshd had an option available called "UseLogin" which by default was set to "no", thus did not execute stuff from profile. Now that option no longer...
SFTP uses SSH as transport. Any SFTP client expects the SSH server to establish communication with an SFTP server (like `sftp-server`). At least with OpenSSH, when an SSH server is told to run something, it uses the target user's shell for this. One can define a subsystem (it may be a custom subsystem) by adding `Sub...
733,351
<p>I want to set up a cron task to automate a Python script. For example: Suppose we have the script in the desktop directory.</p> <pre><code>#set to run at 7 am each day mkdir url1 cp newspaper.py url1 python newspaper.py URL </code></pre> <p>How would I do this?</p>
[ { "answer_id": 733354, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 3, "selected": true, "text": "<ol>\n<li>modify your script so it won't rely on relative paths. You can use <code>cd</code> in your script, but <...
2023/01/27
[ "https://unix.stackexchange.com/questions/733351", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558361/" ]
I want to set up a cron task to automate a Python script. For example: Suppose we have the script in the desktop directory. ``` #set to run at 7 am each day mkdir url1 cp newspaper.py url1 python newspaper.py URL ``` How would I do this?
1. modify your script so it won't rely on relative paths. You can use `cd` in your script, but `mkdir newdir` will attempt to create that `newdir` in a folder you won't expect. Do `cd /proper/path` first or do `mkdir /proper/path/newdir`, and do not forget that all other file manipulation commands are also could be vic...
733,352
<p>I want to print the first two arguments of a bash function, with the unicode character <code>\u2263</code> on each side using a two space separation. The thing is that the final unicode must display at column 70. If the character region where <code>$1</code> and <code>$2</code> reaches column 68, the excess charac...
[ { "answer_id": 733353, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": -1, "selected": false, "text": "<p>Huh? What do you need?</p>\n<p>If the question is how to manipulate string length, then you can use string fu...
2023/01/27
[ "https://unix.stackexchange.com/questions/733352", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/506878/" ]
I want to print the first two arguments of a bash function, with the unicode character `\u2263` on each side using a two space separation. The thing is that the final unicode must display at column 70. If the character region where `$1` and `$2` reaches column 68, the excess characters are truncated. ``` 1 ...
Let's get 2 long parameters: ```bash set -- '123456789.123456789.123456789.123456789.' '987654321.987654321.987654321.987654321.' ``` Let's say we want to set V at 40, so we have 40 chars of field1 and 68-40=28 chars for field2 ```bash cl=40 cr=$((68-cl)) ``` Now we want to print the first field left-justified an...
733,382
<p>When I do enter those commands individualy, I get the results I want:</p> <pre><code>cat /var/log/apt/history.log | grep 'apt install' &gt; installation.txt grep -v &quot;nvidia&quot; installation.txt &gt; tmpfile &amp;&amp; mv tmpfile installation.txt awk -F&quot;ll &quot; '{print $2}' installation.txt &gt; temp1 s...
[ { "answer_id": 733384, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 2, "selected": true, "text": "<p>All combined into a single <code>awk</code> command as following:</p>\n<pre><code>awk -F'll ' '\n /apt install/ &am...
2023/01/27
[ "https://unix.stackexchange.com/questions/733382", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/-1/" ]
When I do enter those commands individualy, I get the results I want: ``` cat /var/log/apt/history.log | grep 'apt install' > installation.txt grep -v "nvidia" installation.txt > tmpfile && mv tmpfile installation.txt awk -F"ll " '{print $2}' installation.txt > temp1 sed -n '/--/!p' temp1 > temp2 sed -n '/-f/!p' temp2...
All combined into a single `awk` command as following: ``` awk -F'll ' ' /apt install/ && !/nvidia|-[-f]/{ print $2 } ' /var/log/apt/history.log >installation.txt ```
733,386
<p>I have an Acer netbook, with built-in camera, running just fine under Ubuntu/x86. I also have a stack of broken netbooks of the same model that suffered various accidents over the years of intense use, and serve as source of spare parts. And I got an Orange Pi, to which I wanted to attach a small, lean webcam - the ...
[ { "answer_id": 733384, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 2, "selected": true, "text": "<p>All combined into a single <code>awk</code> command as following:</p>\n<pre><code>awk -F'll ' '\n /apt install/ &am...
2023/01/27
[ "https://unix.stackexchange.com/questions/733386", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/30534/" ]
I have an Acer netbook, with built-in camera, running just fine under Ubuntu/x86. I also have a stack of broken netbooks of the same model that suffered various accidents over the years of intense use, and serve as source of spare parts. And I got an Orange Pi, to which I wanted to attach a small, lean webcam - the thi...
All combined into a single `awk` command as following: ``` awk -F'll ' ' /apt install/ && !/nvidia|-[-f]/{ print $2 } ' /var/log/apt/history.log >installation.txt ```
733,389
<p>Good evening,</p> <p>I'm trying to grep a list of databases stored within a MYSQL dump but I'd like to adjust some of the settings - I'm unsure how to do so.</p> <p>The code is currently;</p> <pre><code>#!/bin/sh echo &quot;What is the cPanel username!&quot; read cpuser cd /home/${cpuser}/public_html sqldump=$(fi...
[ { "answer_id": 733384, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 2, "selected": true, "text": "<p>All combined into a single <code>awk</code> command as following:</p>\n<pre><code>awk -F'll ' '\n /apt install/ &am...
2023/01/27
[ "https://unix.stackexchange.com/questions/733389", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558266/" ]
Good evening, I'm trying to grep a list of databases stored within a MYSQL dump but I'd like to adjust some of the settings - I'm unsure how to do so. The code is currently; ``` #!/bin/sh echo "What is the cPanel username!" read cpuser cd /home/${cpuser}/public_html sqldump=$(find . -name \*.sql -type f) sqlversi...
All combined into a single `awk` command as following: ``` awk -F'll ' ' /apt install/ && !/nvidia|-[-f]/{ print $2 } ' /var/log/apt/history.log >installation.txt ```
733,427
<p>I want to filter my log files with the keyword ALARM/FATAL in lines into another backup files, suppose I have the following two files</p> <pre><code>[root@TENCENT64 /tmp/test]# cat test_ccd.log ccd0.log:01-28 09:33:18:461 1254 F NORMAL ccd0.log:01-28 09:33:18:461 1254 F FATAL ccd0.log:01-28 09:34:30:827 1254 E ALA...
[ { "answer_id": 733429, "author": "Stephen Harris", "author_id": 168757, "author_profile": "https://unix.stackexchange.com/users/168757", "pm_score": 2, "selected": false, "text": "<p>This may be easier as a <code>for</code> loop</p>\n<p>eg</p>\n<pre><code>for file in *.log\ndo\n grep -E...
2023/01/28
[ "https://unix.stackexchange.com/questions/733427", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558427/" ]
I want to filter my log files with the keyword ALARM/FATAL in lines into another backup files, suppose I have the following two files ``` [root@TENCENT64 /tmp/test]# cat test_ccd.log ccd0.log:01-28 09:33:18:461 1254 F NORMAL ccd0.log:01-28 09:33:18:461 1254 F FATAL ccd0.log:01-28 09:34:30:827 1254 E ALARM [root@TENC...
The argument to `grep` is missing and `:` should be an `L` to get the expected result, thus ``` grep -E "ALARM|FATA:" 1>> "$0.txt" ``` should be ``` grep -E "ALARM|FATAL" "$0" > "$0.txt" ``` (or use `>>` or `1>>` if you want to append the result to an existing file) Since `$0` should be the command name and posi...
733,441
<p>I have <strong>file1.csv</strong></p> <pre><code>&quot;word 1&quot; &quot;&quot; &quot;word 3&quot; &quot;&quot; &quot;word 5&quot; &quot;word 6&quot; </code></pre> <p>and <strong>file2.csv</strong></p> <pre><code>&quot;replacement text 1&quot; &quot;replacement text 2&quot; &quot;replacement text 3&quot; &quot;repl...
[ { "answer_id": 733443, "author": "Kusalananda", "author_id": 116858, "author_profile": "https://unix.stackexchange.com/users/116858", "pm_score": 3, "selected": false, "text": "<p>This is assuming that the files have the same number of lines: Using <code>paste</code> to create a CSV rec...
2023/01/28
[ "https://unix.stackexchange.com/questions/733441", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558210/" ]
I have **file1.csv** ``` "word 1" "" "word 3" "" "word 5" "word 6" ``` and **file2.csv** ``` "replacement text 1" "replacement text 2" "replacement text 3" "replacement text 4" "replacement text 5" "replacement text 6" ``` I'm looking for a command that checks where there are empty lines (or lines with "") in fil...
Another `awk` alternative: ``` awk '{getline other < "file2.csv"} $0 == "\"\"" {$0 = other} {print}' file1.csv > output.csv ``` Or `paste` + `sed`: ``` paste -d '\n' file1.csv file2.csv| sed 'N;s/^""\n//;s/\n.*//' > output.csv ``` If `file2.csv` doesn't have enough lines to satisfy all `""` lines of `fi...
733,442
<p>i have a problem with DNS resolution.</p> <p>The routing seems to work, because I can ping other servers and traceroute also works.</p> <p>But using dig, i get the a address for 'a.root-servers.net not found error.</p> <p>I'm on opensuse leap 15.4.</p> <pre><code>dig +trace google.de @1.1.1.1 ; &lt;&lt;&gt;&gt; DiG...
[ { "answer_id": 733443, "author": "Kusalananda", "author_id": 116858, "author_profile": "https://unix.stackexchange.com/users/116858", "pm_score": 3, "selected": false, "text": "<p>This is assuming that the files have the same number of lines: Using <code>paste</code> to create a CSV rec...
2023/01/28
[ "https://unix.stackexchange.com/questions/733442", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558452/" ]
i have a problem with DNS resolution. The routing seems to work, because I can ping other servers and traceroute also works. But using dig, i get the a address for 'a.root-servers.net not found error. I'm on opensuse leap 15.4. ``` dig +trace google.de @1.1.1.1 ; <<>> DiG 9.16.20 <<>> +trace google.de @1.1.1.1 ;; ...
Another `awk` alternative: ``` awk '{getline other < "file2.csv"} $0 == "\"\"" {$0 = other} {print}' file1.csv > output.csv ``` Or `paste` + `sed`: ``` paste -d '\n' file1.csv file2.csv| sed 'N;s/^""\n//;s/\n.*//' > output.csv ``` If `file2.csv` doesn't have enough lines to satisfy all `""` lines of `fi...
733,456
<p>Is it possible to test whether a function can be used, in case the file in which the function resides has not been sourced ?</p>
[ { "answer_id": 733457, "author": "JdeHaan", "author_id": 44864, "author_profile": "https://unix.stackexchange.com/users/44864", "pm_score": 3, "selected": true, "text": "<p>Test the result of</p>\n<pre><code>type functionname\n\n$ if type existingfunction &gt;/dev/null 2&gt;&amp;1 ; then...
2023/01/28
[ "https://unix.stackexchange.com/questions/733456", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/506878/" ]
Is it possible to test whether a function can be used, in case the file in which the function resides has not been sourced ?
Test the result of ``` type functionname $ if type existingfunction >/dev/null 2>&1 ; then echo yes ; else echo no ; fi yes $ $ if type nonexistingfunction >/dev/null 2>&1 ; then echo yes ; else echo no ; fi no $ ```
733,476
<p>When I try to install a package say <code>git</code> using:</p> <pre><code>dnf install -y git </code></pre> <p>in the very same virtual machine image dnf/yum sometimes simply installs the package, but sometimes, usually if some time spent after the latest dnf/yum usage it starts to update repositories like:</p> <pre...
[ { "answer_id": 733477, "author": "Romeo Ninov", "author_id": 101265, "author_profile": "https://unix.stackexchange.com/users/101265", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://access.redhat.com/solutions/3430121\" rel=\"nofollow noreferrer\">According to RH</a> this...
2023/01/28
[ "https://unix.stackexchange.com/questions/733476", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/491418/" ]
When I try to install a package say `git` using: ``` dnf install -y git ``` in the very same virtual machine image dnf/yum sometimes simply installs the package, but sometimes, usually if some time spent after the latest dnf/yum usage it starts to update repositories like: ``` AlmaLinux 9 - AppStream ...
For those not having Red Hat account answer can be found [here](https://linux.die.net/man/5/yum.conf), under `metadata_expire` parameter. Also `man yum.conf` will give useful information. On my Rocky Linux 9.1 system this parameter is set inside almost every "`rocky`" repo contained in `/etc/yum.repos.d/rocky*.repo` f...
733,502
<p>I cannot get my Virtual Box 7.0 &quot;bridged adapter&quot; to work on my laptop (Kubuntu 22.10). I have a project that I need to submit, but I cannot move forward until I fix this. This affects all my guest machines.</p> <p>These are my guest virtual machines:</p> <p><a href="https://i.stack.imgur.com/pTWBp.png" re...
[ { "answer_id": 733507, "author": "Nicolas Formichella", "author_id": 407300, "author_profile": "https://unix.stackexchange.com/users/407300", "pm_score": 1, "selected": false, "text": "<p>You will not be able to</p>\n<blockquote>\n<p>Note that a bridge cannot be established over Wi-Fi ne...
2023/01/28
[ "https://unix.stackexchange.com/questions/733502", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/432050/" ]
I cannot get my Virtual Box 7.0 "bridged adapter" to work on my laptop (Kubuntu 22.10). I have a project that I need to submit, but I cannot move forward until I fix this. This affects all my guest machines. These are my guest virtual machines: [![Guest Virtual Machines](https://i.stack.imgur.com/pTWBp.png)](https://...
You will not be able to > > Note that a bridge cannot be established over Wi-Fi networks operating in Ad-Hoc or Infrastructure modes. This is due to the IEEE 802.11 standard that specifies the use of 3-address frames in Wi-Fi for the efficient use of airtime. > > > From [Red Hat support site](https://access.redha...
733,518
<p><strong>I have a directory structure that follows this kind of pattern:</strong></p> <pre><code>- Dir 01 (Disc 1) \ - Dir 01 (Disc 1).iso - Dir 01 (Disc 2) \ - Dir 01 (Disc 2).iso - Dir 01 (Disc 3) \ - Dir 01 (Disc 3).iso - Dir 02 (Disc 1) \ - Dir 02 (Disc 1).iso - Dir 02 (Disc 2) \ - Dir 02 (Disc 2).iso ...
[ { "answer_id": 733507, "author": "Nicolas Formichella", "author_id": 407300, "author_profile": "https://unix.stackexchange.com/users/407300", "pm_score": 1, "selected": false, "text": "<p>You will not be able to</p>\n<blockquote>\n<p>Note that a bridge cannot be established over Wi-Fi ne...
2023/01/28
[ "https://unix.stackexchange.com/questions/733518", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558516/" ]
**I have a directory structure that follows this kind of pattern:** ``` - Dir 01 (Disc 1) \ - Dir 01 (Disc 1).iso - Dir 01 (Disc 2) \ - Dir 01 (Disc 2).iso - Dir 01 (Disc 3) \ - Dir 01 (Disc 3).iso - Dir 02 (Disc 1) \ - Dir 02 (Disc 1).iso - Dir 02 (Disc 2) \ - Dir 02 (Disc 2).iso - Dir 02 (Disc 1) (A) \ ...
You will not be able to > > Note that a bridge cannot be established over Wi-Fi networks operating in Ad-Hoc or Infrastructure modes. This is due to the IEEE 802.11 standard that specifies the use of 3-address frames in Wi-Fi for the efficient use of airtime. > > > From [Red Hat support site](https://access.redha...
733,529
<p>I have <strong>file1.txt</strong></p> <pre><code>0.1234 0.333 0.22 0.1 </code></pre> <p>and <strong>file2.txt</strong></p> <pre><code>2 10 100 100 </code></pre> <p>I'm looking for a command that multiplies the lines with each other and outputs as many decimal places as file1.txt had at this position/line. <strong>ou...
[ { "answer_id": 733530, "author": "steeldriver", "author_id": 65304, "author_profile": "https://unix.stackexchange.com/users/65304", "pm_score": 4, "selected": true, "text": "<p>If your awk implementation provides access to the underlying C library's dynamic width and precision features, ...
2023/01/29
[ "https://unix.stackexchange.com/questions/733529", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558210/" ]
I have **file1.txt** ``` 0.1234 0.333 0.22 0.1 ``` and **file2.txt** ``` 2 10 100 100 ``` I'm looking for a command that multiplies the lines with each other and outputs as many decimal places as file1.txt had at this position/line. **output.txt** ``` 0.2468 3.330 22.00 10.0 ``` so far i use this command: `pas...
If your awk implementation provides access to the underlying C library's dynamic width and precision features, **and the numbers in `file1.txt` can never include mantissa-exponent representations like `1.23e4`**, then you could do something like ``` $ paste file1.txt file2.txt | awk '{split($1,a,/[.]/); printf "%.*...
733,533
<p>I'm using GNU sed 4.7 on Debian 11.</p> <p>I have a file with many lines, all of which have a first string in curly brackets at the beginning of the line, a final string in <code>@</code> chars at the end of the line, and a string containing alphanumeric, punctuation and other charcaters between the aforementioned t...
[ { "answer_id": 733534, "author": "cas", "author_id": 7696, "author_profile": "https://unix.stackexchange.com/users/7696", "pm_score": 3, "selected": true, "text": "<p>This is difficult to do in <code>sed</code> (because you need to do different things - nothing, modify with <code>s///</c...
2023/01/29
[ "https://unix.stackexchange.com/questions/733533", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558525/" ]
I'm using GNU sed 4.7 on Debian 11. I have a file with many lines, all of which have a first string in curly brackets at the beginning of the line, a final string in `@` chars at the end of the line, and a string containing alphanumeric, punctuation and other charcaters between the aforementioned termini strings. I w...
This is difficult to do in `sed` (because you need to do different things - nothing, modify with `s///`, and nothing again - to three different parts of each input line) but very easy to do in `perl`. ``` $ perl -lne '($first,$middle,$last) = (/({[^}]*})([^@]*)(@.*)/); $middle =~ s/[[:alnum:]]+//g; ...
733,540
<p>Is this the correct way to test for a number, with double <code>[[]]</code> enclosing <code>:digit:</code> and single quotes surrounding the regex ?</p> <pre><code>if [[ &quot;$var&quot; =~ '^[[:digit:]]+$' ]]; then </code></pre>
[ { "answer_id": 733534, "author": "cas", "author_id": 7696, "author_profile": "https://unix.stackexchange.com/users/7696", "pm_score": 3, "selected": true, "text": "<p>This is difficult to do in <code>sed</code> (because you need to do different things - nothing, modify with <code>s///</c...
2023/01/29
[ "https://unix.stackexchange.com/questions/733540", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/506878/" ]
Is this the correct way to test for a number, with double `[[]]` enclosing `:digit:` and single quotes surrounding the regex ? ``` if [[ "$var" =~ '^[[:digit:]]+$' ]]; then ```
This is difficult to do in `sed` (because you need to do different things - nothing, modify with `s///`, and nothing again - to three different parts of each input line) but very easy to do in `perl`. ``` $ perl -lne '($first,$middle,$last) = (/({[^}]*})([^@]*)(@.*)/); $middle =~ s/[[:alnum:]]+//g; ...
733,547
<p><code>w</code> command of my <code>sed</code> (sed of macOS 13.1) seems to be able to edit the input file with <code>cat</code> (bash 3.2):</p> <pre><code>printf &quot;hello\nworld\n&quot; &gt; foo.txt cat foo.txt | sed 's/l/L/g' | sed -n 'w foo.txt' cat foo.txt &gt; heLLo &gt; worLd </code></pre> <p>I looked over...
[ { "answer_id": 734493, "author": "cas", "author_id": 7696, "author_profile": "https://unix.stackexchange.com/users/7696", "pm_score": 2, "selected": false, "text": "<p>Use <code>sponge</code> (from <a href=\"https://joeyh.name/code/moreutils/\" rel=\"nofollow noreferrer\">moreutils</a>, ...
2023/01/29
[ "https://unix.stackexchange.com/questions/733547", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558535/" ]
`w` command of my `sed` (sed of macOS 13.1) seems to be able to edit the input file with `cat` (bash 3.2): ``` printf "hello\nworld\n" > foo.txt cat foo.txt | sed 's/l/L/g' | sed -n 'w foo.txt' cat foo.txt > heLLo > worLd ``` I looked over <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html> but I...
Use `sponge` (from [moreutils](https://joeyh.name/code/moreutils/), **OR** redirect to a temporary file and rename it over the original, **OR** use [ed](https://www.gnu.org/software/ed/) (or `ex` from vi/vim/nvi) instead of `sed` - remember that `sed` is the stream-oriented version of `ed`. `ed` = `editor`, `sed` = **s...
733,604
<p>I am trying to find the optimum way to back up dotfiles, and I have devised a way to do it. I am using git with rsync to back up all the dotfiles. The rsync script looks like this right now:</p> <pre><code>rsync -avhP $HOME/.??* --exclude-from=$HOME/.dotBackup/exclusions.list $HOME/.dotBackup </code></pre> <p>Howeve...
[ { "answer_id": 734493, "author": "cas", "author_id": 7696, "author_profile": "https://unix.stackexchange.com/users/7696", "pm_score": 2, "selected": false, "text": "<p>Use <code>sponge</code> (from <a href=\"https://joeyh.name/code/moreutils/\" rel=\"nofollow noreferrer\">moreutils</a>, ...
2023/01/29
[ "https://unix.stackexchange.com/questions/733604", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558596/" ]
I am trying to find the optimum way to back up dotfiles, and I have devised a way to do it. I am using git with rsync to back up all the dotfiles. The rsync script looks like this right now: ``` rsync -avhP $HOME/.??* --exclude-from=$HOME/.dotBackup/exclusions.list $HOME/.dotBackup ``` However, I do not think that i...
Use `sponge` (from [moreutils](https://joeyh.name/code/moreutils/), **OR** redirect to a temporary file and rename it over the original, **OR** use [ed](https://www.gnu.org/software/ed/) (or `ex` from vi/vim/nvi) instead of `sed` - remember that `sed` is the stream-oriented version of `ed`. `ed` = `editor`, `sed` = **s...
733,608
<p>I want to fetch some apis from github.</p> <p>so this is the code</p> <pre><code>array=(link1 link2 link3 link4) readarray -t item &lt; &lt;(for i in ${array[@]} do curl -s &quot;$i&quot; | jq '.tag_name' done) </code></pre> <p>and then I can fetch the data from the <strong>item</strong>.</p> <p>But the ...
[ { "answer_id": 734493, "author": "cas", "author_id": 7696, "author_profile": "https://unix.stackexchange.com/users/7696", "pm_score": 2, "selected": false, "text": "<p>Use <code>sponge</code> (from <a href=\"https://joeyh.name/code/moreutils/\" rel=\"nofollow noreferrer\">moreutils</a>, ...
2023/01/29
[ "https://unix.stackexchange.com/questions/733608", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/543427/" ]
I want to fetch some apis from github. so this is the code ``` array=(link1 link2 link3 link4) readarray -t item < <(for i in ${array[@]} do curl -s "$i" | jq '.tag_name' done) ``` and then I can fetch the data from the **item**. But the problem is if there is some links left to fetch, curl just stuck ...
Use `sponge` (from [moreutils](https://joeyh.name/code/moreutils/), **OR** redirect to a temporary file and rename it over the original, **OR** use [ed](https://www.gnu.org/software/ed/) (or `ex` from vi/vim/nvi) instead of `sed` - remember that `sed` is the stream-oriented version of `ed`. `ed` = `editor`, `sed` = **s...
733,631
<p>I am very new to the concept of dual booting and tried it on my PC.  My existing OS is Windows 10.  I downloaded the Manjaro-Budgie ISO file and saved it in my <code>E:</code> Drive in hopes of using that as an alternative OS.</p> <p>First I used EasyBCD to try and dual boot.  This somewhat worked, but when I tried ...
[ { "answer_id": 734493, "author": "cas", "author_id": 7696, "author_profile": "https://unix.stackexchange.com/users/7696", "pm_score": 2, "selected": false, "text": "<p>Use <code>sponge</code> (from <a href=\"https://joeyh.name/code/moreutils/\" rel=\"nofollow noreferrer\">moreutils</a>, ...
2023/01/29
[ "https://unix.stackexchange.com/questions/733631", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558618/" ]
I am very new to the concept of dual booting and tried it on my PC.  My existing OS is Windows 10.  I downloaded the Manjaro-Budgie ISO file and saved it in my `E:` Drive in hopes of using that as an alternative OS. First I used EasyBCD to try and dual boot.  This somewhat worked, but when I tried to use the Manjaro o...
Use `sponge` (from [moreutils](https://joeyh.name/code/moreutils/), **OR** redirect to a temporary file and rename it over the original, **OR** use [ed](https://www.gnu.org/software/ed/) (or `ex` from vi/vim/nvi) instead of `sed` - remember that `sed` is the stream-oriented version of `ed`. `ed` = `editor`, `sed` = **s...
733,674
<p>I have a json file <strong>file.json</strong> like this:</p> <pre><code>{ &quot;abc&quot;: &quot;123&quot;, &quot;def&quot;: 456, &quot;ghi&quot;: 789 } </code></pre> <p>I am trying to get value of all the keys using regex in bash terminal.</p> <p>Here is what I tried for getting value of <strong>abc</strong>:...
[ { "answer_id": 733675, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p>You'd need something like:</p>\n<pre><code>var=$(cat file.json) || exit\nregex='&quot;abc&quot;[[:space:...
2023/01/30
[ "https://unix.stackexchange.com/questions/733674", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558666/" ]
I have a json file **file.json** like this: ``` { "abc": "123", "def": 456, "ghi": 789 } ``` I am trying to get value of all the keys using regex in bash terminal. Here is what I tried for getting value of **abc**: ``` var=cat file.json regex='(abc\":) \"(.+)\",' [[ $var =~ $regex ]] echo ${BASE_REMATCH[1]} ...
If your file really is as simple as you show (without any special JSON encoding in the string values), I would just use `awk`: ``` $ awk '$1=="\"abc\":"{print $2}' file | tr -d '",' 123 ``` Or even GNU `grep`: ``` $ grep -oP '"abc":\s*"?\K[^,]+' file | tr -d '",' 123 ``` The `-P` enables PCRE regular expressions ...
733,678
<p>I want to match the possibility of zero or more keywords separated by commas.</p> <p>Am using the following regex</p> <pre><code>if [[ &quot;$var&quot; =~ ^([^,]+(,[^,]+)*)*$ ]]; then echo &quot;KY MATCH&quot; fi </code></pre> <p>I want to match the following</p> <pre><code>var=&quot;&quot; var=&quot;keyword&quot;...
[ { "answer_id": 733675, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p>You'd need something like:</p>\n<pre><code>var=$(cat file.json) || exit\nregex='&quot;abc&quot;[[:space:...
2023/01/30
[ "https://unix.stackexchange.com/questions/733678", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/506878/" ]
I want to match the possibility of zero or more keywords separated by commas. Am using the following regex ``` if [[ "$var" =~ ^([^,]+(,[^,]+)*)*$ ]]; then echo "KY MATCH" fi ``` I want to match the following ``` var="" var="keyword" var="keyword,keyword" var="keyword,keyword,keyword" ``` Can the regex be simp...
If your file really is as simple as you show (without any special JSON encoding in the string values), I would just use `awk`: ``` $ awk '$1=="\"abc\":"{print $2}' file | tr -d '",' 123 ``` Or even GNU `grep`: ``` $ grep -oP '"abc":\s*"?\K[^,]+' file | tr -d '",' 123 ``` The `-P` enables PCRE regular expressions ...
733,694
<p>I recently changed my password on my <a href="https://vmware.github.io/photon/" rel="nofollow noreferrer">VMware Photon OS</a> host. Now I want to reset it to the old one again, but <code>passwd</code> does not let me do it and displays the following message:</p> <pre><code>Password has been already used. Choose ano...
[ { "answer_id": 733675, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p>You'd need something like:</p>\n<pre><code>var=$(cat file.json) || exit\nregex='&quot;abc&quot;[[:space:...
2023/01/30
[ "https://unix.stackexchange.com/questions/733694", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/402870/" ]
I recently changed my password on my [VMware Photon OS](https://vmware.github.io/photon/) host. Now I want to reset it to the old one again, but `passwd` does not let me do it and displays the following message: ``` Password has been already used. Choose another. passwd: Have exhausted maximum number of retries for se...
If your file really is as simple as you show (without any special JSON encoding in the string values), I would just use `awk`: ``` $ awk '$1=="\"abc\":"{print $2}' file | tr -d '",' 123 ``` Or even GNU `grep`: ``` $ grep -oP '"abc":\s*"?\K[^,]+' file | tr -d '",' 123 ``` The `-P` enables PCRE regular expressions ...
733,710
<p>I have a file containing multiple lines, with fields separated by <em>tab</em>:</p> <pre class="lang-none prettyprint-override"><code>ID Code Date 1 XX 23/1/2018 1 XX 11/3/2021 2 XX 14/5/2011 2 XX 20/9/2013 3 XX 08/7/2014 3 XX 11/9/2016 3 XX 27/10/2018 </code></pre> <p>I would like to keep for e...
[ { "answer_id": 733711, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 1, "selected": false, "text": "<p>You can obtain the desired output using this code:</p>\n<pre><code>sed 1d file_of_data | sort -k1,2n -u\n</code><...
2023/01/30
[ "https://unix.stackexchange.com/questions/733710", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/494872/" ]
I have a file containing multiple lines, with fields separated by *tab*: ```none ID Code Date 1 XX 23/1/2018 1 XX 11/3/2021 2 XX 14/5/2011 2 XX 20/9/2013 3 XX 08/7/2014 3 XX 11/9/2016 3 XX 27/10/2018 ``` I would like to keep for each participant `ID` just one entry, based on the entry with the e...
Since you state that the records for each participant are ordered from oldest to newest, and you want to print only the record with the oldest date for each `ID`, this amounts to printing the first row encountered for each new `ID`. This is easily possible using `awk`: ```bash awk -F'\t' 'FNR>1 && !seen[$1]++' input.t...
733,765
<p>I have the following text file</p> <pre><code>... /a/b/c/f1 /a/b/c/f2 ... /a/b/c/d1 ... </code></pre> <p>where <code>f1</code> and <code>f2</code> are files, while <code>d1</code> is a directory. I would like to copy the exact hiearchy in my destination folder (<code>/z</code>).</p> <p>With bash, for each line <code...
[ { "answer_id": 733790, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 3, "selected": true, "text": "<p>Don't rsync the files manually. Use the <code>--files-from=</code> option to include your text file.</p>\n<p>Rules...
2023/01/30
[ "https://unix.stackexchange.com/questions/733765", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525966/" ]
I have the following text file ``` ... /a/b/c/f1 /a/b/c/f2 ... /a/b/c/d1 ... ``` where `f1` and `f2` are files, while `d1` is a directory. I would like to copy the exact hiearchy in my destination folder (`/z`). With bash, for each line `lr` readed from the text file, my script runs (I omitted the options for the s...
Don't rsync the files manually. Use the `--files-from=` option to include your text file. Rules for directories: * Only the directory is created if the path doesn't end with a trailing `/` * To sync a dir's contents, add a trailing `/` or option `--recursive` / `-r` alternatively If you use option `-a` and want recu...
733,768
<p>I have two NFS exports on my server configured identically in /etc/exports. On my NFS client one always auto-mounts with NFS-3 while the other mounts with NFS-4. I want nfs-4. How do I make that happen?</p> <p>On the server ('nina'):</p> <pre><code># cat /etc/exports /home 192.168.0.0/24(rw,no_all_squash,anonuid=154...
[ { "answer_id": 733790, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 3, "selected": true, "text": "<p>Don't rsync the files manually. Use the <code>--files-from=</code> option to include your text file.</p>\n<p>Rules...
2023/01/30
[ "https://unix.stackexchange.com/questions/733768", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/80431/" ]
I have two NFS exports on my server configured identically in /etc/exports. On my NFS client one always auto-mounts with NFS-3 while the other mounts with NFS-4. I want nfs-4. How do I make that happen? On the server ('nina'): ``` # cat /etc/exports /home 192.168.0.0/24(rw,no_all_squash,anonuid=1545,anongid=501) /mis...
Don't rsync the files manually. Use the `--files-from=` option to include your text file. Rules for directories: * Only the directory is created if the path doesn't end with a trailing `/` * To sync a dir's contents, add a trailing `/` or option `--recursive` / `-r` alternatively If you use option `-a` and want recu...
733,773
<p>Is there a <code>ps</code> or <code>pgrep</code> option or standard practice what will let me list all the running processes on a machine EXCEPT for a few specific ones I don't want to see?</p> <p>Put another way -- let's say I have four processes running</p> <pre><code>% ps PID TTY TIME CMD 26712 ttys00...
[ { "answer_id": 733789, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<pre><code>ps | grep -vFwf /tmp/no-interest.txty\n</code></pre>\n<p>Would filter out the lines of <code>ps<...
2023/01/30
[ "https://unix.stackexchange.com/questions/733773", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/22521/" ]
Is there a `ps` or `pgrep` option or standard practice what will let me list all the running processes on a machine EXCEPT for a few specific ones I don't want to see? Put another way -- let's say I have four processes running ``` % ps PID TTY TIME CMD 26712 ttys000 0:00.45 -zsh 28228 ttys001 0:00.2...
``` ps | grep -vFwf /tmp/no-interest.txty ``` Would filter out the lines of `ps` which contain any of the lines (word delimited) in `/tmp/no-interest.txty`. Note however that it looks for them anywhere, not only in the pid field. Since your shell seems to be zsh, if your `ps` accepts taking a list of pids as argumen...
733,814
<p>I need to change a word in a specific <code>define service</code> section where <code>service_description</code> is <code>NRPE - NTP_TIME</code> and where <code>contact_groups</code> is <code>opsgenie-sla1</code>, I need to change to <code>opsgenie-sla2</code> and I would like to do it with <code>sed</code> command ...
[ { "answer_id": 733823, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": true, "text": "<p>With <code>perl</code>, assuming there's no other <code>{</code>s, <code>}</code>s inside those <code>{.....
2023/01/31
[ "https://unix.stackexchange.com/questions/733814", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558826/" ]
I need to change a word in a specific `define service` section where `service_description` is `NRPE - NTP_TIME` and where `contact_groups` is `opsgenie-sla1`, I need to change to `opsgenie-sla2` and I would like to do it with `sed` command to shorten my work because I need to do it on multiple hosts. Below is a snippet...
With `perl`, assuming there's no other `{`s, `}`s inside those `{...}` services, you could do something like: ``` perl -0777 -pi -e ' s{^\h*define\h+service\s*\{.*?\}}{ my $service = $&; if ($service =~ m{^\h*service_description\h+NRPE - NTP_TIME\h*$}m) { $service =~ s{^\h*contact_groups\h+opsgenie-sla...
733,827
<p>From <code>man rsync</code>:</p> <blockquote> <p>--existing</p> <blockquote> <p>skip <em>creating new files</em> on receiver (emphasis mine)</p> </blockquote> </blockquote> <p>So, what I've done with apparent success:</p> <pre><code>rsync --existing -rtvhP &quot;remote.machine:/photos/*&quot; /photos </code></pre> <...
[ { "answer_id": 734549, "author": "captain", "author_id": 262716, "author_profile": "https://unix.stackexchange.com/users/262716", "pm_score": 2, "selected": false, "text": "<p>For this example I'm using:\nrsync version 2.6.9 protocol version 29</p>\n<p>Thanks to @Freddy for the suggest...
2023/01/31
[ "https://unix.stackexchange.com/questions/733827", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/262716/" ]
From `man rsync`: > > --existing > > > > > > > skip *creating new files* on receiver > > (emphasis mine) > > > > > > > > > So, what I've done with apparent success: ``` rsync --existing -rtvhP "remote.machine:/photos/*" /photos ``` This should reset any changed photos on my local machine to match the or...
For this example I'm using: rsync version 2.6.9 protocol version 29 Thanks to @Freddy for the suggestion. It looks like the `-c` flag takes precedence over `--existing`, so rsync does a lot of unnecessary (IMHO) work. Here is my test case which, to a newly created empty directory, needs to copy nothing and, I would ha...
733,850
<p>I have this simple script, which does nothing more than:</p> <ul> <li>check if an email matches a specific pattern</li> <li>in that case, add a tag to a taglist</li> <li>before quitting, print that taglist</li> </ul> <pre class="lang-bash prettyprint-override"><code>set -e lista_tag=() in_file=&quot;/tmp/grepmail-c...
[ { "answer_id": 734549, "author": "captain", "author_id": 262716, "author_profile": "https://unix.stackexchange.com/users/262716", "pm_score": 2, "selected": false, "text": "<p>For this example I'm using:\nrsync version 2.6.9 protocol version 29</p>\n<p>Thanks to @Freddy for the suggest...
2023/01/31
[ "https://unix.stackexchange.com/questions/733850", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558859/" ]
I have this simple script, which does nothing more than: * check if an email matches a specific pattern * in that case, add a tag to a taglist * before quitting, print that taglist ```bash set -e lista_tag=() in_file="/tmp/grepmail-classify.txt" # save stdin to file, to use it multiple times cp /dev/stdin $in_file ...
For this example I'm using: rsync version 2.6.9 protocol version 29 Thanks to @Freddy for the suggestion. It looks like the `-c` flag takes precedence over `--existing`, so rsync does a lot of unnecessary (IMHO) work. Here is my test case which, to a newly created empty directory, needs to copy nothing and, I would ha...
733,884
<p>How can I only list folders who have at least two files over 100 MB in them?</p>
[ { "answer_id": 733899, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 3, "selected": true, "text": "<h4>With <code>find</code> and <code>awk</code> :</h4>\n<p>List all files &gt; 100M</p>\n<pre><code>$ find . -ty...
2023/02/01
[ "https://unix.stackexchange.com/questions/733884", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/227237/" ]
How can I only list folders who have at least two files over 100 MB in them?
#### With `find` and `awk` : List all files > 100M ``` $ find . -type f -size +100M ./bar/ok ./foo/okp ./foo/ok ``` #### Now filter with `awk`: ``` $ find . -type f -size +100M -exec dirname {} + | awk '{dir[$0]++}END{for (i in dir) if (dir[i] >= 2) print i}' ./foo ``` It output only dirs with at least two f...
733,886
<p>This question is essentially the <em>opposite</em> of the first question below, and adjacently related to the second question, and is therefore not a duplicate:</p> <ol> <li><a href="https://askubuntu.com/q/309047/327339">Ask Ubuntu: How do I find out what filesystem my partitions are using?</a></li> <li><a href="ht...
[ { "answer_id": 733899, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 3, "selected": true, "text": "<h4>With <code>find</code> and <code>awk</code> :</h4>\n<p>List all files &gt; 100M</p>\n<pre><code>$ find . -ty...
2023/02/01
[ "https://unix.stackexchange.com/questions/733886", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/114401/" ]
This question is essentially the *opposite* of the first question below, and adjacently related to the second question, and is therefore not a duplicate: 1. [Ask Ubuntu: How do I find out what filesystem my partitions are using?](https://askubuntu.com/q/309047/327339) 2. [Unix & Linux: How to tell what type of filesys...
#### With `find` and `awk` : List all files > 100M ``` $ find . -type f -size +100M ./bar/ok ./foo/okp ./foo/ok ``` #### Now filter with `awk`: ``` $ find . -type f -size +100M -exec dirname {} + | awk '{dir[$0]++}END{for (i in dir) if (dir[i] >= 2) print i}' ./foo ``` It output only dirs with at least two f...
733,897
<p>I have 2 instances running on AWS. Instance A (main instance) and Instance B (rescue instance).</p> <p>I detached volume from Instance A and attached it to Instance B to perform some changes why because I am unable to login inside Instance A due to SSH issue.</p> <p>After doing changes on Instance B the UUID of the ...
[ { "answer_id": 733899, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 3, "selected": true, "text": "<h4>With <code>find</code> and <code>awk</code> :</h4>\n<p>List all files &gt; 100M</p>\n<pre><code>$ find . -ty...
2023/02/01
[ "https://unix.stackexchange.com/questions/733897", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558917/" ]
I have 2 instances running on AWS. Instance A (main instance) and Instance B (rescue instance). I detached volume from Instance A and attached it to Instance B to perform some changes why because I am unable to login inside Instance A due to SSH issue. After doing changes on Instance B the UUID of the PV & VG are now...
#### With `find` and `awk` : List all files > 100M ``` $ find . -type f -size +100M ./bar/ok ./foo/okp ./foo/ok ``` #### Now filter with `awk`: ``` $ find . -type f -size +100M -exec dirname {} + | awk '{dir[$0]++}END{for (i in dir) if (dir[i] >= 2) print i}' ./foo ``` It output only dirs with at least two f...
733,907
<p>I often want to grep output from processes that include a few header lines. But if grep would remove all actual content lines, I don't want to display the header lines. For this to work I would need a command similar to <code>tail</code> but instead of only returning n lines, it would return <em>all</em> lines but o...
[ { "answer_id": 733908, "author": "Paul_Pedant", "author_id": 379287, "author_profile": "https://unix.stackexchange.com/users/379287", "pm_score": 2, "selected": false, "text": "<p>You could save the first <code>n</code> lines in an awk array, and write them out when (and if) you see line...
2023/02/01
[ "https://unix.stackexchange.com/questions/733907", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/21212/" ]
I often want to grep output from processes that include a few header lines. But if grep would remove all actual content lines, I don't want to display the header lines. For this to work I would need a command similar to `tail` but instead of only returning n lines, it would return *all* lines but only if there are at l...
You could save the first `n` lines in an awk array, and write them out when (and if) you see line `n + 1`, which is when you discover you have at least one data line. ``` Awk_N=' FNR <= N { X[FNR] = $0; next; } FNR == N + 1 { for (j = 1; j in X; ++j) print X[j]; delete X; } { print; } ' awk -v N=7 "${Awk_N}" ...
733,915
<p>I have set up a DNS service on a Debian 11 server (BIND 9.16.33-Debian) for my company's LAN with the following (forward) zone file (<code>mycomp.com</code> isn't the real name, of course):</p> <pre><code># cat forward.mycomp.com.db ; ; BIND data file for local loopback interface ; $TTL 604800 @ IN SOA...
[ { "answer_id": 733908, "author": "Paul_Pedant", "author_id": 379287, "author_profile": "https://unix.stackexchange.com/users/379287", "pm_score": 2, "selected": false, "text": "<p>You could save the first <code>n</code> lines in an awk array, and write them out when (and if) you see line...
2023/02/01
[ "https://unix.stackexchange.com/questions/733915", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/364511/" ]
I have set up a DNS service on a Debian 11 server (BIND 9.16.33-Debian) for my company's LAN with the following (forward) zone file (`mycomp.com` isn't the real name, of course): ``` # cat forward.mycomp.com.db ; ; BIND data file for local loopback interface ; $TTL 604800 @ IN SOA ns1.mycomp.com. roo...
You could save the first `n` lines in an awk array, and write them out when (and if) you see line `n + 1`, which is when you discover you have at least one data line. ``` Awk_N=' FNR <= N { X[FNR] = $0; next; } FNR == N + 1 { for (j = 1; j in X; ++j) print X[j]; delete X; } { print; } ' awk -v N=7 "${Awk_N}" ...
733,933
<p>I am using the following control sequence to set up that when I click in the command line in shell (BASH) in XTerm the <strong>cursor moves to the position</strong>. At least, it used to worked that way in my ancient Fedora 18 I used to have. (I tend to write very long pipelines and therefor this feature is splendid...
[ { "answer_id": 733908, "author": "Paul_Pedant", "author_id": 379287, "author_profile": "https://unix.stackexchange.com/users/379287", "pm_score": 2, "selected": false, "text": "<p>You could save the first <code>n</code> lines in an awk array, and write them out when (and if) you see line...
2023/02/01
[ "https://unix.stackexchange.com/questions/733933", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/488266/" ]
I am using the following control sequence to set up that when I click in the command line in shell (BASH) in XTerm the **cursor moves to the position**. At least, it used to worked that way in my ancient Fedora 18 I used to have. (I tend to write very long pipelines and therefor this feature is splendid and quite cruti...
You could save the first `n` lines in an awk array, and write them out when (and if) you see line `n + 1`, which is when you discover you have at least one data line. ``` Awk_N=' FNR <= N { X[FNR] = $0; next; } FNR == N + 1 { for (j = 1; j in X; ++j) print X[j]; delete X; } { print; } ' awk -v N=7 "${Awk_N}" ...
733,937
<p>I have a file, as you can see, which is tab-separated data, about 4,000 lines, ten columns.</p> <p>The second column of the file records the different tissues.</p> <pre><code>samples tissue_s tissue_e tissue_d tissue_category tissue_visa sex study tissue_f age samples1 ear CNS ear CNS CNS ...
[ { "answer_id": 734032, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 3, "selected": true, "text": "<p>One way is to process the input file twice:</p>\n<pre><code>awk -F'\\t' -v frq=10 -v colId=2 '\n NR==FNR{ count[$co...
2023/02/01
[ "https://unix.stackexchange.com/questions/733937", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558958/" ]
I have a file, as you can see, which is tab-separated data, about 4,000 lines, ten columns. The second column of the file records the different tissues. ``` samples tissue_s tissue_e tissue_d tissue_category tissue_visa sex study tissue_f age samples1 ear CNS ear CNS CNS male 1 ea...
One way is to process the input file twice: ``` awk -F'\t' -v frq=10 -v colId=2 ' NR==FNR{ count[$colId]++; next } count[$colId] >frq ' infile infile ``` Note: User defined awk variables `frq` and `colId` are used for setting and to specifying at what minimum frequency of repeating the elements in the target col...
733,938
<p>I have one abc.yml file as below which contains username and password parameters. I have stored these parameters in env variable of my linux user But when application is execting abc.yml file it's not print value of env variables. It's only print environment variables.</p> <p>abc.yml:</p> <pre><code>type: MYSQL hos...
[ { "answer_id": 734032, "author": "αғsнιη", "author_id": 72456, "author_profile": "https://unix.stackexchange.com/users/72456", "pm_score": 3, "selected": true, "text": "<p>One way is to process the input file twice:</p>\n<pre><code>awk -F'\\t' -v frq=10 -v colId=2 '\n NR==FNR{ count[$co...
2023/02/01
[ "https://unix.stackexchange.com/questions/733938", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/546877/" ]
I have one abc.yml file as below which contains username and password parameters. I have stored these parameters in env variable of my linux user But when application is execting abc.yml file it's not print value of env variables. It's only print environment variables. abc.yml: ``` type: MYSQL host: localhost port: ...
One way is to process the input file twice: ``` awk -F'\t' -v frq=10 -v colId=2 ' NR==FNR{ count[$colId]++; next } count[$colId] >frq ' infile infile ``` Note: User defined awk variables `frq` and `colId` are used for setting and to specifying at what minimum frequency of repeating the elements in the target col...
733,956
<p>I would like to have this script's windows version</p> <pre><code>cat name-of-APK.apk | openssl dgst -binary -sha256 | openssl base64 | tr '+/' '-_' | tr -d '=' </code></pre> <p>How can I get that?</p>
[ { "answer_id": 733958, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 1, "selected": false, "text": "<p>You can actually use <code>cat</code> in PowerShell (which is an alias for <code>Get-Content</code>) or <code>typ...
2023/02/01
[ "https://unix.stackexchange.com/questions/733956", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558976/" ]
I would like to have this script's windows version ``` cat name-of-APK.apk | openssl dgst -binary -sha256 | openssl base64 | tr '+/' '-_' | tr -d '=' ``` How can I get that?
Seems like PowerShell has `cat` -command, but it's just an alias for `Get-Content`, as is `type` ([source](https://adamtheautomator.com/powershell-cat/)). So if you need to script Windows, I'd suggest learning PowerShell scripting. If you want to use \*NIX commands and tools in Windows, Cygwin is one option. You can a...
733,969
<p>Consider this usage of <a href="https://man.freebsd.org/cgi/man.cgi?query=column&amp;manpath=FreeBSD+13.1-RELEASE+and+Ports" rel="nofollow noreferrer">column(1)</a>:</p> <pre class="lang-bash prettyprint-override"><code>column -s, -t &lt;&lt;CSV a,b,c ,ee,ff CSV </code></pre> <p>The above snippet emits:</p> <pre><co...
[ { "answer_id": 733970, "author": "shadowtalker", "author_id": 73256, "author_profile": "https://unix.stackexchange.com/users/73256", "pm_score": 0, "selected": false, "text": "<p>If &quot;non-standard&quot; tools are OK, the <a href=\"https://github.com/BurntSushi/xsv\" rel=\"nofollow no...
2023/02/01
[ "https://unix.stackexchange.com/questions/733969", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/73256/" ]
Consider this usage of [column(1)](https://man.freebsd.org/cgi/man.cgi?query=column&manpath=FreeBSD+13.1-RELEASE+and+Ports): ```bash column -s, -t <<CSV a,b,c ,ee,ff CSV ``` The above snippet emits: ``` a b c ee ff ``` But I was expecting to see something like this: ``` a b c ee ff ``` `column` s...
The `column` utility removes empty columns from the start and end of each line. This gives rise to the misaligned columns that you observe. There are no options for the utility to disable this behaviour. Would you want to convert a general CSV document to another format, such as TSV, a safer way would be to use a CSV-...
733,971
<p>I have problem new USB LTE modem <a href="https://lowcostmobile.fr/products/brovi-e3372-325-blanc-cle-4g-usb-modem-huawei" rel="nofollow noreferrer">Brovi E3372-325</a></p> <p>I can't get it to work on linux. When connected to a USB port, the modem identifies itself as:</p> <pre><code># dmesg ... [ 6731.401923] usb ...
[ { "answer_id": 734246, "author": "PekkaH", "author_id": 559164, "author_profile": "https://unix.stackexchange.com/users/559164", "pm_score": 1, "selected": false, "text": "<p>Same gizmo, same setup, same problem here.</p>\n<p>However, today I played a bit more with that and I got that ac...
2023/02/01
[ "https://unix.stackexchange.com/questions/733971", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/90697/" ]
I have problem new USB LTE modem [Brovi E3372-325](https://lowcostmobile.fr/products/brovi-e3372-325-blanc-cle-4g-usb-modem-huawei) I can't get it to work on linux. When connected to a USB port, the modem identifies itself as: ``` # dmesg ... [ 6731.401923] usb 1-3.4.4: new high-speed USB device number 22 using xhci_...
I found a solution that works: <https://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=3043&p=20026#p20054> `/etc/udev/rules.d/40-huawei.rules`: ``` # This is part of USB_ModeSwitch version 1.x.x # ACTION!="add", GOTO="modeswitch_rules_end" SUBSYSTEM!="usb", GOTO="modeswitch_rules_end" # All known install...
733,981
<p>Before you hit me with the obvious, I know, the backup option makes a backup of a file.</p> <p>But the thing is, the <code>cp</code> command in general backs up a file. One could argue a copy of a file is a backup.</p> <p>So more precisely, my question is this: what does the <code>-b</code> option do that the <code>...
[ { "answer_id": 733985, "author": "Marcus Müller", "author_id": 106650, "author_profile": "https://unix.stackexchange.com/users/106650", "pm_score": 0, "selected": false, "text": "<p>From the same (GNU coreutils) cp manpage:</p>\n<pre><code> --backup[=CONTROL]\n make a ...
2023/02/01
[ "https://unix.stackexchange.com/questions/733981", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558996/" ]
Before you hit me with the obvious, I know, the backup option makes a backup of a file. But the thing is, the `cp` command in general backs up a file. One could argue a copy of a file is a backup. So more precisely, my question is this: what does the `-b` option do that the `cp` command doesn't do already? The cp(1)...
It makes a backup copy of each destination file that already exists. The ones that would otherwise get overwritten and lost. ``` $ mkdir foo; cd foo $ echo hello > hello.txt $ echo world > world.txt $ cp -b hello.txt world.txt $ ls hello.txt world.txt~ world.txt $ cat world.txt hello $ cat world.txt~ world ``` Tha...
733,997
<p>I have a working DNSSEC name server. It runs on the BIND 9.18 on recent Fedora. I have two keys (KSK, ZSK), my parent (DNS-wise) got a valid DS record and everything is fine. Really. The DNSSEC analyzers are happy with the setup too.</p> <p>But then came this log message:</p> <blockquote> <p>'auto-dnssec' option is ...
[ { "answer_id": 734432, "author": "le luxe fou", "author_id": 137003, "author_profile": "https://unix.stackexchange.com/users/137003", "pm_score": 1, "selected": false, "text": "<p>I had the same problem:</p>\n<pre><code>zone_rekey:dns_dnssec_keymgr failed: error occurred writing key to d...
2023/02/01
[ "https://unix.stackexchange.com/questions/733997", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/215626/" ]
I have a working DNSSEC name server. It runs on the BIND 9.18 on recent Fedora. I have two keys (KSK, ZSK), my parent (DNS-wise) got a valid DS record and everything is fine. Really. The DNSSEC analyzers are happy with the setup too. But then came this log message: > > 'auto-dnssec' option is deprecated and will be ...
I had the same problem: ``` zone_rekey:dns_dnssec_keymgr failed: error occurred writing key to disk ``` It seems to be only a permission problem. I changed the permission of my `/etc/bind/keys` directory to `rwxrwxr--` (774) and all the files therein to `rw-rw-r--` (664). * `keys` directory owner is root * `keys` ...
733,999
<p>I am trying to understand why <code>wc</code> and <code>stat</code> report different things for <code>/proc/[pid]/cmdline</code>.</p> <p><code>wc</code> says my shell's <code>cmdline</code> file is 6 bytes in size:</p> <pre><code>$ wc --bytes /proc/$$/cmdline 6 /proc/10425/cmdline </code></pre> <p><code>stat</code> ...
[ { "answer_id": 734002, "author": "ilkkachu", "author_id": 170373, "author_profile": "https://unix.stackexchange.com/users/170373", "pm_score": 5, "selected": true, "text": "<p>The files under <code>/proc</code> are not <strike>regular</strike> your usual files, but virtual things created...
2023/02/01
[ "https://unix.stackexchange.com/questions/733999", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/392334/" ]
I am trying to understand why `wc` and `stat` report different things for `/proc/[pid]/cmdline`. `wc` says my shell's `cmdline` file is 6 bytes in size: ``` $ wc --bytes /proc/$$/cmdline 6 /proc/10425/cmdline ``` `stat` says the file is 0 bytes in size: ``` $ stat --format='%s' /proc/$$/cmdline 0 ``` `file` agre...
The files under `/proc` are not regular your usual files, but virtual things created on the fly by the kernel. For most (all?) of them, the system doesn't bother calculating a size beforehand, but a program reading it just gets whatever data there is to get. The difference between what your `wc` does and what `stat` a...
734,028
<p>There are lots of questions/answers explaining what characters one shouldn't use in Linux filenames etc.</p> <p>I am looking for a non-alpha/numeric character that I can put at the front of a filename to bump it to the top of an ls without requiring escape characters to handle it on the command line.</p> <p>In macOS...
[ { "answer_id": 734029, "author": "berndbausch", "author_id": 144217, "author_profile": "https://unix.stackexchange.com/users/144217", "pm_score": 2, "selected": false, "text": "<p>The sort order of <code>ls</code> depends on command line options and language setting. If your LANG variabl...
2023/02/02
[ "https://unix.stackexchange.com/questions/734028", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/77888/" ]
There are lots of questions/answers explaining what characters one shouldn't use in Linux filenames etc. I am looking for a non-alpha/numeric character that I can put at the front of a filename to bump it to the top of an ls without requiring escape characters to handle it on the command line. In macOS I use <Filenam...
Without knowing it, you've asked two very complicated questions... quoting and sorting. Sort order is determine by locale. What comes first is... not fixed. e.g. ``` $ touch Hello hello There there $ LANG=C ls -1 Hello There hello there $ LANG=en_US ls -1 hello Hello there There ``` The next is the quoting questio...
734,055
<p>I have a text file that looks like this -</p> <pre><code>1 29 12 1 22 17 1 20 43 1 48 30 1 3 0 1 21 25 1 18 9 1 14 1 1 44 45 1 52 26 1 NaN 27 1 13 46 1 5 37 1 34 23 1 39 40 </code></pre> <p>whose columns I want to store into different array variables. I have used the following command -</p> <pre><code>#!/bin/csh set...
[ { "answer_id": 734029, "author": "berndbausch", "author_id": 144217, "author_profile": "https://unix.stackexchange.com/users/144217", "pm_score": 2, "selected": false, "text": "<p>The sort order of <code>ls</code> depends on command line options and language setting. If your LANG variabl...
2023/02/02
[ "https://unix.stackexchange.com/questions/734055", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559088/" ]
I have a text file that looks like this - ``` 1 29 12 1 22 17 1 20 43 1 48 30 1 3 0 1 21 25 1 18 9 1 14 1 1 44 45 1 52 26 1 NaN 27 1 13 46 1 5 37 1 34 23 1 39 40 ``` whose columns I want to store into different array variables. I have used the following command - ``` #!/bin/csh set Logfile=$proj_path/data/individua...
Without knowing it, you've asked two very complicated questions... quoting and sorting. Sort order is determine by locale. What comes first is... not fixed. e.g. ``` $ touch Hello hello There there $ LANG=C ls -1 Hello There hello there $ LANG=en_US ls -1 hello Hello there There ``` The next is the quoting questio...
734,107
<p><strong>Hi I'm having a multiple tar files like 1.tar 2.tar 3.tar..etc and i wanted to extract them to corresponding folders i.e 1.tar to a folder named 1 and so on... my trial was like the following:</strong></p> <pre><code> for f in *; do tar -xvf &quot;$f.tar&quot; --xform='s|^|$f/|S'; done </code></pre> ...
[ { "answer_id": 734029, "author": "berndbausch", "author_id": 144217, "author_profile": "https://unix.stackexchange.com/users/144217", "pm_score": 2, "selected": false, "text": "<p>The sort order of <code>ls</code> depends on command line options and language setting. If your LANG variabl...
2023/02/02
[ "https://unix.stackexchange.com/questions/734107", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/524729/" ]
**Hi I'm having a multiple tar files like 1.tar 2.tar 3.tar..etc and i wanted to extract them to corresponding folders i.e 1.tar to a folder named 1 and so on... my trial was like the following:** ``` for f in *; do tar -xvf "$f.tar" --xform='s|^|$f/|S'; done ``` **which doesn't work as expected how can i a...
Without knowing it, you've asked two very complicated questions... quoting and sorting. Sort order is determine by locale. What comes first is... not fixed. e.g. ``` $ touch Hello hello There there $ LANG=C ls -1 Hello There hello there $ LANG=en_US ls -1 hello Hello there There ``` The next is the quoting questio...
734,116
<p>I've been hardening SSH but, for some odd reason, <code>X11Forwarding</code> stays enabled. I tried adding <code>X11UseForwarding no</code>, but running <code>sudo sshd -T | grep x11</code> resulted in the error below, so I removed it:</p> <pre><code>/etc/ssh/sshd_config: line 134: Bad configuration option: X11UseFo...
[ { "answer_id": 734119, "author": "symcbean", "author_id": 9178, "author_profile": "https://unix.stackexchange.com/users/9178", "pm_score": 0, "selected": false, "text": "<p>As Giles says you seem confused about the configuration directive. Your output from 'sshd -T` says there is an erro...
2023/02/02
[ "https://unix.stackexchange.com/questions/734116", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/469646/" ]
I've been hardening SSH but, for some odd reason, `X11Forwarding` stays enabled. I tried adding `X11UseForwarding no`, but running `sudo sshd -T | grep x11` resulted in the error below, so I removed it: ``` /etc/ssh/sshd_config: line 134: Bad configuration option: X11UseForwarding /etc/ssh/sshd_config: terminating, 1 ...
It's true there is `X11Forwarding no` in the config file, but there's also `Include /etc/ssh/sshd_config.d/*.conf` before it. For each keyword (like `X11Forwarding`) the *first* obtained value is used (`man 5 sshd_config` states this explicitly). This means if `X11Forwarding yes` from some `.conf` file in `/etc/ssh/ssh...
734,150
<p>I have been away from scripting for years, so I was wondering if someone can help in the below.</p> <p>I am migrating from Google Photos to Amazon Photos (about 40k photos). Here is an example of what I downloaded from Google:</p> <pre><code>IMG-20180601-WA0004-modifié.jpg IMG-20180601-WA0004.jpg IMG-20180601-WA000...
[ { "answer_id": 734159, "author": "Vojtech Trefny", "author_id": 196468, "author_profile": "https://unix.stackexchange.com/users/196468", "pm_score": 4, "selected": true, "text": "<p>These are <a href=\"https://www.open-scap.org/\" rel=\"noreferrer\">OpenSCAP</a> profiles to ensure compli...
2023/02/03
[ "https://unix.stackexchange.com/questions/734150", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559200/" ]
I have been away from scripting for years, so I was wondering if someone can help in the below. I am migrating from Google Photos to Amazon Photos (about 40k photos). Here is an example of what I downloaded from Google: ``` IMG-20180601-WA0004-modifié.jpg IMG-20180601-WA0004.jpg IMG-20180601-WA0004.jpg.json IMG-2018...
These are [OpenSCAP](https://www.open-scap.org/) profiles to ensure compliance with various government security standards. These are mostly used in situations when you are required to adhere to some specific security policy. So you'd usually choose a security policy if you are working for a governmental organization or...
734,168
<p>Title kind of says it all. I'm really trying to understand if the location of /boot is hardcoded into grub or what?</p> <p>If bios looks at first 512 and finds grub...then grub must have it hard coded to look into /boot?</p> <p>Am I accurate on that?</p>
[ { "answer_id": 734169, "author": "Gerald Schneider", "author_id": 2823, "author_profile": "https://unix.stackexchange.com/users/2823", "pm_score": 1, "selected": false, "text": "<p>It is not hard coded into grub. If you take a look at a boot entry from a GRUB configuration file, like thi...
2023/01/30
[ "https://unix.stackexchange.com/questions/734168", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/280122/" ]
Title kind of says it all. I'm really trying to understand if the location of /boot is hardcoded into grub or what? If bios looks at first 512 and finds grub...then grub must have it hard coded to look into /boot? Am I accurate on that?
It is not hard coded into grub. If you take a look at a boot entry from a GRUB configuration file, like this: ``` title Red Hat Enterprise Linux (2.4.21-1.ent) root (hd0,0) kernel /vmlinuz-2.4.21-1 ro root=/dev/sda2 initrd /initrd-2.4.21-1.img ``` you'll see the line `root (hd0,0)`. This is t...
734,183
<p>I know that <code>|</code> is the logical &quot;OR&quot; operator <em>inside</em> a RegExp expression. But what is the equivalent &quot;AND&quot; operator (again, <em>inside</em> a RegExp)?</p> <p><strong>Note:</strong></p> <ul> <li>This is not about the multiple expressions' operator of &quot;AND&quot;, which is ju...
[ { "answer_id": 734185, "author": "terdon", "author_id": 22222, "author_profile": "https://unix.stackexchange.com/users/22222", "pm_score": 4, "selected": true, "text": "<p>There is no such operator in any of the regular expression flavors I am familiar with. If you want to match inputs t...
2023/02/03
[ "https://unix.stackexchange.com/questions/734183", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/263508/" ]
I know that `|` is the logical "OR" operator *inside* a RegExp expression. But what is the equivalent "AND" operator (again, *inside* a RegExp)? **Note:** * This is not about the multiple expressions' operator of "AND", which is just `&&`. * For example, something like `/A&B/` to match both `A` and `B`.
There is no such operator in any of the regular expression flavors I am familiar with. If you want to match inputs that have both `A` and `B` you can write `A.*B` or `B.*A`, both of which require them in that particular order; or combine both expressions to accept either order with `A.*B|B.*A`. Alternatively, do two s...
734,208
<p>Suppose I am already storing a path in a variable as:</p> <pre><code>tmp=/home/abc/xyz </code></pre> <p>So what I want now is to go one way backward and store it in a variable as</p> <pre><code>tmp2=/home/abc </code></pre> <p>Please let me know how to achieve that without any error</p>
[ { "answer_id": 734221, "author": "stribika", "author_id": 4477, "author_profile": "https://unix.stackexchange.com/users/4477", "pm_score": 2, "selected": false, "text": "<p>Sounds like a job for <code>dirname</code>. The files/directories don't have to exist, it just cuts off the last pa...
2023/02/03
[ "https://unix.stackexchange.com/questions/734208", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559255/" ]
Suppose I am already storing a path in a variable as: ``` tmp=/home/abc/xyz ``` So what I want now is to go one way backward and store it in a variable as ``` tmp2=/home/abc ``` Please let me know how to achieve that without any error
Sounds like a job for `dirname`. The files/directories don't have to exist, it just cuts off the last part, so you'll never get an error. For `/` it returns `/`. ``` tmp2="$(dirname -- "$tmp")" ```
734,251
<p>I'm trying to discover a way to alter the systemd initialization process to disable the parallelization of processes' to enable overclocking my cpu without crashing the system on startup.</p> <p>My system is explicitly a gaming system, with basic built in overclocking controls in the bios, and I research all the way...
[ { "answer_id": 734252, "author": "Simon Richter", "author_id": 4542, "author_profile": "https://unix.stackexchange.com/users/4542", "pm_score": 1, "selected": false, "text": "<p>If the machine is unstable running multiple tasks in parallel, then it will not be able to run modern games, w...
2023/02/03
[ "https://unix.stackexchange.com/questions/734251", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559300/" ]
I'm trying to discover a way to alter the systemd initialization process to disable the parallelization of processes' to enable overclocking my cpu without crashing the system on startup. My system is explicitly a gaming system, with basic built in overclocking controls in the bios, and I research all the ways to twea...
If the machine is unstable running multiple tasks in parallel, then it will not be able to run modern games, which also run multiple tasks in parallel. For example it is now common to split graphics processing between a tighter loop operating on geometry data (so you get position updates every frame) and a slower loop...
734,262
<p>This is ubuntu 20.04.</p> <p>I stopped and disabled systemd-networkd. Then enabled NetworkManager. But after reboot both services come up. Keeps happening like that. I want to manage my server using nmcli, but not sure how to get it to work (and stop networkd)</p> <pre><code> 349 systemctl stop systemd-networkd ...
[ { "answer_id": 734252, "author": "Simon Richter", "author_id": 4542, "author_profile": "https://unix.stackexchange.com/users/4542", "pm_score": 1, "selected": false, "text": "<p>If the machine is unstable running multiple tasks in parallel, then it will not be able to run modern games, w...
2023/02/03
[ "https://unix.stackexchange.com/questions/734262", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/189150/" ]
This is ubuntu 20.04. I stopped and disabled systemd-networkd. Then enabled NetworkManager. But after reboot both services come up. Keeps happening like that. I want to manage my server using nmcli, but not sure how to get it to work (and stop networkd) ``` 349 systemctl stop systemd-networkd 350 nmcli dev stat...
If the machine is unstable running multiple tasks in parallel, then it will not be able to run modern games, which also run multiple tasks in parallel. For example it is now common to split graphics processing between a tighter loop operating on geometry data (so you get position updates every frame) and a slower loop...
734,278
<p>I am on Linux, using bash.</p> <pre><code>$ A=\&quot;\&quot; $ grep $A nomatch &quot;&quot; &quot;&quot; &lt;- (returned by grep) $ grep &quot;&quot; imatcheverything imatcheverything &lt;- (returned by grep) </code></pre> <p>I would have expected <code>grep $A</code> to act like <c...
[ { "answer_id": 734283, "author": "user unknown", "author_id": 4485, "author_profile": "https://unix.stackexchange.com/users/4485", "pm_score": 0, "selected": false, "text": "<pre><code>$ A = \\&quot;\\&quot;\n$ grep $A\n</code></pre>\n<p>In Bash, assignment is without whitespace around t...
2023/02/04
[ "https://unix.stackexchange.com/questions/734278", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559328/" ]
I am on Linux, using bash. ``` $ A=\"\" $ grep $A nomatch "" "" <- (returned by grep) $ grep "" imatcheverything imatcheverything <- (returned by grep) ``` I would have expected `grep $A` to act like `grep ""`. Why does it literally match `""`? I expect this because the shell appear...
Bash doesn't evaluate quotes after expanding parameters. The expanded value is only processed for [word splitting](https://www.gnu.org/software/bash/manual/html_node/Word-Splitting.html) and [filename expansion](https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html) if variable isn't quoted but quo...
734,296
<p>I am using a bash script and have a string of comma separated values <code>string=&quot;string1,string2,string&quot;</code>. There would not be any embedded commas in each string, or spaces. Want to test whether the string elements occur in an array.</p> <p>What can I do to match string elements with elements of a...
[ { "answer_id": 734319, "author": "jesse_b", "author_id": 237982, "author_profile": "https://unix.stackexchange.com/users/237982", "pm_score": 0, "selected": false, "text": "<p>If I understand your question properly, ignoring the bits where you convert the csv to an array, the following c...
2023/02/04
[ "https://unix.stackexchange.com/questions/734296", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559079/" ]
I am using a bash script and have a string of comma separated values `string="string1,string2,string"`. There would not be any embedded commas in each string, or spaces. Want to test whether the string elements occur in an array. What can I do to match string elements with elements of an arbitrary array? ``` string="...
Maybe you can just do something like: ``` string=element1,element2,element3 element=element2 case ",$string," in (*,"$element",*) echo element is in string;; (*) echo it is not;; esac ``` (standard `sh` syntax). To work with arrays or split strings, bash is one the poorest choices of shells. With `zsh`, to spl...
734,300
<p>This is the output of the <code>[global]</code> section of the /etc/samba/smb.conf of a random Synology NAS:</p> <pre><code>~# cat /etc/samba/smb.conf [global] printcap name=cups winbind enum groups=yes include=/var/tmp/nginx/smb.netbios.aliases.conf min protocol=NT1 security=...
[ { "answer_id": 734326, "author": "Rowland Penny", "author_id": 542430, "author_profile": "https://unix.stackexchange.com/users/542430", "pm_score": 0, "selected": false, "text": "<p>This is very probably because synology takes the Samba source and adapts it to their needs, there a lots o...
2023/02/04
[ "https://unix.stackexchange.com/questions/734300", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/101920/" ]
This is the output of the `[global]` section of the /etc/samba/smb.conf of a random Synology NAS: ``` ~# cat /etc/samba/smb.conf [global] printcap name=cups winbind enum groups=yes include=/var/tmp/nginx/smb.netbios.aliases.conf min protocol=NT1 security=user local maste...
A default-value isn't some absolute value but relative. Meaning: what was compiled into the samba-binaries. Vendors can, at compile-time, define their own default values for some options.
734,342
<p>I am in Linux Mint with Mate desktop. Each time I open a file (text file, image file, libreOffice, mp3...) I receive the following error:</p> <p><a href="https://i.stack.imgur.com/iwGnc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iwGnc.png" alt="enter image description here" /></a></p> <p>The ...
[ { "answer_id": 734326, "author": "Rowland Penny", "author_id": 542430, "author_profile": "https://unix.stackexchange.com/users/542430", "pm_score": 0, "selected": false, "text": "<p>This is very probably because synology takes the Samba source and adapts it to their needs, there a lots o...
2023/02/04
[ "https://unix.stackexchange.com/questions/734342", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/129648/" ]
I am in Linux Mint with Mate desktop. Each time I open a file (text file, image file, libreOffice, mp3...) I receive the following error: [![enter image description here](https://i.stack.imgur.com/iwGnc.png)](https://i.stack.imgur.com/iwGnc.png) The problem does not occur if I open filebrowser windows. If I reload th...
A default-value isn't some absolute value but relative. Meaning: what was compiled into the samba-binaries. Vendors can, at compile-time, define their own default values for some options.
734,349
<p>When I plug my Lenovo ThinkPad T490 in to my LG 32UL950 via Thunderbolt 3, the following messages are repeated in <code>journalctl</code> 8 times/second:</p> <pre><code>Feb 04 09:12:46 &lt;hostname&gt; kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.RP09.PEGP.NVDN], AE_NOT_FOUND (20210730/psargs-3...
[ { "answer_id": 734326, "author": "Rowland Penny", "author_id": 542430, "author_profile": "https://unix.stackexchange.com/users/542430", "pm_score": 0, "selected": false, "text": "<p>This is very probably because synology takes the Samba source and adapts it to their needs, there a lots o...
2023/02/04
[ "https://unix.stackexchange.com/questions/734349", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/15939/" ]
When I plug my Lenovo ThinkPad T490 in to my LG 32UL950 via Thunderbolt 3, the following messages are repeated in `journalctl` 8 times/second: ``` Feb 04 09:12:46 <hostname> kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.RP09.PEGP.NVDN], AE_NOT_FOUND (20210730/psargs-330) Feb 04 09:12:46 <hostname>...
A default-value isn't some absolute value but relative. Meaning: what was compiled into the samba-binaries. Vendors can, at compile-time, define their own default values for some options.
734,396
<p>I updated <code>docker-ce</code> on my debian 10 inside a VM on XEN with pygrub.</p> <p>after this upgrade I upgraded to Debian 11, but the error stayed the same.</p> <p>I am on docker-ce version 5:23.0.0-1~debian.11~bullseye now and I get this error messages when trying to restart the dae...
[ { "answer_id": 734797, "author": "rubo77", "author_id": 20661, "author_profile": "https://unix.stackexchange.com/users/20661", "pm_score": 3, "selected": true, "text": "<p>The Storage-Driver <code>devicemapper</code> is deprecated and was disabled by the last update. You should set the s...
2023/02/05
[ "https://unix.stackexchange.com/questions/734396", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/20661/" ]
I updated `docker-ce` on my debian 10 inside a VM on XEN with pygrub. after this upgrade I upgraded to Debian 11, but the error stayed the same. I am on docker-ce version 5:23.0.0-1~debian.11~bullseye now and I get this error messages when trying to restart the daemon: ``` Starting Docker Application Container Engin...
The Storage-Driver `devicemapper` is deprecated and was disabled by the last update. You should set the storage driver to `overlay2`. Open the file `/etc/docker/daemon.json` (if it does not exist, create it) and add the following JSON string: ``` { "storage-driver": "overlay2" } ``` Then restart docker: ``` syst...
734,426
<p>I have a big file with multiple lines, I want to escape(remove) all lines that has one of those conditions:</p> <ol> <li>Lines start with <code>/*!</code> or <code>'/*!</code></li> <li>Lines start with <code>#</code>, then one or more (+) of spaces, digits, or numbers come.</li> </ol> <p>I used <code>egrep -v</code...
[ { "answer_id": 734437, "author": "HatLess", "author_id": 480066, "author_profile": "https://unix.stackexchange.com/users/480066", "pm_score": 3, "selected": true, "text": "<p>You can try this <code>grep</code></p>\n<pre><code>$ grep -Ev &quot;^'?/\\*!|^#[ [:alpha:][:digit:]]+&quot; input...
2023/02/05
[ "https://unix.stackexchange.com/questions/734426", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/323220/" ]
I have a big file with multiple lines, I want to escape(remove) all lines that has one of those conditions: 1. Lines start with `/*!` or `'/*!` 2. Lines start with `#`, then one or more (+) of spaces, digits, or numbers come. I used `egrep -v` as below, but all my attempts failed: ``` cat File.log | egrep -v '^(/*!)...
You can try this `grep` ``` $ grep -Ev "^'?/\*!|^#[ [:alpha:][:digit:]]+" input_file ```
734,442
<p>I have the following <code>bash</code> call and want to put the <code>awk</code> commands in an <code>awk</code> file. What I would like to do is put the specific functionality beginning from line <code>$0 ~ beg_ere {</code> and ending at line <code>display { sub(pn_ere, &quot;&quot;) ; print }</code> in an <code>a...
[ { "answer_id": 734446, "author": "Marwi", "author_id": 417034, "author_profile": "https://unix.stackexchange.com/users/417034", "pm_score": 1, "selected": false, "text": "<p>Create a new file with <code>.awk</code> extension, for example <code>script.awk</code>, and paste the awk express...
2023/02/05
[ "https://unix.stackexchange.com/questions/734442", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559079/" ]
I have the following `bash` call and want to put the `awk` commands in an `awk` file. What I would like to do is put the specific functionality beginning from line `$0 ~ beg_ere {` and ending at line `display { sub(pn_ere, "") ; print }` in an `awk` function . Then be able to call it from a `bash` function. ``` awk ...
~~I don't think it's possible to specify `awk -f` and `awk '{code...}'` simultaneously~~. In GNU awk (aka `gawk`) for reading multiple codes simultaneously you can use `-e` option, see `gawk --help` for more details. Also it'd be useful to read use `AWKPATH` (see `man gawk` to read about it). To avoid using GNU awk i...
734,449
<p>We need to download a 182 GB compressed file (uncompressed as a <a href="https://en.wikipedia.org/wiki/Tab-separated_values" rel="nofollow noreferrer">TSV</a>). However, we only need the first five columns of the file, which equates to approximately 1 GB.</p> <p>Is there some fancy shell magic that can be done to do...
[ { "answer_id": 734453, "author": "user10489", "author_id": 447908, "author_profile": "https://unix.stackexchange.com/users/447908", "pm_score": 3, "selected": false, "text": "<ul>\n<li>If the file wasn't compressed, it is possible in the http protocol to download ranges of bytes. Howeve...
2023/02/05
[ "https://unix.stackexchange.com/questions/734449", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/467640/" ]
We need to download a 182 GB compressed file (uncompressed as a [TSV](https://en.wikipedia.org/wiki/Tab-separated_values)). However, we only need the first five columns of the file, which equates to approximately 1 GB. Is there some fancy shell magic that can be done to download a subset of a file? Downloading the wh...
You can download the file, filter it, and then write the result to your local disk ``` curl https://storage.googleapis.com/gcp-public-data--gnomad/release/3.1.2/vcf/genomes/gnomad.genomes.v3.1.2.sites.chr1.vcf.bgz | bgzip -d | cut -f1-5 ``` This still requires you to download the full file but only the filte...
734,470
<p>My server lost power last night so was abruptly shut down. Bringing it back up this morning my xen dom0 can connect to network, but my domU cannot. Tried full reboots of Dom0 and DomU. Only DomU on hypervisor so not able to compare DomUs to determine if root cause is Dom0 or U. I haven't done any changes to my confi...
[ { "answer_id": 734996, "author": "k.Cyborg", "author_id": 260722, "author_profile": "https://unix.stackexchange.com/users/260722", "pm_score": 0, "selected": false, "text": "<p>It appears that your DomU instance is not able to connect to the internet. To diagnose the issue, we need to lo...
2023/02/06
[ "https://unix.stackexchange.com/questions/734470", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/55660/" ]
My server lost power last night so was abruptly shut down. Bringing it back up this morning my xen dom0 can connect to network, but my domU cannot. Tried full reboots of Dom0 and DomU. Only DomU on hypervisor so not able to compare DomUs to determine if root cause is Dom0 or U. I haven't done any changes to my configur...
I was experiencing the bug described here: [5.15.0-58.64 breaks xen bridge networking (pvh domU)](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2002889) tl;dr from that bug report is apparently this is a regresion related to a security fix. There's a fix currently being tested. The kernel version which has t...
734,512
<p><strong>Basically what I want</strong>: When I browse files/dires with <a href="https://github.com/gokcehan/lf" rel="nofollow noreferrer">lf</a>, I want to toggle &quot;something&quot; on the way. And only see PDF files, and make invisible any other file-types.</p> <p><strong>Rationale</strong>: Sometimes it's bit a...
[ { "answer_id": 734996, "author": "k.Cyborg", "author_id": 260722, "author_profile": "https://unix.stackexchange.com/users/260722", "pm_score": 0, "selected": false, "text": "<p>It appears that your DomU instance is not able to connect to the internet. To diagnose the issue, we need to lo...
2023/02/06
[ "https://unix.stackexchange.com/questions/734512", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/470206/" ]
**Basically what I want**: When I browse files/dires with [lf](https://github.com/gokcehan/lf), I want to toggle "something" on the way. And only see PDF files, and make invisible any other file-types. **Rationale**: Sometimes it's bit annoying to search certain file(s) that I forgot the filename but remember the file...
I was experiencing the bug described here: [5.15.0-58.64 breaks xen bridge networking (pvh domU)](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2002889) tl;dr from that bug report is apparently this is a regresion related to a security fix. There's a fix currently being tested. The kernel version which has t...
734,522
<p>I have a source code and I want to replace some specific lines with a new formatting and text.</p> <p>Following lines are in a file:</p> <pre><code>LogIfYouCan(!is_it_ready, &quot;Log Text, some variable: &quot; &lt;&lt; variable1 &lt;&lt; &quot; variable2: &quot; &lt;&lt; variable2); </code></pre> <p>I want to repl...
[ { "answer_id": 734996, "author": "k.Cyborg", "author_id": 260722, "author_profile": "https://unix.stackexchange.com/users/260722", "pm_score": 0, "selected": false, "text": "<p>It appears that your DomU instance is not able to connect to the internet. To diagnose the issue, we need to lo...
2023/02/06
[ "https://unix.stackexchange.com/questions/734522", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/188527/" ]
I have a source code and I want to replace some specific lines with a new formatting and text. Following lines are in a file: ``` LogIfYouCan(!is_it_ready, "Log Text, some variable: " << variable1 << " variable2: " << variable2); ``` I want to replace it with ``` if(!is_it_ready) { LogOutput("Log Text, some var...
I was experiencing the bug described here: [5.15.0-58.64 breaks xen bridge networking (pvh domU)](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2002889) tl;dr from that bug report is apparently this is a regresion related to a security fix. There's a fix currently being tested. The kernel version which has t...
734,531
<p>In a recent Lubuntu 22.04 install, when running <code>systemctl --user</code> with user 1000 I get:</p> <pre><code>❯ systemctl status --user Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=&lt;user&gt;@.host --user to connect to bus of other user) ❯ eval...
[ { "answer_id": 734536, "author": "Stewart", "author_id": 272848, "author_profile": "https://unix.stackexchange.com/users/272848", "pm_score": 1, "selected": false, "text": "<p>Borrowing from:</p>\n<p><a href=\"https://unix.stackexchange.com/questions/615917/failed-to-get-d-bus-connection...
2023/02/06
[ "https://unix.stackexchange.com/questions/734531", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/55882/" ]
In a recent Lubuntu 22.04 install, when running `systemctl --user` with user 1000 I get: ``` ❯ systemctl status --user Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user) ❯ eval $(dbus-launch --sh-syntax) ❯ ...
Borrowing from: [Failed to get D-Bus connection: Connection refused](https://unix.stackexchange.com/questions/615917/failed-to-get-d-bus-connection-connection-refused/615964#615964) You'll get the `Failed to connect to bus` when `$XDG_RUNTIME_DIR` is not equal to `$UID`. This can happen if you are logged in as one us...
734,543
<p>It's well known that redirecting standard output and error to the same file with <code>cmd &gt;out_err.txt 2&gt;out_err.txt</code> can lead to loss of data, as per the example below:</p> <pre><code>work:/tmp$ touch file.txt work:/tmp$ ls another_file.txt ls: cannot access 'another_file.txt': No such file or director...
[ { "answer_id": 734546, "author": "ilkkachu", "author_id": 170373, "author_profile": "https://unix.stackexchange.com/users/170373", "pm_score": 6, "selected": true, "text": "<p>Not sure it's that well known, but it happens because done like that, the two file handles are completely separa...
2023/02/06
[ "https://unix.stackexchange.com/questions/734543", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/499446/" ]
It's well known that redirecting standard output and error to the same file with `cmd >out_err.txt 2>out_err.txt` can lead to loss of data, as per the example below: ``` work:/tmp$ touch file.txt work:/tmp$ ls another_file.txt ls: cannot access 'another_file.txt': No such file or directory ``` The above is the setup...
Not sure it's that well known, but it happens because done like that, the two file handles are completely separate, and have independent read/write positions. Hence they can overwrite each other. (They correspond to two distinct *open file descriptions*, to use the technical term, which is sadly somewhat easy to confus...
734,562
<pre><code>Input: 1: aaa bbb 2: xxx yyy, zzz 3: ccc 4: 5: xxx yyy </code></pre> <p>Output:</p> <pre><code>1: aaa bbb 2: xxx yyy, zzz 3: ccc 4: 5: xxx yyy </code></pre> <p>Requirement: Merge all lines between pattern 1 <code>:$</code> and pattern 2 <code>:$</code> inclusive of pattern 1 but excluding pattern 2</p> <p>...
[ { "answer_id": 734582, "author": "don_crissti", "author_id": 22142, "author_profile": "https://unix.stackexchange.com/users/22142", "pm_score": 0, "selected": false, "text": "<p>You could use a &quot;resizable&quot; sliding window -<code>$!N</code> is usually used together with <code>P</...
2023/02/06
[ "https://unix.stackexchange.com/questions/734562", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559600/" ]
``` Input: 1: aaa bbb 2: xxx yyy, zzz 3: ccc 4: 5: xxx yyy ``` Output: ``` 1: aaa bbb 2: xxx yyy, zzz 3: ccc 4: 5: xxx yyy ``` Requirement: Merge all lines between pattern 1 `:$` and pattern 2 `:$` inclusive of pattern 1 but excluding pattern 2 Regex to match : `:$` Tried: ``` sed '/:$/{n;:l N;/:$/b; s/\n/ ...
With perl: ``` $ perl -0 -pe 's/\n+/ /g; s/ (\d+:)/\n$1/g; s/^\n+//; s/ +$/\n/' input.txt 1: aaa bbb 2: xxx yyy, zzz 3: ccc 4: 5: xxx yyy ``` (newlines added in script for readability. It runs as-is, or you can remove them for an inscrutable one-liner) * first it r...
734,578
<p>I recently had to change my router subnet from 192.168.1.1 to use 192.168.2.1, so it wouldn't conflict with an upstream router.</p> <p>I have a few servers connected to the router using static IPs that I also needed to update to use the new subnet. For example: the old IP was 192.168.1.2, so I thought I simply neede...
[ { "answer_id": 734580, "author": "hardillb", "author_id": 44275, "author_profile": "https://unix.stackexchange.com/users/44275", "pm_score": 0, "selected": false, "text": "<p>You have only changed the <code>address</code> and <code>gateways</code> entries in <code>/etc/network/interfaces...
2023/02/06
[ "https://unix.stackexchange.com/questions/734578", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/16477/" ]
I recently had to change my router subnet from 192.168.1.1 to use 192.168.2.1, so it wouldn't conflict with an upstream router. I have a few servers connected to the router using static IPs that I also needed to update to use the new subnet. For example: the old IP was 192.168.1.2, so I thought I simply needed to chan...
Your `/etc/resolv.conf` may have been fully autogenerated at one point of time, but it looks like the old values are "frozen in" because nothing is supplying any new DNS server addresses to the configuration mechanism. The fact that it now has `nameserver 127.0.0.53` as the first nameserver indicates your system proba...
734,592
<p>I have a Linux system, I want to change the names of the commands in the system through the kernal, for example, <strong>ls to show</strong> or <strong>cd to enter</strong>, how do I do that.</p> <p>I searched on the Internet on how to change the names of the commands, but I did not find an explanation for this matt...
[ { "answer_id": 734593, "author": "Stephen Kitt", "author_id": 86440, "author_profile": "https://unix.stackexchange.com/users/86440", "pm_score": 3, "selected": false, "text": "<p>The kernel doesn’t care what names commands have; commands’ names are decided by the file names of binaries w...
2023/02/06
[ "https://unix.stackexchange.com/questions/734592", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559627/" ]
I have a Linux system, I want to change the names of the commands in the system through the kernal, for example, **ls to show** or **cd to enter**, how do I do that. I searched on the Internet on how to change the names of the commands, but I did not find an explanation for this matter. Who has an excellent source to ...
The kernel doesn’t care what names commands have; commands’ names are decided by the file names of binaries which implement them, and for shell-internal commands such as `cd`, by the shell which provides them. In fact, your shell most likely provides mechanisms by which you can give new names to commands for your own ...
734,608
<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": 734612, "author": "telcoM", "author_id": 258991, "author_profile": "https://unix.stackexchange.com/users/258991", "pm_score": 3, "selected": false, "text": "<p>Backup data on <code>ext4</code> filesystem you wish to convert. Then unmount the filesystem, use <code>bcachefs ...
2023/02/07
[ "https://unix.stackexchange.com/questions/734608", "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...
Backup data on `ext4` filesystem you wish to convert. Then unmount the filesystem, use `bcachefs format` on the device containing the filesystem, edit `/etc/fstab` to reflect the fact that the filesystem type is now `bcachefs`, mount it, and restore the data. Since the bcachefs filesystem is so new, there seems to be ...
734,611
<p>The first bcachefs from Kent Overstreet supporting Kernel 6.1, are released on 2022-12-11 by Linus Torvalds. See following 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.archi...
[ { "answer_id": 735309, "author": "Alfred.37", "author_id": 449067, "author_profile": "https://unix.stackexchange.com/users/449067", "pm_score": 1, "selected": false, "text": "<p>Thats what the bcachefs Howto tell about:</p>\n<p>&quot;<strong>Build the bcachefs-kernel branch.</strong></p>...
2023/02/07
[ "https://unix.stackexchange.com/questions/734611", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/456207/" ]
The first bcachefs from Kent Overstreet supporting Kernel 6.1, are released on 2022-12-11 by Linus Torvalds. See following 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/...
Thats what the bcachefs Howto tell about: "**Build the bcachefs-kernel branch.** Firt run the following command to download a kernel branch with the bcachefs patches. ``` git clone https://evilpiepirate.org/git/bcachefs.git ``` This is slighly more complicated to explain. It's best you look up a tutorial for your ...
734,647
<p>I'd like to use Ansible to upload files from local workstations to a NAS server. Both are managed via Ansible.</p> <p>The only way I've gotten this to work so far is by mounting the NAS file share as a local directory via NFS, and delegating the copy tasks to the Ansible controller:</p> <pre><code> - name: Fetch fi...
[ { "answer_id": 734691, "author": "user103944", "author_id": 306203, "author_profile": "https://unix.stackexchange.com/users/306203", "pm_score": 0, "selected": false, "text": "<p>It might be possible to use the Ansible syncronize module which does rsync under the covers. That would poss...
2023/02/07
[ "https://unix.stackexchange.com/questions/734647", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/325943/" ]
I'd like to use Ansible to upload files from local workstations to a NAS server. Both are managed via Ansible. The only way I've gotten this to work so far is by mounting the NAS file share as a local directory via NFS, and delegating the copy tasks to the Ansible controller: ``` - name: Fetch files to NAS fetc...
There are more options. For example, use *rsync* or *scp* **rsync** Use the module [*synchronize*](https://docs.ansible.com/ansible/latest/collections/ansible/posix/synchronize_module.html#ansible-posix-synchronize-module-a-wrapper-around-rsync-to-make-common-tasks-in-your-playbooks-quick-and-easy) if you can: * Ins...
734,692
<p>I have input files (.txt oder .csv) In this files are different values (sometimes no value -&gt; &quot;&quot;). If ONE of this values is less than 0.001 (or empty -&gt; &quot;&quot;) the output should be &quot;UNCONFIRMED&quot;. If every line of the input file contains a value that's greater (or equal? doesn't matte...
[ { "answer_id": 734697, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p>With GNU <code>awk</code>:</p>\n<pre><code>gawk -F '&quot;' '\n BEGINFILE {found = 0}\n $2 &lt; 0.001 ...
2023/02/07
[ "https://unix.stackexchange.com/questions/734692", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/558210/" ]
I have input files (.txt oder .csv) In this files are different values (sometimes no value -> ""). If ONE of this values is less than 0.001 (or empty -> "") the output should be "UNCONFIRMED". If every line of the input file contains a value that's greater (or equal? doesn't matter) than 0.001 the output should be "CON...
A simple and readable format ``` file=input-1.csv status="CONFIRMED" minvalue=0.001 for i in $(cat $file) do if [ $(echo "${i//\"/} < $minvalue" | bc) -eq 1 ] then status="UNCONFIRMED" break fi done echo $status ``` This reads the file line by line, `${i//\"/}` removes the `"` from the v...
734,715
<p>I wonder is there any procedure to initiate concurrent rebuild of two or more separate arrays?</p> <p>while one is rebuilding, another stays in status:</p> <pre><code>md2 : active raid10 sdf5[4] sdd5[6] sdc5[5] sda5[7] 7804374912 blocks super 1.2 64K chunks 2 near-copies [4/3] [_UUU] [=====&gt;.............
[ { "answer_id": 734719, "author": "frostschutz", "author_id": 30851, "author_profile": "https://unix.stackexchange.com/users/30851", "pm_score": 2, "selected": true, "text": "<p>They should run in parallel, if truly separate (different sets of physical drives).</p>\n<p>However, when multi...
2023/02/07
[ "https://unix.stackexchange.com/questions/734715", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/100512/" ]
I wonder is there any procedure to initiate concurrent rebuild of two or more separate arrays? while one is rebuilding, another stays in status: ``` md2 : active raid10 sdf5[4] sdd5[6] sdc5[5] sda5[7] 7804374912 blocks super 1.2 64K chunks 2 near-copies [4/3] [_UUU] [=====>...............] recovery = 28....
They should run in parallel, if truly separate (different sets of physical drives). However, when multiple arrays share the same drives (different partitions of the same drive), the rebuilds are delayed, since running in parallel here would not speed things up, but slow them down instead. You can force resyncs to run...
734,729
<p>How to keep previous and current line if the previous line contains common text?</p> <p>I have a main file like this:</p> <pre><code>Hello_world Anna Frank Jeremy Hello_earth Jessie James </code></pre> <p>I would want 3 output files like this:</p> <p><strong>Output file 1</strong> (Only has the string with the previ...
[ { "answer_id": 734719, "author": "frostschutz", "author_id": 30851, "author_profile": "https://unix.stackexchange.com/users/30851", "pm_score": 2, "selected": true, "text": "<p>They should run in parallel, if truly separate (different sets of physical drives).</p>\n<p>However, when multi...
2023/02/08
[ "https://unix.stackexchange.com/questions/734729", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559801/" ]
How to keep previous and current line if the previous line contains common text? I have a main file like this: ``` Hello_world Anna Frank Jeremy Hello_earth Jessie James ``` I would want 3 output files like this: **Output file 1** (Only has the string with the previous hello) ``` Hello_world,Anna Hello_earth,Jess...
They should run in parallel, if truly separate (different sets of physical drives). However, when multiple arrays share the same drives (different partitions of the same drive), the rebuilds are delayed, since running in parallel here would not speed things up, but slow them down instead. You can force resyncs to run...
734,767
<p>Suppose I have two paths. Path1 which is static and path2 which is dynamic.</p> <p>Example:</p> <ul> <li>Path1= /tmp/folder/</li> <li>Path2= /tmp/folder/dir1/dir1_2</li> </ul> <p>Result:</p> <ul> <li>Diff= /dir/dir1_2</li> </ul> <p>I want to achieve as above example.</p>
[ { "answer_id": 734769, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p>With GNU <code>realpath</code>, you can do:</p>\n<pre><code>$ Path1=/tmp/folder\n$ Path2=/tmp/folder/dir...
2023/02/08
[ "https://unix.stackexchange.com/questions/734767", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559255/" ]
Suppose I have two paths. Path1 which is static and path2 which is dynamic. Example: * Path1= /tmp/folder/ * Path2= /tmp/folder/dir1/dir1\_2 Result: * Diff= /dir/dir1\_2 I want to achieve as above example.
With GNU `realpath`, you can do: ``` $ Path1=/tmp/folder $ Path2=/tmp/folder/dir1/dir1_2 $ realpath -m --relative-to="$Path1" -- "$Path2" dir1/dir1_2 ``` In POSIX/Korn-like shells (such as bash), store in a variable with: ``` Diff=$(realpath -m --relative-to="$Path1" -- "$Path2") ``` with the usual caveat that it...
734,777
<p>I want to write a glob pattern to match numbers separated by commas. What would the pattern be like?</p> <p>Here are some examples</p> <pre><code>5 5,8,13 </code></pre> <p>Have started with the following, but there some problem with it, as I do not get a match.</p> <pre><code>var=&quot;8,13,21&quot; echo &quot;var:...
[ { "answer_id": 734779, "author": "AdminBee", "author_id": 377345, "author_profile": "https://unix.stackexchange.com/users/377345", "pm_score": 1, "selected": false, "text": "<p>Note that the syntax you use looks like a mixture of globbing and regular expression syntax.</p>\n<p>If you wan...
2023/02/08
[ "https://unix.stackexchange.com/questions/734777", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559749/" ]
I want to write a glob pattern to match numbers separated by commas. What would the pattern be like? Here are some examples ``` 5 5,8,13 ``` Have started with the following, but there some problem with it, as I do not get a match. ``` var="8,13,21" echo "var: $var" if [[ "$var" == ^*([[:digit:]])+(,+[[:digit:]])$ ...
The bash manual says of the `[[ expression ]]` grammar: > > When the `==` and `!=` operators are used, the string to the right of the > operator is considered a pattern and matched according to the rules described below under Pattern Matching, as if the `extglob` shell option > were enabled¹. > > > The `extglob` ...
734,805
<p>I'm trying to script the deployment of a postfix server, and creating DNS records accordingly. SPF ; DMARC and DKIM. The first two are pretty simple, but i'm struggling to extract the record from the file opendkim generated.</p> <p>This is the file that opendkim gives me :</p> <pre class="lang-none prettyprint-overr...
[ { "answer_id": 734779, "author": "AdminBee", "author_id": 377345, "author_profile": "https://unix.stackexchange.com/users/377345", "pm_score": 1, "selected": false, "text": "<p>Note that the syntax you use looks like a mixture of globbing and regular expression syntax.</p>\n<p>If you wan...
2023/02/08
[ "https://unix.stackexchange.com/questions/734805", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559900/" ]
I'm trying to script the deployment of a postfix server, and creating DNS records accordingly. SPF ; DMARC and DKIM. The first two are pretty simple, but i'm struggling to extract the record from the file opendkim generated. This is the file that opendkim gives me : ```none mail._domainkey IN TXT ( "v=DKIM1; h=sha25...
The bash manual says of the `[[ expression ]]` grammar: > > When the `==` and `!=` operators are used, the string to the right of the > operator is considered a pattern and matched according to the rules described below under Pattern Matching, as if the `extglob` shell option > were enabled¹. > > > The `extglob` ...
734,826
<p>I am running Kali Linux. Whenever I run <code>apt-get upgrade</code> I get the following error. I tried <code>apt --fix-broken install</code>. Not working.</p> <pre><code>apt-get upgrade Reading package lists... Done Building...
[ { "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/734826", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/559941/" ]
I am running Kali Linux. Whenever I run `apt-get upgrade` I get the following error. I tried `apt --fix-broken install`. Not working. ``` apt-get upgrade Reading package lists... Done Building dependency tree... Done Reading st...
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...