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
730,472
<p>I am trying to use <code>find</code> command like this</p> <pre><code>cut -f 4 file.txt | awk 'NR&gt;1' | find ./ -name </code></pre> <p>After the awk command my input looks like this</p> <pre><code>foo.c foo.txt abc.txt </code></pre> <p>How can I feed the name of the file coming from previous command to find comma...
[ { "answer_id": 730474, "author": "tripleee", "author_id": 19240, "author_profile": "https://unix.stackexchange.com/users/19240", "pm_score": 0, "selected": false, "text": "<p>You have to separately add a bunch of options for each <code>-name</code>. Try this:</p>\n<pre><code>IFS='\n'\nse...
2023/01/04
[ "https://unix.stackexchange.com/questions/730472", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/63486/" ]
I am trying to use `find` command like this ``` cut -f 4 file.txt | awk 'NR>1' | find ./ -name ``` After the awk command my input looks like this ``` foo.c foo.txt abc.txt ``` How can I feed the name of the file coming from previous command to find command? So basically looking for `foo.c` and getting it's pa...
Here, it may be easier to get `find` to find every file and `awk` to select the ones with the names you want. For instance, assuming a `awk` that supports setting the record separator to NUL: ```bash find . -print0 | awk ' ! names_loaded {if (NR>1) names[$4]; next} $NF in names' FS='\t' file.txt names_loaded=1 FS=...
730,504
<p>I am trying to perform a sort by 3 different columns in the correct order on an AIX system.</p> <p>The below is an extract of a larger file that displays the longest running runtimes between the open brackets e.g. (0 hrs 0 mins 1.030 Secs). Keep in mind that the 1st column will not be in order as the output to the f...
[ { "answer_id": 730507, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 3, "selected": false, "text": "<p>Assuming the text between the timestamp and the duration always has 3 blank-separated words like in you...
2023/01/04
[ "https://unix.stackexchange.com/questions/730504", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/186444/" ]
I am trying to perform a sort by 3 different columns in the correct order on an AIX system. The below is an extract of a larger file that displays the longest running runtimes between the open brackets e.g. (0 hrs 0 mins 1.030 Secs). Keep in mind that the 1st column will not be in order as the output to the file runs ...
Assuming the text between the timestamp and the duration always has 3 blank-separated words like in your sample, you could do: ``` <your-file LC_ALL=C sort -nb -k6.2,6 -k8,8 -k10,10 ``` The default separator for `sort` is the transition between a non-blank and a blank, so sort keys without `-b` would include the lea...
730,518
<p>I'm on Arch Linux.</p> <p>I came across some new pager software called <a href="https://github.com/noborus/ov" rel="nofollow noreferrer">OV</a> and installed it. It has more features than <code>less</code> and I like it so I want to set it as my default pager.</p> <p>I added the following to my .bashrc:</p> <pre cla...
[ { "answer_id": 730520, "author": "tukan", "author_id": 258307, "author_profile": "https://unix.stackexchange.com/users/258307", "pm_score": 0, "selected": false, "text": "<p>To my best knowledge you can not change the <code>journalctl</code> pager by using env variables.</p>\n<p>The best...
2023/01/04
[ "https://unix.stackexchange.com/questions/730518", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/538525/" ]
I'm on Arch Linux. I came across some new pager software called [OV](https://github.com/noborus/ov) and installed it. It has more features than `less` and I like it so I want to set it as my default pager. I added the following to my .bashrc: ```bash export PAGER=/usr/bin/ov ``` Most programs are respecting this e...
I think you're seeing the effects of `SYSTEMD_PAGERSECURE` in action. From [`man journalctl`](https://man7.org/linux/man-pages/man1/journalctl.1.html#ENVIRONMENT): ``` $SYSTEMD_PAGER Pager to use when --no-pager is not given; overrides $PAGER. If neither $SYSTEMD_PAGER nor $PAGER are set, a set of well-known ...
730,539
<p>I need to list all files in a directory and their subdirectories, save them in an array and do some stuffs (basically for-loop the array and set attributes)</p> <p>I started with:</p> <pre><code>var=$(find ./ -type f) </code></pre> <p>My problem here is that file names contain spaces and other unfriendly characters ...
[ { "answer_id": 730541, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p><code>find</code> is always recursive¹, but your:</p>\n<blockquote>\n<pre><code>var=$(find ./ -type f)\n...
2023/01/04
[ "https://unix.stackexchange.com/questions/730539", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/523638/" ]
I need to list all files in a directory and their subdirectories, save them in an array and do some stuffs (basically for-loop the array and set attributes) I started with: ``` var=$(find ./ -type f) ``` My problem here is that file names contain spaces and other unfriendly characters (not my bad!) and this makes q...
I made a mistake, I am using softlink and I did not use *find* with *-L* flag. ``` original_list=() while IFS= read -r -d $'\0'; do original_list+=("$REPLY") done < <(find -L ./ -type f -print0) ``` This works!
730,561
<p>I'm using <code>watch -g</code> to monitor the output of a command and exit as soon as it changes. The problem is that all the UI elements of watch (including the output of the command that I'm monitoring) disappear as soon as it exits. I want to know what the output changed to before watch exited. Is this possible?...
[ { "answer_id": 730541, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p><code>find</code> is always recursive¹, but your:</p>\n<blockquote>\n<pre><code>var=$(find ./ -type f)\n...
2023/01/04
[ "https://unix.stackexchange.com/questions/730561", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555420/" ]
I'm using `watch -g` to monitor the output of a command and exit as soon as it changes. The problem is that all the UI elements of watch (including the output of the command that I'm monitoring) disappear as soon as it exits. I want to know what the output changed to before watch exited. Is this possible?
I made a mistake, I am using softlink and I did not use *find* with *-L* flag. ``` original_list=() while IFS= read -r -d $'\0'; do original_list+=("$REPLY") done < <(find -L ./ -type f -print0) ``` This works!
730,566
<p>I'd like to use ExactImage on Fedora 37. As far as I can see, it is neither in the main repository nor in rpmfusion, nor can I find any third-party package.</p> <p>I tried compiling from source but it appears to be an extremely difficult case. For one thing, the latest release does not compile as-is, but at least th...
[ { "answer_id": 730541, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p><code>find</code> is always recursive¹, but your:</p>\n<blockquote>\n<pre><code>var=$(find ./ -type f)\n...
2023/01/04
[ "https://unix.stackexchange.com/questions/730566", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/492896/" ]
I'd like to use ExactImage on Fedora 37. As far as I can see, it is neither in the main repository nor in rpmfusion, nor can I find any third-party package. I tried compiling from source but it appears to be an extremely difficult case. For one thing, the latest release does not compile as-is, but at least this was fi...
I made a mistake, I am using softlink and I did not use *find* with *-L* flag. ``` original_list=() while IFS= read -r -d $'\0'; do original_list+=("$REPLY") done < <(find -L ./ -type f -print0) ``` This works!
730,574
<p>I recently switched from Windows to Linux Mint and so far I'm absolutely loving it! However, I am wondering how can I choose the installation destination of various programs.</p> <p>For example, I have a SATA drive that is 1TB and my SSD that is 128GB. I want to install Steam and various games on my SATA but wheneve...
[ { "answer_id": 730576, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 1, "selected": false, "text": "<p>One way, on a <code>GNU/Linux</code> OS, using <code>mount --bind</code>:</p>\n<ul>\n<li>check which directo...
2023/01/05
[ "https://unix.stackexchange.com/questions/730574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555429/" ]
I recently switched from Windows to Linux Mint and so far I'm absolutely loving it! However, I am wondering how can I choose the installation destination of various programs. For example, I have a SATA drive that is 1TB and my SSD that is 128GB. I want to install Steam and various games on my SATA but whenever I try t...
As you have noticed, it is unusual to specify an installation directory on Unix-like operating systems, because everything goes into a big hierarchy and the package manager sorts things out. You can still have multiple partitions, but these would be "everything below a specific path" -- for example, typical setups have...
730,580
<p>Scripts typically start with a shebang such as <code>#!/usr/bin/env bash</code>, which specifies the shell to be used for execution. The execution behavior when the shebang is not present seems to be <a href="https://unix.stackexchange.com/a/373229/45354">up to the calling shell</a>. Either way, the script is run fr...
[ { "answer_id": 730582, "author": "Zaidhaan Hussain", "author_id": 553919, "author_profile": "https://unix.stackexchange.com/users/553919", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://pubs.opengroup.org/onlinepubs/9699919799/\" rel=\"nofollow noreferrer\">POSIX (IEEE S...
2023/01/05
[ "https://unix.stackexchange.com/questions/730580", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/45354/" ]
Scripts typically start with a shebang such as `#!/usr/bin/env bash`, which specifies the shell to be used for execution. The execution behavior when the shebang is not present seems to be [up to the calling shell](https://unix.stackexchange.com/a/373229/45354). Either way, the script is run from a "new" shell which do...
```sh (. ./myscript.sh) ``` is the right way ([the standard form is `.`, not `source`](https://unix.stackexchange.com/a/459089/86440), and `.` with no directory specified searches on the `PATH`). Doing this using a shebang would require having a reliable way of finding the binary for the shell running the parent scr...
730,626
<p>I'm on Fedora 37. I deleted my grub.cfg file and when I re-booted my laptop, I booted into the grub boot prompt. I was able to repair my system and reboot. I regenerated the grub.cfg file and re-installed grub.</p> <p>However, reading into this process has left me confused, because in some websites the advice is to ...
[ { "answer_id": 730582, "author": "Zaidhaan Hussain", "author_id": 553919, "author_profile": "https://unix.stackexchange.com/users/553919", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://pubs.opengroup.org/onlinepubs/9699919799/\" rel=\"nofollow noreferrer\">POSIX (IEEE S...
2023/01/05
[ "https://unix.stackexchange.com/questions/730626", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555479/" ]
I'm on Fedora 37. I deleted my grub.cfg file and when I re-booted my laptop, I booted into the grub boot prompt. I was able to repair my system and reboot. I regenerated the grub.cfg file and re-installed grub. However, reading into this process has left me confused, because in some websites the advice is to regenerat...
```sh (. ./myscript.sh) ``` is the right way ([the standard form is `.`, not `source`](https://unix.stackexchange.com/a/459089/86440), and `.` with no directory specified searches on the `PATH`). Doing this using a shebang would require having a reliable way of finding the binary for the shell running the parent scr...
730,657
<p>I have Ubuntu 22.04 with Nvidia 515.86.01 (proprietary), along with the CUDA toolkit and cuDNN.</p> <pre><code>nvidia/515.86.01, 5.15.0-53-generic, x86_64 </code></pre> <p>After 3 weeks of holiday I am back and wanted to install a few tools (Evince for example). I was surprised to see that nothing regarding <code>ap...
[ { "answer_id": 730582, "author": "Zaidhaan Hussain", "author_id": 553919, "author_profile": "https://unix.stackexchange.com/users/553919", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://pubs.opengroup.org/onlinepubs/9699919799/\" rel=\"nofollow noreferrer\">POSIX (IEEE S...
2023/01/05
[ "https://unix.stackexchange.com/questions/730657", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/79008/" ]
I have Ubuntu 22.04 with Nvidia 515.86.01 (proprietary), along with the CUDA toolkit and cuDNN. ``` nvidia/515.86.01, 5.15.0-53-generic, x86_64 ``` After 3 weeks of holiday I am back and wanted to install a few tools (Evince for example). I was surprised to see that nothing regarding `apt-get` related to package ins...
```sh (. ./myscript.sh) ``` is the right way ([the standard form is `.`, not `source`](https://unix.stackexchange.com/a/459089/86440), and `.` with no directory specified searches on the `PATH`). Doing this using a shebang would require having a reliable way of finding the binary for the shell running the parent scr...
730,670
<p>How do I convert a JAR file to a .pkg.tar.xz(Installable arch archive used by pacman)? Is there any maven plugin or some tool to do it?</p>
[ { "answer_id": 730681, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 0, "selected": false, "text": "<p>.jar - Java ARchive - an archive format used by Java language</p>\n<p>.pkg.tar.xz - a package of some kind, ar...
2023/01/05
[ "https://unix.stackexchange.com/questions/730670", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/519959/" ]
How do I convert a JAR file to a .pkg.tar.xz(Installable arch archive used by pacman)? Is there any maven plugin or some tool to do it?
Jars don't know anything about pacman and its usage. Either your distro, arch-linux, knows how to handle jar files, or it doesn't. I know jars of 2 kinds: * Executable programs which are packed as a jar, which is essentially a zip archiv of mainly the .class-files, combined with a some manifest files, which specify, ...
730,672
<p>whenever I try to connect to connect to wlan0 it says it is down but whenever I try to put it up by using the command <code>ifconfig wlan0 up</code> then I try <code>ip address</code>but it still doesn't come up</p> <pre><code> ip address 1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN ...
[ { "answer_id": 730681, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 0, "selected": false, "text": "<p>.jar - Java ARchive - an archive format used by Java language</p>\n<p>.pkg.tar.xz - a package of some kind, ar...
2023/01/05
[ "https://unix.stackexchange.com/questions/730672", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555522/" ]
whenever I try to connect to connect to wlan0 it says it is down but whenever I try to put it up by using the command `ifconfig wlan0 up` then I try `ip address`but it still doesn't come up ``` ip address 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback...
Jars don't know anything about pacman and its usage. Either your distro, arch-linux, knows how to handle jar files, or it doesn't. I know jars of 2 kinds: * Executable programs which are packed as a jar, which is essentially a zip archiv of mainly the .class-files, combined with a some manifest files, which specify, ...
730,674
<p>I'm working on a simple method to force hard line breaks in a file at whitespaces under a margin/character limit, i.e. no line can exceed n characters and line breaks are in between words. I have this working in BBEdit:</p> <pre><code>Find: (.{1,26})(\h+\R?|\R) Replace: \1\n </code></pre> <p>But I can't make it work...
[ { "answer_id": 730681, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 0, "selected": false, "text": "<p>.jar - Java ARchive - an archive format used by Java language</p>\n<p>.pkg.tar.xz - a package of some kind, ar...
2023/01/05
[ "https://unix.stackexchange.com/questions/730674", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555525/" ]
I'm working on a simple method to force hard line breaks in a file at whitespaces under a margin/character limit, i.e. no line can exceed n characters and line breaks are in between words. I have this working in BBEdit: ``` Find: (.{1,26})(\h+\R?|\R) Replace: \1\n ``` But I can't make it work in sed (MacOS 12 zsh) ...
Jars don't know anything about pacman and its usage. Either your distro, arch-linux, knows how to handle jar files, or it doesn't. I know jars of 2 kinds: * Executable programs which are packed as a jar, which is essentially a zip archiv of mainly the .class-files, combined with a some manifest files, which specify, ...
730,675
<p>I want to grep everything after the &quot;system path&quot; up to before &quot;type =&quot;. grep &quot;system path&quot; prints everything after &quot;system path&quot;</p> <p>Only want to grep from the line - system path=&quot;file/aww/ld/lslmux</p> <pre><code>&lt;system path=&quot;file/aww/ld/lslmux&quot; type=&...
[ { "answer_id": 730676, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>With GNU <code>grep</code>:</p>\n<pre><code>$ grep -oP '&lt;system path=&quot;\\K[^&quot;]+' file\nfile/aww...
2023/01/05
[ "https://unix.stackexchange.com/questions/730675", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555524/" ]
I want to grep everything after the "system path" up to before "type =". grep "system path" prints everything after "system path" Only want to grep from the line - system path="file/aww/ld/lslmux ``` <system path="file/aww/ld/lslmux" type="FILE" reason="filelist" action="NEW" status="COMPLETED" <system path="file/aww...
With GNU `grep`: ``` $ grep -oP '<system path="\K[^"]+' file file/aww/ld/lslmux file/aww/ld/lslmux/systemfile.xml file/aww/ld/lslmux/systemfiletest.page ``` With `Perl`: ``` $ perl -nE 'say for /<system path="\K([^"]+)/g' file ``` ### The regular expression matches as follows: | Node | Explanation | | --- | ---...
730,722
<p>I am following the ideas from the stackexchange articles below</p> <ul> <li>here to select and delete an element <a href="https://unix.stackexchange.com/questions/700580/how-to-remove-a-specific-json-object-from-a-file">Delete Element</a></li> <li>here to append an element: <a href="https://stackoverflow.com/questio...
[ { "answer_id": 730810, "author": "Daniel Ferreira Castro", "author_id": 555581, "author_profile": "https://unix.stackexchange.com/users/555581", "pm_score": 0, "selected": false, "text": "<pre><code>#!/bin/bash\nfile=temp.json\nnow=&quot;$(date)&quot;\nprevious_year=$(date --date=&quot;$...
2023/01/06
[ "https://unix.stackexchange.com/questions/730722", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555581/" ]
I am following the ideas from the stackexchange articles below * here to select and delete an element [Delete Element](https://unix.stackexchange.com/questions/700580/how-to-remove-a-specific-json-object-from-a-file) * here to append an element: [Add New Element](https://stackoverflow.com/questions/42245288/add-new-el...
Assuming you have the correct values in the shell variables `label`, `last_year`, and `previous_year` and that you want to delete all entries in the `options` array with the `value` value `$previous_year`, and add a new entry with the `label` value `$label` and `value` value `$last_year`. ```bash jq --arg add_label "...
730,736
<p>I want to see how many lines exist in each file that has been found using the <code>find</code> command.</p> <p>I know I can use <code>wc -l</code> to find the lines number of a single file. But this does not work when piped from the output of <code>find</code>:</p> <pre><code>find -type f -name package.json | wc -l...
[ { "answer_id": 730738, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 3, "selected": false, "text": "<p><code>wc</code> takes the list of files whose bytes/chars/<code>w</code>ords/lines to <code>c</code>ount...
2023/01/06
[ "https://unix.stackexchange.com/questions/730736", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/168855/" ]
I want to see how many lines exist in each file that has been found using the `find` command. I know I can use `wc -l` to find the lines number of a single file. But this does not work when piped from the output of `find`: ``` find -type f -name package.json | wc -l ``` This returns the count of the found files. I ...
`wc` takes the list of files whose bytes/chars/`w`ords/lines to `c`ount as *arguments*. When called with no argument, it reports those bytes/chars/words/lines in its stdin. So if you're piping `find` to `wc -l`, you'll get the number of newline characters in the output of `find`, so that'll be the number of found file...
730,739
<p>I have one Disk for backup on my PC that I copy some files. I have a lot of Folders and Data on this disk but I get this error message only for one folder. Do I need another disk?</p> <p>I Run <code>sudo ntfsfix /dev/sdb1</code> but with no luck same error message.</p> <p>Should I delete the Downloads folder?</p> <...
[ { "answer_id": 730738, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 3, "selected": false, "text": "<p><code>wc</code> takes the list of files whose bytes/chars/<code>w</code>ords/lines to <code>c</code>ount...
2023/01/06
[ "https://unix.stackexchange.com/questions/730739", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/149626/" ]
I have one Disk for backup on my PC that I copy some files. I have a lot of Folders and Data on this disk but I get this error message only for one folder. Do I need another disk? I Run `sudo ntfsfix /dev/sdb1` but with no luck same error message. Should I delete the Downloads folder? I try to delete Downloads but n...
`wc` takes the list of files whose bytes/chars/`w`ords/lines to `c`ount as *arguments*. When called with no argument, it reports those bytes/chars/words/lines in its stdin. So if you're piping `find` to `wc -l`, you'll get the number of newline characters in the output of `find`, so that'll be the number of found file...
730,757
<p>When attempting to connect to the tryhackme provided IP address we get port 22: connection timed out even while our ssh server is active</p> <p>When I attempt to</p> <blockquote> <p>ssh -vvv tryhackme@10.10.72.152</p> </blockquote> <p>I get the below result while using verbosity 3 -vvv</p> <pre><code>OpenSSH_9.0p1 U...
[ { "answer_id": 730761, "author": "telcoM", "author_id": 258991, "author_profile": "https://unix.stackexchange.com/users/258991", "pm_score": 2, "selected": false, "text": "<p>Your <code>ubuntu-22</code> system is configured to start <code>sshd</code> only when needed, using systemd <em>s...
2023/01/06
[ "https://unix.stackexchange.com/questions/730757", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555633/" ]
When attempting to connect to the tryhackme provided IP address we get port 22: connection timed out even while our ssh server is active When I attempt to > > ssh -vvv tryhackme@10.10.72.152 > > > I get the below result while using verbosity 3 -vvv ``` OpenSSH_9.0p1 Ubuntu-1ubuntu7.1, OpenSSL 3.0.5 5 Jul 2022 d...
Your `ubuntu-22` system is configured to start `sshd` only when needed, using systemd *socket activation*. In other words, when no SSH connection attempts have yet been received, the `ssh.service` will not be started yet: there will be only `ssh.socket`, which is managed by PID #1/`init` (which is actually `systemd` in...
730,758
<p>I trying to create a list of strings with spaces in, that I want to choose between in a <code>select</code> - something like this:</p> <pre><code>sel=&quot;&quot; while read l do sel=$(printf &quot;%s '%s'&quot; &quot;$sel&quot; &quot;$l&quot;) done&lt; &lt;(cd /some/data/directory;du -sh *) select x in $sel ...
[ { "answer_id": 730813, "author": "terdon", "author_id": 22222, "author_profile": "https://unix.stackexchange.com/users/22222", "pm_score": 3, "selected": false, "text": "<p>You want to use an array of multiple strings there, not a single string that must be split correctly by the shell. ...
2023/01/06
[ "https://unix.stackexchange.com/questions/730758", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/364511/" ]
I trying to create a list of strings with spaces in, that I want to choose between in a `select` - something like this: ``` sel="" while read l do sel=$(printf "%s '%s'" "$sel" "$l") done< <(cd /some/data/directory;du -sh *) select x in $sel do break done ``` The string `sel` looks like expected: `"597G 202...
This is really over-thought. ```bash #!/usr/bin/env bash IFS=' ' select x in $(cd /some/data/directory && du -sh -- *); do break done unset IFS # or save/restore it explicitly ``` As an added bonus, the only bashism here is the `select`. Typescript: ``` $ ./cg 1) 0 0 2) 0 000000000000000000000000000000...
730,885
<p>I have 2 instances of <code>vlc</code> running. One is playing. One is paused (and mostly swapped out).</p> <pre><code>top - 14:25:01 up 23 days, 19:19, 69 users, load average: 2.36, 2.61, 4.19 Tasks: 905 total, 3 running, 894 sleeping, 2 stopped, 6 zombie %Cpu(s): 11.9 us, 6.5 sy, 0.1 ni, 81.0 id, 0.4 wa,...
[ { "answer_id": 730886, "author": "Andrew Henle", "author_id": 111943, "author_profile": "https://unix.stackexchange.com/users/111943", "pm_score": -1, "selected": false, "text": "<p>I just started a VLC instance on Ubuntu 20.04 without playing anything and ran <code>pmap PID</code> to se...
2023/01/07
[ "https://unix.stackexchange.com/questions/730885", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/2972/" ]
I have 2 instances of `vlc` running. One is playing. One is paused (and mostly swapped out). ``` top - 14:25:01 up 23 days, 19:19, 69 users, load average: 2.36, 2.61, 4.19 Tasks: 905 total, 3 running, 894 sleeping, 2 stopped, 6 zombie %Cpu(s): 11.9 us, 6.5 sy, 0.1 ni, 81.0 id, 0.4 wa, 0.0 hi, 0.0 si, 0.0 ...
This looks relatively reasonable – assume this: we do software decoding (i.e., we're not just sending preprocessed video data to GPU buffers for decoding in hardware), we're dealing with Full HD, and we're working with MPEG4-era codecs. Then, we need to keep a few frames readily rendered (i.e., broken down to still im...
730,893
<p>Let's say I'd like to remove the first two and last three characters from all elements of an array e.g.</p> <pre><code>results=( QK9H9UtADCgnG AlaLkCADjQ krsxseW8H1VrU 6nBG94ZbCWQ ) </code></pre> <p>I'd like to end up with</p> <pre><code>results=( 9H9UtADC aLkCA sxseW8H1 BG94Zb ) </code></pre> <p>other than looping ...
[ { "answer_id": 730898, "author": "dhm", "author_id": 548011, "author_profile": "https://unix.stackexchange.com/users/548011", "pm_score": -1, "selected": false, "text": "<p>Here is one method to trim your array elements:</p>\n<pre><code>trimmed_array=( $(printf '%s\\n' &quot;${results[@]...
2023/01/07
[ "https://unix.stackexchange.com/questions/730893", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/22142/" ]
Let's say I'd like to remove the first two and last three characters from all elements of an array e.g. ``` results=( QK9H9UtADCgnG AlaLkCADjQ krsxseW8H1VrU 6nBG94ZbCWQ ) ``` I'd like to end up with ``` results=( 9H9UtADC aLkCA sxseW8H1 BG94Zb ) ``` other than looping over the elements and using `${element:2:-3}`...
Note that `${string:offset:length}` from ksh93 is not the native zsh way, it's only been added recently for compatibility with ksh93 / bash. In zsh, you rather do `$string[first,last]` (which predates ksh93). But in any case, whether it's zsh's `$var[first,last]` or ksh93-style `${var:offset:length}`, those are opera...
730,906
<p>Output of <code>locate txt | head</code>:</p> <pre><code>/etc/brltty/brl-ba-all.txt /etc/brltty/brl-bd-all.txt /etc/brltty/brl-bl-18.txt /etc/brltty/brl-bl-40_m20_m40.txt /etc/brltty/brl-ec-all.txt /etc/brltty/brl-ec-spanish.txt /etc/brltty/brl-eu-all.txt /etc/brltty/brl-lb-all.txt /etc/brltty/brl-lt-all.txt /etc/br...
[ { "answer_id": 730907, "author": "polemon", "author_id": 1290, "author_profile": "https://unix.stackexchange.com/users/1290", "pm_score": 3, "selected": false, "text": "<p>When you use globbing like that (<code>&lt;command&gt; *.txt</code>) for instance, the expansion is done by your she...
2023/01/07
[ "https://unix.stackexchange.com/questions/730906", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/547763/" ]
Output of `locate txt | head`: ``` /etc/brltty/brl-ba-all.txt /etc/brltty/brl-bd-all.txt /etc/brltty/brl-bl-18.txt /etc/brltty/brl-bl-40_m20_m40.txt /etc/brltty/brl-ec-all.txt /etc/brltty/brl-ec-spanish.txt /etc/brltty/brl-eu-all.txt /etc/brltty/brl-lb-all.txt /etc/brltty/brl-lt-all.txt /etc/brltty/brl-mb-all.txt ```...
`locate txt` locates all files (of any type including regular, symlink, directory, socket...) whose path contains `txt`¹, so includes `/foo/xtxty/bar`, `/foo/bar.txt`, `/foo/txt.bar`, etc. `locate *.txt` is wrong because that `*` is left unquoted, so the `*.txt` would be expanded by the shell to all the filenames in t...
730,957
<p>I try to use a public key to connect to a remote server running centos7.</p> <p>I generated a key by</p> <pre><code>ssh-keygen </code></pre> <p>then copy the key to the server by</p> <pre><code>ssh-copy-id hoa@chip02.phy.ncu.edu.tw </code></pre> <p>the <code>authorized_keys</code> is created on the remote machine, b...
[ { "answer_id": 730924, "author": "Stephen Kitt", "author_id": 86440, "author_profile": "https://unix.stackexchange.com/users/86440", "pm_score": 7, "selected": true, "text": "<p><a href=\"https://www.kernel.org/doc/html/latest/filesystems/ext4/overview.html#blocks\" rel=\"noreferrer\">64...
2023/01/08
[ "https://unix.stackexchange.com/questions/730957", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555836/" ]
I try to use a public key to connect to a remote server running centos7. I generated a key by ``` ssh-keygen ``` then copy the key to the server by ``` ssh-copy-id hoa@chip02.phy.ncu.edu.tw ``` the `authorized_keys` is created on the remote machine, but the ssh login still requires the password. I try to login ...
[64-bit ext4 file systems can be up to 64ZiB in size with 4KiB blocks, and up to 1YiB in size with 64KiB blocks](https://www.kernel.org/doc/html/latest/filesystems/ext4/overview.html#blocks), no need for an ext5 to handle large volumes. 1 YiB, one yobibyte, is 10248 bytes. [There are practical limits around 1 PiB and ...
730,959
<p>I'm new to Debian and Linux in general and I have a curious problem I have no idea how to fix. I'm on Debian Testing (currently bookworm).</p> <p>During boot, my Debian always says that it fails to raise network interface and that I should check my networking service for more information. When I check the log with <...
[ { "answer_id": 731580, "author": "Ben", "author_id": 553322, "author_profile": "https://unix.stackexchange.com/users/553322", "pm_score": -1, "selected": false, "text": "<p>You have the same ip for your connections : address 192.168.1.39</p>\n<p>Could you please install net-tools ?</p>\n...
2023/01/08
[ "https://unix.stackexchange.com/questions/730959", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/555838/" ]
I'm new to Debian and Linux in general and I have a curious problem I have no idea how to fix. I'm on Debian Testing (currently bookworm). During boot, my Debian always says that it fails to raise network interface and that I should check my networking service for more information. When I check the log with `sudo jour...
I'm using a debian-like parrot os operating system. The other day after the update, my network disappeared, after some dancing with a tambourine, I realized that the RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver was blacklisted. I commented out the lines in file `/etc/modprobe.d/r8168-dkms.conf`: ...
730,963
<p>I have an ini file like for example</p> <pre><code>[Admin Prefixes] # Here you can add custom prefixes to specific players or flags that are shown when using $admin_prefix$. # Syntax: &quot;type&quot; &quot;info&quot; &quot;prefix&quot; &quot;[expiration date]&quot; #&quot;name&quot; &quot;OciXCrom&quot; &quot;[Tim...
[ { "answer_id": 731580, "author": "Ben", "author_id": 553322, "author_profile": "https://unix.stackexchange.com/users/553322", "pm_score": -1, "selected": false, "text": "<p>You have the same ip for your connections : address 192.168.1.39</p>\n<p>Could you please install net-tools ?</p>\n...
2023/01/08
[ "https://unix.stackexchange.com/questions/730963", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525521/" ]
I have an ini file like for example ``` [Admin Prefixes] # Here you can add custom prefixes to specific players or flags that are shown when using $admin_prefix$. # Syntax: "type" "info" "prefix" "[expiration date]" #"name" "OciXCrom" "[Timed Prefix]" "31.12.2030" #"name" "OciXCrom" "[Scripter]" #"steam" "STEAM_0:0:5...
I'm using a debian-like parrot os operating system. The other day after the update, my network disappeared, after some dancing with a tambourine, I realized that the RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver was blacklisted. I commented out the lines in file `/etc/modprobe.d/r8168-dkms.conf`: ...
730,968
<p>I know that an interrupt is a signal sent to a kernel asking for handling. In some cases we have a physical device like a keyboard with a driver that connects a process with an interrupt(key pressed). But what about timers or other things that don’t have a physical device. Maybe I have wrong thoughts about this all,...
[ { "answer_id": 731580, "author": "Ben", "author_id": 553322, "author_profile": "https://unix.stackexchange.com/users/553322", "pm_score": -1, "selected": false, "text": "<p>You have the same ip for your connections : address 192.168.1.39</p>\n<p>Could you please install net-tools ?</p>\n...
2023/01/08
[ "https://unix.stackexchange.com/questions/730968", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556020/" ]
I know that an interrupt is a signal sent to a kernel asking for handling. In some cases we have a physical device like a keyboard with a driver that connects a process with an interrupt(key pressed). But what about timers or other things that don’t have a physical device. Maybe I have wrong thoughts about this all, an...
I'm using a debian-like parrot os operating system. The other day after the update, my network disappeared, after some dancing with a tambourine, I realized that the RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver was blacklisted. I commented out the lines in file `/etc/modprobe.d/r8168-dkms.conf`: ...
730,975
<p>I have in an input file like as follows:</p> <pre><code>1 30 35 90 ... </code></pre> <p>What I would like to do is modify it so that it shows me the following:</p> <pre><code>sed -i '1s///g' file_to_modify sed -i '30s///g' file_to_modify </code></pre> <p>Do you know how I could do it in Linux?</p>
[ { "answer_id": 730987, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 0, "selected": false, "text": "<h2>What I would do</h2>\n<pre><code>sed -E &quot;s:[0-9]+:sed -i '&amp;s///g' file_to_modify:&quot; file\n</co...
2023/01/08
[ "https://unix.stackexchange.com/questions/730975", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/446882/" ]
I have in an input file like as follows: ``` 1 30 35 90 ... ``` What I would like to do is modify it so that it shows me the following: ``` sed -i '1s///g' file_to_modify sed -i '30s///g' file_to_modify ``` Do you know how I could do it in Linux?
Assuming you have a file of line numbers, `lines.list`, and you want to create a `sed` editing script that executes `s///g` on each of the listed lines: ```bash sed 's:$:s///g:' lines.list ``` Given a file with the four numbers shown in the question, this would generate the `sed` script ``` 1s///g 30s///g 35s///g 9...
731,015
<p>Recursive file renamer - very useful python script stops working after upgrade Python (Pyt2 to Pyt3). Can anyone find and fix the problem please? Thank you!</p> <p>Example, those files:</p> <pre> 'Linux příručka českého uživatele.pdf' 'LINUXTERO příkazy které se vždy hodí.pdf' 'Práce s archívy příkazové řádka.pdf' '...
[ { "answer_id": 730987, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 0, "selected": false, "text": "<h2>What I would do</h2>\n<pre><code>sed -E &quot;s:[0-9]+:sed -i '&amp;s///g' file_to_modify:&quot; file\n</co...
2023/01/08
[ "https://unix.stackexchange.com/questions/731015", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/454448/" ]
Recursive file renamer - very useful python script stops working after upgrade Python (Pyt2 to Pyt3). Can anyone find and fix the problem please? Thank you! Example, those files: ``` 'Linux příručka českého uživatele.pdf' 'LINUXTERO příkazy které se vždy hodí.pdf' 'Práce s archívy příkazové řádka.pdf' 'Rekurzivní gr...
Assuming you have a file of line numbers, `lines.list`, and you want to create a `sed` editing script that executes `s///g` on each of the listed lines: ```bash sed 's:$:s///g:' lines.list ``` Given a file with the four numbers shown in the question, this would generate the `sed` script ``` 1s///g 30s///g 35s///g 9...
731,017
<p>So I want to take the questions found in <a href="https://unix.stackexchange.com/questions/523302/sed-add-word-before-string-only-if-not-exists">sed + add word before string only if not exists</a> and <a href="https://unix.stackexchange.com/questions/714758/sed-replace-a-character-in-a-string-when-the-preceding-char...
[ { "answer_id": 731071, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": true, "text": "<p>I'd use <code>perl</code> for that:</p>\n<pre><code>perl -pe 's{start\\[.*?\\]end}{$&amp; =~ s{\\\\?_}{\\...
2023/01/08
[ "https://unix.stackexchange.com/questions/731017", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/11337/" ]
So I want to take the questions found in [sed + add word before string only if not exists](https://unix.stackexchange.com/questions/523302/sed-add-word-before-string-only-if-not-exists) and [sed -- replace a character in a string when the preceding character is not a certain character](https://unix.stackexchange.com/qu...
I'd use `perl` for that: ``` perl -pe 's{start\[.*?\]end}{$& =~ s{\\?_}{\\_}gr}ge' < your-file ``` Where we `s`ubstitute¹ all (`g`) the `start[...]end` sequences with the same (`$&` which contains what was matched by the regexp) where we've `s`ubstituded and `r`eturned all (`g`) the `_`s optionally (`?`) preceded by...
731,072
<p>I am facing a very confusing behaviour of <code>ls</code> that I cannot search for. It displays that there are contents in a directory, but only when I'm in the directory where these were created from.</p> <p>Let me show you:</p> <pre><code>ciprian Documents $ pwd /Users/ciprian/Documents ciprian Documents $ ls ../...
[ { "answer_id": 731079, "author": "telcoM", "author_id": 258991, "author_profile": "https://unix.stackexchange.com/users/258991", "pm_score": 6, "selected": true, "text": "<p>The difference is physical vs. logical treatment of <code>..</code>:</p>\n<p>You apparently have two separate <cod...
2023/01/09
[ "https://unix.stackexchange.com/questions/731072", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/68186/" ]
I am facing a very confusing behaviour of `ls` that I cannot search for. It displays that there are contents in a directory, but only when I'm in the directory where these were created from. Let me show you: ``` ciprian Documents $ pwd /Users/ciprian/Documents ciprian Documents $ ls ../Downloads/rss22/ 22rss-USB/ c...
The difference is physical vs. logical treatment of `..`: You apparently have two separate `Downloads` directories: * one is `/Users/ciprian/Downloads` * the other is `/Users/ciprian/Library/CloudStorage/OneDrive/Downloads` Some shells, including `bash` and all POSIX shells, have the option of treating `..` in the `...
731,119
<p>I'm creating a small script that will delete indexes on an Elasticsearch cluster to prevent it for fill up all the storage with logstash data.</p> <p>I have a list of records, and I would like to keep the latest n records (for example 7) and delete all the others.</p> <p>I can get the list of the indexes with curl:<...
[ { "answer_id": 731124, "author": "Brad", "author_id": 7326, "author_profile": "https://unix.stackexchange.com/users/7326", "pm_score": 1, "selected": false, "text": "<p>This should be pretty simple. Try this (untested!)</p>\n<pre><code>drakaris:~/ # curl -sL localhost:9200/_cat/indices/...
2023/01/09
[ "https://unix.stackexchange.com/questions/731119", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556024/" ]
I'm creating a small script that will delete indexes on an Elasticsearch cluster to prevent it for fill up all the storage with logstash data. I have a list of records, and I would like to keep the latest n records (for example 7) and delete all the others. I can get the list of the indexes with curl: ``` drakaris:~...
This should be pretty simple. Try this (untested!) ``` drakaris:~/ # curl -sL localhost:9200/_cat/indices/logstash-* | awk '{print $3;}' | sort | tail -n +8 logstash-2022.12.30 logstash-2022.12.31 logstash-2023.01.01 logstash-2023.01.02 ``` note that you might want to play with `head` or `tail` here, to get what you...
731,120
<p>(disclaimer: I am… a certified noob)</p> <p>I think I made a real mess while installing EndeavourOS (gonna call it EOS for short) and then trying to kind-of reinstall it… so I might need an advice of someone experienced. I’ll begin from the start (oh and yeah, I did post this on EOS forums, but... nobody seems to ha...
[ { "answer_id": 731124, "author": "Brad", "author_id": 7326, "author_profile": "https://unix.stackexchange.com/users/7326", "pm_score": 1, "selected": false, "text": "<p>This should be pretty simple. Try this (untested!)</p>\n<pre><code>drakaris:~/ # curl -sL localhost:9200/_cat/indices/...
2023/01/09
[ "https://unix.stackexchange.com/questions/731120", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556019/" ]
(disclaimer: I am… a certified noob) I think I made a real mess while installing EndeavourOS (gonna call it EOS for short) and then trying to kind-of reinstall it… so I might need an advice of someone experienced. I’ll begin from the start (oh and yeah, I did post this on EOS forums, but... nobody seems to have solved...
This should be pretty simple. Try this (untested!) ``` drakaris:~/ # curl -sL localhost:9200/_cat/indices/logstash-* | awk '{print $3;}' | sort | tail -n +8 logstash-2022.12.30 logstash-2022.12.31 logstash-2023.01.01 logstash-2023.01.02 ``` note that you might want to play with `head` or `tail` here, to get what you...
731,125
<p>I just learned about brace expansion and hoped I could make use of them to launch the same C++ program with different command line arguments.</p> <p>My code is run like this from the terminal:</p> <pre><code>mpirun -n 1 main.exe 1 10 0.1 1 5 </code></pre> <p>The numbers after main.exe are the input arguments of my p...
[ { "answer_id": 731126, "author": "terdon", "author_id": 22222, "author_profile": "https://unix.stackexchange.com/users/22222", "pm_score": 3, "selected": true, "text": "<p>No, that won't work. Brace expansions are expanded when you run the command. Only the brace expansion is affected, t...
2023/01/09
[ "https://unix.stackexchange.com/questions/731125", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556030/" ]
I just learned about brace expansion and hoped I could make use of them to launch the same C++ program with different command line arguments. My code is run like this from the terminal: ``` mpirun -n 1 main.exe 1 10 0.1 1 5 ``` The numbers after main.exe are the input arguments of my program. I would like to do so...
No, that won't work. Brace expansions are expanded when you run the command. Only the brace expansion is affected, they don't cause you to run multiple commands. In your case, this: ``` mpirun -n 1 main.exe 1 10 {0.1,0.2} 1 5 ``` Will simply become this: ``` mpirun -n 1 main.exe 1 10 0.1 0.2 1 5 ``` If you want t...
731,150
<p>I have a folder 'reg_standard' nested within 68 different folders that I want to remove. The path to this folder looks something like:</p> <pre><code>/Volumes/.../sub-???/run_?.feat/reg_standard </code></pre> <p>where <code>'?'</code> is a stand-in for all the different folders that start with 'sub' or 'run'. For ex...
[ { "answer_id": 731153, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 2, "selected": false, "text": "<p>In zsh,</p>\n<pre><code>rm -rf /Volumes/.../sub-&lt;0-999&gt;/run_&lt;0-9&gt;.feat/reg_standard(/oN)\n</...
2023/01/09
[ "https://unix.stackexchange.com/questions/731150", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556056/" ]
I have a folder 'reg\_standard' nested within 68 different folders that I want to remove. The path to this folder looks something like: ``` /Volumes/.../sub-???/run_?.feat/reg_standard ``` where `'?'` is a stand-in for all the different folders that start with 'sub' or 'run'. For example, I have sub-101, sub-102, su...
I would do this using the `find` utility. Run it once and carefully review that it lists *just* the files that you would like to run the delete command on: ``` find . -type d -name reg_standard ``` If this works as expected, you can re-run the `find` command with the `-exec` option: ``` find . -type d -name reg_st...
731,172
<p>I have an account</p> <pre><code>grafana:x:494:494:Grafana User:/tmp:/sbin/nologin </code></pre> <p>I want to use to run a container. If I do</p> <pre><code>jsmith$ sudo -u grafana -s TMPDIR=/bs XDG_DATA_HOME=/bs XDG_CONFIG_DIR=/bs podman run --network-config-dir=/bs -it alpine </code></pre> <p>I get: &quot;cannot c...
[ { "answer_id": 731226, "author": "Anuril", "author_id": 556000, "author_profile": "https://unix.stackexchange.com/users/556000", "pm_score": 1, "selected": false, "text": "<p>It looks to me like this could be achieved in two ways:</p>\n<p>The first way would be to change the account so i...
2023/01/09
[ "https://unix.stackexchange.com/questions/731172", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/506893/" ]
I have an account ``` grafana:x:494:494:Grafana User:/tmp:/sbin/nologin ``` I want to use to run a container. If I do ``` jsmith$ sudo -u grafana -s TMPDIR=/bs XDG_DATA_HOME=/bs XDG_CONFIG_DIR=/bs podman run --network-config-dir=/bs -it alpine ``` I get: "cannot chdir to /home/jsmith: Permission denied". I can ru...
It looks to me like this could be achieved in two ways: The first way would be to change the account so it is able to log in: ``` grafana:x:494:494:Grafana User:/tmp:/bin/bash ``` This could be a potential security risk, so if you do not want that, you could consider using a systemd Unit file to start this, instead...
731,205
<p>I have a new desktop computer with Intel i7-12700 32GB RAM.</p> <p>I am doing build code stuff, I use the <code>sensors</code> command to check CPU temperature, and I found most of the cores are @ 100C.</p> <p>Is that normal?</p> <p>Will CPU hardware itself control the frequency to fit the temperature?</p> <p><stron...
[ { "answer_id": 731207, "author": "Stephen Kitt", "author_id": 86440, "author_profile": "https://unix.stackexchange.com/users/86440", "pm_score": 5, "selected": true, "text": "<p>Whether it’s normal for your system depends on a number of factors; however 100°C is on the high end for a des...
2023/01/10
[ "https://unix.stackexchange.com/questions/731205", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/368823/" ]
I have a new desktop computer with Intel i7-12700 32GB RAM. I am doing build code stuff, I use the `sensors` command to check CPU temperature, and I found most of the cores are @ 100C. Is that normal? Will CPU hardware itself control the frequency to fit the temperature? **update** I checked dmesg and found many l...
Whether it’s normal for your system depends on a number of factors; however 100°C is on the high end for a desktop system and you should try to address that. Typically, that would involve improving the system’s cooling: the overall airflow in the case itself (assuming your CPU isn’t water-cooled), the CPU cooler and it...
731,261
<p>For an application, I need to open a new terminal window and later execute some commands in that.</p> <p>I tried the command</p> <pre><code>gnome-terminal </code></pre> <p>And it works properly, it open a new terminal, but when i want to send commands i cannot, it says that failed parsing arguments, so I'm not sure ...
[ { "answer_id": 731266, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": 2, "selected": false, "text": "<p>You can do something like this:</p>\n<pre><code>gnome-terminal -- bash -c &quot;ls; exec bash&quot;\n</code></...
2023/01/10
[ "https://unix.stackexchange.com/questions/731261", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556175/" ]
For an application, I need to open a new terminal window and later execute some commands in that. I tried the command ``` gnome-terminal ``` And it works properly, it open a new terminal, but when i want to send commands i cannot, it says that failed parsing arguments, so I'm not sure about how should i do it ``` ...
This requires a two step process. 1. you need to start `gnome-terminal` running a program that waits for commands to be "sent in" 2. you need to speak to said program to make it execute the things you want it to execute. The right syntax to start `gnome-terminal` with a command to execute is ``` gnome-terminal -- co...
731,287
<p>I am running dual boot with Windows 11 and Fedora 37 GNOME 43, on kernel version 6.0.7-301.fc37.x86_64</p> <p>Before I installed fedora, I was using Ubuntu 20 and I never had any freezing problems at all. Now that I installed Fedora, I am getting these random freezes where everything is frozen, the mouse isn't movin...
[ { "answer_id": 731324, "author": "Artem S. Tashkinov", "author_id": 260833, "author_profile": "https://unix.stackexchange.com/users/260833", "pm_score": 1, "selected": false, "text": "<p>Crashes are most likely caused by the nouveau open source NVIDIA driver.</p>\n<p>To solve the issue y...
2023/01/10
[ "https://unix.stackexchange.com/questions/731287", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556209/" ]
I am running dual boot with Windows 11 and Fedora 37 GNOME 43, on kernel version 6.0.7-301.fc37.x86\_64 Before I installed fedora, I was using Ubuntu 20 and I never had any freezing problems at all. Now that I installed Fedora, I am getting these random freezes where everything is frozen, the mouse isn't moving, I can...
Crashes are most likely caused by the nouveau open source NVIDIA driver. To solve the issue you need to install NVIDIA binary drivers: <https://rpmfusion.org/Howto/NVIDIA> Maybe Ubuntu installed it for you automatically, Fedora doesn't.
731,329
<p>I'm trying to use a hardware keyboard (the Arturia KeyStep Pro) as a MIDI controller via USB in my digital audio workstation (Bitwig) under Ubuntu 22.04. So far, it's not working, and I'm not certain it's sending MIDI data at all.</p> <p><code>lsusb</code> recognizes the device:</p> <pre><code>Bus 001 Device 004: ID...
[ { "answer_id": 731324, "author": "Artem S. Tashkinov", "author_id": 260833, "author_profile": "https://unix.stackexchange.com/users/260833", "pm_score": 1, "selected": false, "text": "<p>Crashes are most likely caused by the nouveau open source NVIDIA driver.</p>\n<p>To solve the issue y...
2023/01/11
[ "https://unix.stackexchange.com/questions/731329", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556259/" ]
I'm trying to use a hardware keyboard (the Arturia KeyStep Pro) as a MIDI controller via USB in my digital audio workstation (Bitwig) under Ubuntu 22.04. So far, it's not working, and I'm not certain it's sending MIDI data at all. `lsusb` recognizes the device: ``` Bus 001 Device 004: ID 1c75:0218 Arturia KeyStep Pro...
Crashes are most likely caused by the nouveau open source NVIDIA driver. To solve the issue you need to install NVIDIA binary drivers: <https://rpmfusion.org/Howto/NVIDIA> Maybe Ubuntu installed it for you automatically, Fedora doesn't.
731,334
<p>I want to know could I wc -l files are in subfolder.If only one file I can use code like below.</p> <pre><code>find ./calss{1..20}/ -name 'C1.student' | xargs wc -l </code></pre> <p>In fact, I have 20 folders , every folder contain C1.student to C50.student files.I want to use <code>wc</code> to count multiple files...
[ { "answer_id": 731324, "author": "Artem S. Tashkinov", "author_id": 260833, "author_profile": "https://unix.stackexchange.com/users/260833", "pm_score": 1, "selected": false, "text": "<p>Crashes are most likely caused by the nouveau open source NVIDIA driver.</p>\n<p>To solve the issue y...
2023/01/11
[ "https://unix.stackexchange.com/questions/731334", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556261/" ]
I want to know could I wc -l files are in subfolder.If only one file I can use code like below. ``` find ./calss{1..20}/ -name 'C1.student' | xargs wc -l ``` In fact, I have 20 folders , every folder contain C1.student to C50.student files.I want to use `wc` to count multiple files at different sub folders. I try t...
Crashes are most likely caused by the nouveau open source NVIDIA driver. To solve the issue you need to install NVIDIA binary drivers: <https://rpmfusion.org/Howto/NVIDIA> Maybe Ubuntu installed it for you automatically, Fedora doesn't.
731,342
<p>Need to add a white space or line break before the next line,if the next line starts with blank it has to ignore.</p> <p>My input file is like below</p> <pre><code>#qwert TRWQQA 01 40 /* this is the sample test */ /* STILL COMING UP....
[ { "answer_id": 731345, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Like this, using GNU <code>awk</code> :</p>\n<pre><code>$ awk 'NR &gt; 1 &amp;&amp; /^\\S/{print &quot;&quot...
2023/01/11
[ "https://unix.stackexchange.com/questions/731342", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/431343/" ]
Need to add a white space or line break before the next line,if the next line starts with blank it has to ignore. My input file is like below ``` #qwert TRWQQA 01 40 /* this is the sample test */ /* STILL COMING UP... AFTER UP ENQ GOES...
Using `awk` to add a line before each line that does not start with a blank (but avoid doing that for the first line): ```bash awk 'NR != 1 && /^[^[:blank:]]/ { print "" }; 1' file ``` The command uses two tests. If both tests are *true*, a blank line is inserted. * The `NR != 1` test is *true* if the current line ...
731,343
<p>With <code>$</code> as my bash prompt and <code>⏎</code> symbolizing me hitting the enter key in the following example, how could I construct a command/alias <code>foo</code> so that</p> <pre><code>$ foo bar⏎ </code></pre> <p>would enter/input/pre-fill/type &quot;bar&quot; (or any other string I pass to the command)...
[ { "answer_id": 731344, "author": "kubi", "author_id": 68163, "author_profile": "https://unix.stackexchange.com/users/68163", "pm_score": 2, "selected": true, "text": "<p>Here's a small and ugly solution, inspired <a href=\"https://unix.stackexchange.com/questions/391679/how-to-automatica...
2023/01/11
[ "https://unix.stackexchange.com/questions/731343", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/68163/" ]
With `$` as my bash prompt and `⏎` symbolizing me hitting the enter key in the following example, how could I construct a command/alias `foo` so that ``` $ foo bar⏎ ``` would enter/input/pre-fill/type "bar" (or any other string I pass to the command) to the command line, so that I can modify "bar" before hitting Ent...
Here's a small and ugly solution, inspired [by a perl solution to insert a string after each prompt](https://unix.stackexchange.com/questions/391679/how-to-automatically-insert-a-string-after-the-prompt), using TIOCSTI [adapted to python](https://stackoverflow.com/a/29615101/629238): A bash function, e.g. for `.bashrc...
731,448
<p>I am new to renaming and have many files and folders in pascal case that I would like to convert to lower case, separated by a hyphen. I would like to run the command on both files and folders, recursively.</p> <p>Eg.</p> <ul> <li><code>MyFile.txt</code> becomes <code>my-file.txt</code></li> <li><code>MyPhoto.jpg</c...
[ { "answer_id": 731344, "author": "kubi", "author_id": 68163, "author_profile": "https://unix.stackexchange.com/users/68163", "pm_score": 2, "selected": true, "text": "<p>Here's a small and ugly solution, inspired <a href=\"https://unix.stackexchange.com/questions/391679/how-to-automatica...
2023/01/12
[ "https://unix.stackexchange.com/questions/731448", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525938/" ]
I am new to renaming and have many files and folders in pascal case that I would like to convert to lower case, separated by a hyphen. I would like to run the command on both files and folders, recursively. Eg. * `MyFile.txt` becomes `my-file.txt` * `MyPhoto.jpg` becomes `my-photo.jpg` However: * `ABird.jpg` should...
Here's a small and ugly solution, inspired [by a perl solution to insert a string after each prompt](https://unix.stackexchange.com/questions/391679/how-to-automatically-insert-a-string-after-the-prompt), using TIOCSTI [adapted to python](https://stackoverflow.com/a/29615101/629238): A bash function, e.g. for `.bashrc...
731,475
<pre><code>ABC,1234.5333,5733.9374,5673.352,352,2.346374,-0.6686874 XYZ,5463.674,93773.683,5734.874,432,-5.683423,-10.38393 AES,7436874.5743,937.6843,8464.5634,564,6.35739,10.6834 PQR,784945.464,57484.8647,57484.453,5764,-10.67484,5.74764 </code></pre> <p>From the above csv file , I need to write shell script which wil...
[ { "answer_id": 731478, "author": "pLumo", "author_id": 236063, "author_profile": "https://unix.stackexchange.com/users/236063", "pm_score": 1, "selected": false, "text": "<p>Use a tool that can parse <code>csv</code> data and filter rows, e.g.<code>python</code> with <code>csv</code> mod...
2023/01/12
[ "https://unix.stackexchange.com/questions/731475", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/297054/" ]
``` ABC,1234.5333,5733.9374,5673.352,352,2.346374,-0.6686874 XYZ,5463.674,93773.683,5734.874,432,-5.683423,-10.38393 AES,7436874.5743,937.6843,8464.5634,564,6.35739,10.6834 PQR,784945.464,57484.8647,57484.453,5764,-10.67484,5.74764 ``` From the above csv file , I need to write shell script which will select all the r...
You can try with `awk`. Something like can do the work (using only internal functions): ``` awk -F\, '{if (sqrt($(NF-1)*$(NF-1))>=10 || sqrt($NF*$NF)>=10 ) { print $0}}' input_file ```
731,479
<p>I have a function which provides various information relevant to a file called <code>CODESFILE-00001.DAT</code>.</p> <p>Within the function the following command works fine and returns the line containing <code>00202200USER</code>:</p> <pre><code>strings CODESFILE-00001.DAT | grep 00202200USER </code></pre> <p>Howev...
[ { "answer_id": 731491, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": -1, "selected": false, "text": "<p>It is much simpler:</p>\n<pre><code>#!/bin/sh\nfilename=CODESFILE-00001.DAT\npattern=00202200USER\ngrep $patt...
2023/01/12
[ "https://unix.stackexchange.com/questions/731479", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556433/" ]
I have a function which provides various information relevant to a file called `CODESFILE-00001.DAT`. Within the function the following command works fine and returns the line containing `00202200USER`: ``` strings CODESFILE-00001.DAT | grep 00202200USER ``` However, I would like to use a variable instead of insert...
Save this in a directory on your `PATH` and `chmod +x` the file. ``` #! /bin/sh - : "${1?Syntax: $0 <file>}" strings -- "$1" | grep '00202200USER' ``` Perhaps create more elaborate error checking and/or an option to specify a different pattern to `grep` for; but in essence, this is all there is to it. The quotes ar...
731,497
<p>I keep hearing different things from different people, some people are telling me that the reason people don't like snaps is because the software that runs the server for <a href="https://snapcraft.io/" rel="nofollow noreferrer">https://snapcraft.io/</a> is closed source and proprietary.</p> <p>Other people are tell...
[ { "answer_id": 731491, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": -1, "selected": false, "text": "<p>It is much simpler:</p>\n<pre><code>#!/bin/sh\nfilename=CODESFILE-00001.DAT\npattern=00202200USER\ngrep $patt...
2023/01/12
[ "https://unix.stackexchange.com/questions/731497", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/477559/" ]
I keep hearing different things from different people, some people are telling me that the reason people don't like snaps is because the software that runs the server for <https://snapcraft.io/> is closed source and proprietary. Other people are telling that everything including the software for <https://snapcraft.io/...
Save this in a directory on your `PATH` and `chmod +x` the file. ``` #! /bin/sh - : "${1?Syntax: $0 <file>}" strings -- "$1" | grep '00202200USER' ``` Perhaps create more elaborate error checking and/or an option to specify a different pattern to `grep` for; but in essence, this is all there is to it. The quotes ar...
731,507
<p>I've followed <a href="https://www.twilio.com/docs/iot/supersim/getting-started-super-sim-raspberry-pi-waveshare-4g-hat#software-setup" rel="nofollow noreferrer">this guide</a> to get a 4G hat networked with my pi zero, and everything seems fine. I'm able to ping out once <code>pon</code> has started in the backgrou...
[ { "answer_id": 731491, "author": "White Owl", "author_id": 420446, "author_profile": "https://unix.stackexchange.com/users/420446", "pm_score": -1, "selected": false, "text": "<p>It is much simpler:</p>\n<pre><code>#!/bin/sh\nfilename=CODESFILE-00001.DAT\npattern=00202200USER\ngrep $patt...
2023/01/12
[ "https://unix.stackexchange.com/questions/731507", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556449/" ]
I've followed [this guide](https://www.twilio.com/docs/iot/supersim/getting-started-super-sim-raspberry-pi-waveshare-4g-hat#software-setup) to get a 4G hat networked with my pi zero, and everything seems fine. I'm able to ping out once `pon` has started in the background and a route has been added. What I want is for ...
Save this in a directory on your `PATH` and `chmod +x` the file. ``` #! /bin/sh - : "${1?Syntax: $0 <file>}" strings -- "$1" | grep '00202200USER' ``` Perhaps create more elaborate error checking and/or an option to specify a different pattern to `grep` for; but in essence, this is all there is to it. The quotes ar...
731,522
<p>We have school districts that SFTP us student info which we process and load into another app. The system we have been using is dated and under another dept's purview. I have set up a chrooted SFTP account for each school district on one of my RHEL servers. How can I set up an SFTP account that can access the files ...
[ { "answer_id": 731554, "author": "symcbean", "author_id": 9178, "author_profile": "https://unix.stackexchange.com/users/9178", "pm_score": 1, "selected": false, "text": "<p>You don't need to do anything unless you've configured the server to only allow logins from members of the stpusers...
2023/01/12
[ "https://unix.stackexchange.com/questions/731522", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/513424/" ]
We have school districts that SFTP us student info which we process and load into another app. The system we have been using is dated and under another dept's purview. I have set up a chrooted SFTP account for each school district on one of my RHEL servers. How can I set up an SFTP account that can access the files in ...
You don't need to do anything unless you've configured the server to only allow logins from members of the stpusers group From [the manual](https://www.man7.org/linux/man-pages/man5/sshd_config.5.html)... > > **Match** Introduces a conditional block. If all of the criteria on > the Match line are satisfied, the keywo...
731,549
<p>I have a .csv file which is 7+ GB and has 30M rows. When I load the file into a database table in SQL Server, it reports the position of a row with some format problem, probably due to some fields missing.</p> <p>I can see the row with the position (i.e. row number), by using less</p> <pre><code>less +24923786 -N h...
[ { "answer_id": 731552, "author": "spinkus", "author_id": 74575, "author_profile": "https://unix.stackexchange.com/users/74575", "pm_score": 2, "selected": false, "text": "<p>If you want to actually edit the singular line in an editor you could use <code>sed</code> like this to extract li...
2023/01/12
[ "https://unix.stackexchange.com/questions/731549", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/674/" ]
I have a .csv file which is 7+ GB and has 30M rows. When I load the file into a database table in SQL Server, it reports the position of a row with some format problem, probably due to some fields missing. I can see the row with the position (i.e. row number), by using less ``` less +24923786 -N huge.csv ``` I try ...
If you want to actually edit the singular line in an editor you could use `sed` like this to extract line, edit then splice back in (supposing a compatible version or sed is in git-bash - it should be): ``` sed '24923786,24923786p' -n huge.csv > line.txt edit line.txt sed '24923786,24923786{s/.*/cat line.txt/e;}' -i ...
731,597
<p>This is in continuation of my previous question, <a href="https://unix.stackexchange.com/questions/715885/unstable-nic-how-to-troubleshoot">Unstable NIC: how to troubleshoot?</a>. The NIC is:</p> <pre><code># networkctl -a status ... ● 4: ens6f0 ...
[ { "answer_id": 738448, "author": "Jesse Brandeburg", "author_id": 30625, "author_profile": "https://unix.stackexchange.com/users/30625", "pm_score": 1, "selected": false, "text": "<p>When there is an unstable link, especially on fiber, one very good indicator is if you're getting a local...
2023/01/13
[ "https://unix.stackexchange.com/questions/731597", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/364511/" ]
This is in continuation of my previous question, [Unstable NIC: how to troubleshoot?](https://unix.stackexchange.com/questions/715885/unstable-nic-how-to-troubleshoot). The NIC is: ``` # networkctl -a status ... ● 4: ens6f0 ...
I finally figured out the problem: dust in the optics. Somehow, someone (not mentioning names, but it was someone very close to me!) had managed to pull out the fibre cable and reinserting it without cleaning the optics - what an idiot. After a careful cleaning, everything works perfectly. We live and learn.
731,598
<p>I have the following directory names:</p> <pre><code>/aaa /bbb /ccc /ddd </code></pre> <p>And I want to run the following command passing in the directory names with just <em>ls</em>:</p> <pre><code>ls | composer show drupal/MY_DIRECTORY_NAME_HERE --available | ack versions </code></pre> <p>How can I create a one li...
[ { "answer_id": 731604, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 1, "selected": false, "text": "<p>What I would do:</p>\n<pre><code>printf '%s\\n' '/aaa' '/bbb' '/ccc' |\n xargs -I{} composer show drupal/...
2023/01/13
[ "https://unix.stackexchange.com/questions/731598", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/33183/" ]
I have the following directory names: ``` /aaa /bbb /ccc /ddd ``` And I want to run the following command passing in the directory names with just *ls*: ``` ls | composer show drupal/MY_DIRECTORY_NAME_HERE --available | ack versions ``` How can I create a one line command to pass in the directory name into this c...
Since you obviously want to apply the command to all of the existing sub-directories, the cleanest way to do so (avoids the issue of directory names with special characters) would be ```bash for dir in */ do composer show drupal/"$dir" --available | ack versions done ``` This will iterate over all non-hidden dire...
731,645
<p>I'm trying out <code>docker-compose</code> with Podman which according to <a href="https://www.redhat.com/sysadmin/podman-docker-compose" rel="nofollow noreferrer">this</a> is now supported. I run the instructions and can indeed hit the socket when running as root but when I try as user I get:</p> <blockquote> <p>pe...
[ { "answer_id": 731680, "author": "Mix tutor", "author_id": 472170, "author_profile": "https://unix.stackexchange.com/users/472170", "pm_score": 0, "selected": false, "text": "<p>Yes, it is possible to use Podman with Docker Compose with user privileges. The error message you are seeing i...
2023/01/13
[ "https://unix.stackexchange.com/questions/731645", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/240147/" ]
I'm trying out `docker-compose` with Podman which according to [this](https://www.redhat.com/sysadmin/podman-docker-compose) is now supported. I run the instructions and can indeed hit the socket when running as root but when I try as user I get: > > permission denied while trying to connect to the Docker daemon sock...
You have to set podman up to run as a user. 1. If you have already set podman up to run with `systemctl enable podman` you will need to reverse that with `systemctl disable --now podman podman.socket`. If you have previously installed `podman-docker` you will notice that the soft link from `/var/run/docker.sock` to `/...
731,650
<p>I have a Raspberry Pi 3 on which I use Visual Studio cross-platform building to build an application (.out) file. The (.out) file has permissions for everyone. When I run this (.out), it creates a folder on the Pi to save some text files with some output data. However, when I try to open the folder to access the dat...
[ { "answer_id": 731680, "author": "Mix tutor", "author_id": 472170, "author_profile": "https://unix.stackexchange.com/users/472170", "pm_score": 0, "selected": false, "text": "<p>Yes, it is possible to use Podman with Docker Compose with user privileges. The error message you are seeing i...
2023/01/13
[ "https://unix.stackexchange.com/questions/731650", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556622/" ]
I have a Raspberry Pi 3 on which I use Visual Studio cross-platform building to build an application (.out) file. The (.out) file has permissions for everyone. When I run this (.out), it creates a folder on the Pi to save some text files with some output data. However, when I try to open the folder to access the data, ...
You have to set podman up to run as a user. 1. If you have already set podman up to run with `systemctl enable podman` you will need to reverse that with `systemctl disable --now podman podman.socket`. If you have previously installed `podman-docker` you will notice that the soft link from `/var/run/docker.sock` to `/...
731,672
<p>In a report file generated from Quartus, there are multiple &quot;tables&quot; like the following:</p> <pre><code>+---------------------+ ; Section1 Title ; +---------------------+ Miscellaneous text +-----------------+ ; Table1 Header ; +--------+--------; ; Field1 ; Field2 ; ; Field3 ; Field4 ; +--------+-...
[ { "answer_id": 731676, "author": "Mix tutor", "author_id": 472170, "author_profile": "https://unix.stackexchange.com/users/472170", "pm_score": -1, "selected": false, "text": "<p>You can use a single sed command to print out the full table based on the &quot;Table Header&quot; match. The...
2023/01/13
[ "https://unix.stackexchange.com/questions/731672", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556647/" ]
In a report file generated from Quartus, there are multiple "tables" like the following: ``` +---------------------+ ; Section1 Title ; +---------------------+ Miscellaneous text +-----------------+ ; Table1 Header ; +--------+--------; ; Field1 ; Field2 ; ; Field3 ; Field4 ; +--------+--------+ Table notes +...
Perl's paragraph mode (`-00`) is good for this, it reads the input (stdin and/or file(s)) one paragraph at a time. A paragraph is a block of text extending until the next blank line - the paragraph boundary is one or more blank lines. For example: ``` $ perl -00 -ne 'print if /Table1 Header/' quartus.rpt +----------...
731,685
<p>I have a tab delimited file with 2500 columns and 3000 rows. I would like to extract a specific column based on the header. By the way, this is being done in a while loop so each time a different column name will be selected.</p> <p>Example file format:</p> <pre><code>a b c d e f g h xy ...
[ { "answer_id": 731688, "author": "Mix tutor", "author_id": 472170, "author_profile": "https://unix.stackexchange.com/users/472170", "pm_score": 1, "selected": true, "text": "<p>It is possible to extract a specific column from a tab delimited file using the 'cut' command. To do this, you ...
2023/01/13
[ "https://unix.stackexchange.com/questions/731685", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/359686/" ]
I have a tab delimited file with 2500 columns and 3000 rows. I would like to extract a specific column based on the header. By the way, this is being done in a while loop so each time a different column name will be selected. Example file format: ``` a b c d e f g h xy 1 2 f 21 ...
It is possible to extract a specific column from a tab delimited file using the 'cut' command. To do this, you need to identify the column number of the required column and then use the '-f' option with the cut command to specify the column number. For example, if you want to extract the 'g' column from your file, you ...
731,783
<p>Currently have a shell script called path.sh that reads</p> <pre><code>cat /etc/zsh/zshenv |\ sed &quot;s|bashscripts|bashscripts:$PWD|g&quot; |\ sudo tee &gt;&gt; /etc/zsh/zshenv &amp;&amp; zsh </code></pre> <p>my path has :/bashscripts at the end of it. The idea is to tack on $PWD to the end of $PATH. But curren...
[ { "answer_id": 731829, "author": "PonJar", "author_id": 429115, "author_profile": "https://unix.stackexchange.com/users/429115", "pm_score": 2, "selected": true, "text": "<p><code>brltty</code> is a braille display driver. If you don’t use one you can probably uninstall it or as a first ...
2023/01/14
[ "https://unix.stackexchange.com/questions/731783", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556369/" ]
Currently have a shell script called path.sh that reads ``` cat /etc/zsh/zshenv |\ sed "s|bashscripts|bashscripts:$PWD|g" |\ sudo tee >> /etc/zsh/zshenv && zsh ``` my path has :/bashscripts at the end of it. The idea is to tack on $PWD to the end of $PATH. But currently I cannot get it to work the way I intend it....
`brltty` is a braille display driver. If you don’t use one you can probably uninstall it or as a first step check if there is a service running that can be disabled
731,826
<p>I want to create a command that is called <code>Age</code> which calls this script:</p> <pre><code>From=$(stat / | grep &quot;Birth&quot; | sed 's/Birth: //g' | cut -b 2-11) echo $From Now=$(date) echo $Now </code></pre> <p>However, I'm stuck subtracting these two dates.</p> <p>How can I subtract them and ensure tha...
[ { "answer_id": 731830, "author": "nobody", "author_id": 130631, "author_profile": "https://unix.stackexchange.com/users/130631", "pm_score": 2, "selected": false, "text": "<p><strong>This answer is wrong!!! The difference should be calculated manually from the number of seconds. Displayi...
2023/01/15
[ "https://unix.stackexchange.com/questions/731826", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/168855/" ]
I want to create a command that is called `Age` which calls this script: ``` From=$(stat / | grep "Birth" | sed 's/Birth: //g' | cut -b 2-11) echo $From Now=$(date) echo $Now ``` However, I'm stuck subtracting these two dates. How can I subtract them and ensure that it does not mess with date times like `2022-05-07...
**This answer is wrong!!! The difference should be calculated manually from the number of seconds. Displaying with `date` command just displays month, day number of the day, which is so many seconds from `1970-01-01`.** --- I would do it like this: ``` #!/bin/bash d1=$(date -d "$(stat / | grep "Birth" | sed 's/Birt...
731,883
<p>For Fedora <strong>Server</strong> 36 was installed <code>MySQL</code> 8 Community through the <code>.rpm</code> from <a href="https://dev.mysql.com/downloads/" rel="nofollow noreferrer">MySQL Community Downloads</a>. Now according with the <a href="https://docs.fedoraproject.org/en-US/quick-docs/installing-mysql-ma...
[ { "answer_id": 731956, "author": "wiktor.wandachowicz", "author_id": 556875, "author_profile": "https://unix.stackexchange.com/users/556875", "pm_score": 0, "selected": false, "text": "<p>Maybe port should be specified in <code>[mysqld]</code> section - for server settings?\nSection <cod...
2023/01/15
[ "https://unix.stackexchange.com/questions/731883", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/383045/" ]
For Fedora **Server** 36 was installed `MySQL` 8 Community through the `.rpm` from [MySQL Community Downloads](https://dev.mysql.com/downloads/). Now according with the [Editing Conf. Files](https://docs.fedoraproject.org/en-US/quick-docs/installing-mysql-mariadb/#_editing_conf_files) section is indicated to use the `/...
The problem is related to SELinux [(Troubleshooting problems related to SELinux)](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/using_selinux/troubleshooting-problems-related-to-selinux_using-selinux) because as @Artem S. Tashkinov said, this allows mysql only to listen on port 3306. So ...
731,961
<p>The <a href="https://fishshell.com/docs/current/cmds/for.html" rel="nofollow noreferrer">fish documentation</a> gives the following way to run a <code>for</code> loop.</p> <pre><code>for i in 1 2 3 4 5; echo $i end </code></pre> <p>Let us say I want to run a command 1000 times, How can I do it?</p>
[ { "answer_id": 731962, "author": "Marcus Müller", "author_id": 106650, "author_profile": "https://unix.stackexchange.com/users/106650", "pm_score": 3, "selected": true, "text": "<p>Same documentation, <a href=\"https://fishshell.com/docs/current/language.html#loops-and-blocks\" rel=\"nof...
2023/01/16
[ "https://unix.stackexchange.com/questions/731961", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/544093/" ]
The [fish documentation](https://fishshell.com/docs/current/cmds/for.html) gives the following way to run a `for` loop. ``` for i in 1 2 3 4 5; echo $i end ``` Let us say I want to run a command 1000 times, How can I do it?
Same documentation, <https://fishshell.com/docs/current/language.html#loops-and-blocks> : ```bash for i in (seq 1 5) echo $i end ``` replace `seq 1 5` with the numbers you want to get, e.g., `seq 14 1000` to get the numbers from 14 to 1000; if you want to start at 1, it's OK to omit the starting point, i.e., wri...
731,969
<p>I am working on extracting certain data from OECD statistics. These are available in a CSV file and look as follows (excerpt):</p> <pre><code>&quot;COUNTRY&quot;,&quot;Country&quot;,&quot;DAGEGR&quot;,&quot;Age groups&quot;,&quot;DSEX&quot;,&quot;Gender&quot;,&quot;DSTATUS&quot;,&quot;Status of population&quot;,&quo...
[ { "answer_id": 731971, "author": "AdminBee", "author_id": 377345, "author_profile": "https://unix.stackexchange.com/users/377345", "pm_score": 3, "selected": true, "text": "<p>If the aim really is to simply return the number <code>44474631</code>, you can do all in one using <code>awk</c...
2023/01/16
[ "https://unix.stackexchange.com/questions/731969", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/152326/" ]
I am working on extracting certain data from OECD statistics. These are available in a CSV file and look as follows (excerpt): ``` "COUNTRY","Country","DAGEGR","Age groups","DSEX","Gender","DSTATUS","Status of population","YEAR","Year","Value","Flag Codes","Flags" "AUS","Australia","900000","All ages","90","Total male...
If the aim really is to simply return the number `44474631`, you can do all in one using `awk` on the original input file: ``` awk -F, '$1=="\"ESP\"" && $9=="\"2007\"" {print $11}' RPOP_16012023145346836.csv ``` This will set the field separator to `,` and print the content of column 11, but only if column 1 is equa...
731,970
<p>I was running a pipe command with one section being the following:</p> <pre><code>sort -t $'\t' -T . -k1,1g </code></pre> <p>When I was monitoring <code>htop</code> I saw this instead:</p> <p><a href="https://i.stack.imgur.com/tJSCS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tJSCS.png" alt="...
[ { "answer_id": 731976, "author": "Stephen Kitt", "author_id": 86440, "author_profile": "https://unix.stackexchange.com/users/86440", "pm_score": 5, "selected": true, "text": "<p>There’s nothing wrong with your command, <a href=\"https://github.com/htop-dev/htop/blob/29f0b3c5e1184421ee779...
2023/01/16
[ "https://unix.stackexchange.com/questions/731970", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/304576/" ]
I was running a pipe command with one section being the following: ``` sort -t $'\t' -T . -k1,1g ``` When I was monitoring `htop` I saw this instead: [![enter image description here](https://i.stack.imgur.com/tJSCS.png)](https://i.stack.imgur.com/tJSCS.png) What is the reason behind this? Does this mean my comman...
There’s nothing wrong with your command, [`htop` replaces control characters with question marks](https://github.com/htop-dev/htop/blob/29f0b3c5e1184421ee7796ab2e1841733c45f403/RichString.c#L143): ```c (((unsigned char)data_c[j]) >= 32 ? ((unsigned char)data_c[j]) : '?') ``` (characters with values less than 32 are ...
731,990
<p>I have a bunch of text that can look something like this:</p> <pre><code>K1 CM1 TN1 CT14 D01 K2 CM2 TN2 CT15 D02 K3 CM3 TN3 CT16 D03 K4 CM4 TN4 CT17 D04 K5 CM5 TN5 CT18 D05 K6 CM6 TN6 CT19 D06 K7 CM11 TN7 CT20...
[ { "answer_id": 731997, "author": "ilkkachu", "author_id": 170373, "author_profile": "https://unix.stackexchange.com/users/170373", "pm_score": 1, "selected": false, "text": "<p>Assuming the input contains lines with tab-separated fields, and you want first the first field from each line ...
2023/01/16
[ "https://unix.stackexchange.com/questions/731990", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/416384/" ]
I have a bunch of text that can look something like this: ``` K1 CM1 TN1 CT14 D01 K2 CM2 TN2 CT15 D02 K3 CM3 TN3 CT16 D03 K4 CM4 TN4 CT17 D04 K5 CM5 TN5 CT18 D05 K6 CM6 TN6 CT19 D06 K7 CM11 TN7 CT20 D07 K8 ...
Assuming the input contains lines with tab-separated fields, and you want first the first field from each line top to bottom, then the second field, etc., plus the quotes and commas, here are some cheap solutions. Ugly two-liner for max 9 columns (with sed for formatting): ``` for i in 1 2 3 4 5 6 7 8 9; do cut -f$i ...
732,002
<p>I want to upgrade my Centos version 7.8 to 7.9 or 8. But my system is not connected to the internet. And I can reach remotely with ssh and sftp to the this server. Is there a way to do this update remotely from cli? I will be glad if you help.</p>
[ { "answer_id": 732008, "author": "Timmetje", "author_id": 556943, "author_profile": "https://unix.stackexchange.com/users/556943", "pm_score": -1, "selected": false, "text": "<p>You will need to download the ISO image from the CentOS website, then burn the ISO image onto a CD or DVD. Onc...
2023/01/16
[ "https://unix.stackexchange.com/questions/732002", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556939/" ]
I want to upgrade my Centos version 7.8 to 7.9 or 8. But my system is not connected to the internet. And I can reach remotely with ssh and sftp to the this server. Is there a way to do this update remotely from cli? I will be glad if you help.
> > Is there a way to do this update remotely from cli? > > > i think so, what you would want to do is * <http://isoredirect.centos.org/centos/7/isos/x86_64/> * download `CentOS-7-x86_64-DVD-2009.iso` it is 4.4gb; this is version 7.9 * `scp` that iso to your centos\_7.8 server * `mount -o loop CentOS-7-x86_64-DVD...
732,012
<p>I've been playing around with bash a bit and was wondering if it is possible to make blinking text stop if I execute another command. E.g. <code>echo -e '\033[5mEXAMPLE\033[0m'</code> will output a blinking <code>EXAMPLE</code> text; however, I'd like to know if it's possible to make the text to stop blinking if a s...
[ { "answer_id": 732015, "author": "Stéphane Chazelas", "author_id": 22565, "author_profile": "https://unix.stackexchange.com/users/22565", "pm_score": 3, "selected": true, "text": "<p>Sending the <code>&lt;ESC&gt;[5m</code> sequence tells the terminal to set the blinking attributes of cha...
2023/01/16
[ "https://unix.stackexchange.com/questions/732012", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/469646/" ]
I've been playing around with bash a bit and was wondering if it is possible to make blinking text stop if I execute another command. E.g. `echo -e '\033[5mEXAMPLE\033[0m'` will output a blinking `EXAMPLE` text; however, I'd like to know if it's possible to make the text to stop blinking if a second command is executed...
Sending the `<ESC>[5m` sequence tells the terminal to set the blinking attributes of characters it will display from now on. On most terminals, `<ESC>[25m` turns that off in that characters that will be sent thereafter will have their *blink* attribute off. `<ESC>[0m`, same as `<ESC>[m` turns *all* character rendition...
732,047
<p>I am unable to interact with the virtual console after upgrading my Arch system today with <code>sudo pacman -Syu</code> to 6.1.6. I have had this system for 2+ years and it has always worked fine. It worked immediately after the upgrade, but when I rebooted keystrokes no longer were being processed by the virtual c...
[ { "answer_id": 734102, "author": "Uwe Burger", "author_id": 94848, "author_profile": "https://unix.stackexchange.com/users/94848", "pm_score": -1, "selected": false, "text": "<p>If you can ssh into the Box try strace -f -p PID the login process and see if the process gets data from the k...
2023/01/17
[ "https://unix.stackexchange.com/questions/732047", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/47542/" ]
I am unable to interact with the virtual console after upgrading my Arch system today with `sudo pacman -Syu` to 6.1.6. I have had this system for 2+ years and it has always worked fine. It worked immediately after the upgrade, but when I rebooted keystrokes no longer were being processed by the virtual console so I wa...
**Edit** thanks to @don\_crissti who noticed that the OP has already tried what I was suggesting in the comments section (I have missed that): > > "Note that the keyboard works normally in BIOS and if I boot the same > machine with an Arch live CD and chroot into 6.1.6 environment, the > keyboard works fine. > > > ...
732,049
<p>I have a sequence of DNA separated by some white space. I need to remove the white spaces and return the count of the sequence without the white space characters. Any help on how to do that? I am using a terminal with bash.</p> <p>For example, the sequence looks like this:</p> <pre><code>GTCGATTGCAAGGATCCGCATGGGATAA...
[ { "answer_id": 732050, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Using a Perl one liner:</p>\n<pre><code>perl -F'' -e '\n BEGIN{my %h}\n map { /\\S/ and $h{$_}++ } @F;...
2023/01/17
[ "https://unix.stackexchange.com/questions/732049", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556983/" ]
I have a sequence of DNA separated by some white space. I need to remove the white spaces and return the count of the sequence without the white space characters. Any help on how to do that? I am using a terminal with bash. For example, the sequence looks like this: ``` GTCGATTGCAAGGATCCGCATGGGATAAAGGAATCGCAGTTCGAACA...
Using `grep` `sort` `uniq`: ``` $ grep -oP '\w' file | sort | uniq -c ``` Or ``` $ grep -o '[A-Z]' file | sort | uniq -c ``` Or for only `G`: ``` $ grep -o 'G' file | uniq -c ``` or ``` $ grep -o 'G' file | wc -l ``` Output ------ ``` 101 A 68 C 74 G 98 T ```
732,073
<ul> <li>I am getting some linewise output from grep like ...</li> </ul> <pre><code>value1 value2 value3 </code></pre> <ul> <li>in order to filling a variable for a bash script I need to transform this into inline format like <code>('value1' 'value2' 'value3')</code> though.</li> </ul> <p>In reality there are more then...
[ { "answer_id": 732050, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 2, "selected": false, "text": "<p>Using a Perl one liner:</p>\n<pre><code>perl -F'' -e '\n BEGIN{my %h}\n map { /\\S/ and $h{$_}++ } @F;...
2023/01/17
[ "https://unix.stackexchange.com/questions/732073", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/188249/" ]
* I am getting some linewise output from grep like ... ``` value1 value2 value3 ``` * in order to filling a variable for a bash script I need to transform this into inline format like `('value1' 'value2' 'value3')` though. In reality there are more then 40 values, so I am looking for an automated workflow rather th...
Using `grep` `sort` `uniq`: ``` $ grep -oP '\w' file | sort | uniq -c ``` Or ``` $ grep -o '[A-Z]' file | sort | uniq -c ``` Or for only `G`: ``` $ grep -o 'G' file | uniq -c ``` or ``` $ grep -o 'G' file | wc -l ``` Output ------ ``` 101 A 68 C 74 G 98 T ```
732,085
<p>As a non-root user, I want to install <code>git</code> (version = 2.38.1-1) on a shared host CentOS 7 server because the original version of <code>git</code> on the host is too old. I tried to use the method in <a href="https://unix.stackexchange.com/a/61295/556700">this answer</a> to install <code>git</code> from t...
[ { "answer_id": 733170, "author": "AdminBee", "author_id": 377345, "author_profile": "https://unix.stackexchange.com/users/377345", "pm_score": 2, "selected": false, "text": "<p>As for the foreground problem:</p>\n<ol>\n<li>You can't install an RPM package without root privileges, even if...
2023/01/17
[ "https://unix.stackexchange.com/questions/732085", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556700/" ]
As a non-root user, I want to install `git` (version = 2.38.1-1) on a shared host CentOS 7 server because the original version of `git` on the host is too old. I tried to use the method in [this answer](https://unix.stackexchange.com/a/61295/556700) to install `git` from the file `git-2.38.1-1.ep7.x86_64.rpm`. 1. I us...
As for the foreground problem: 1. You can't install an RPM package without root privileges, even if you have downloaded the RPM file. 2. Even so, if you want to manually install two RPM packages, where one of them will provide a not yet fulfilled dependency of the other, you have to state *both* as arguments to `rpm` ...
732,093
<p>I have a lot of associative arrays and i want to use only 1 loop. select the array for loop by a given name</p> <p>I want to select/build a part of the arrayname with a variable and than loop with that name, but it doesn't work.</p> <p>Like in OUTPUT3 and OUTPUT4, but the syntax is wrong.</p> <p>For output 3 i recei...
[ { "answer_id": 732095, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 0, "selected": false, "text": "<p><code>bash</code> does not have multidimensional arrays. However, you can implement them with an associative arra...
2023/01/17
[ "https://unix.stackexchange.com/questions/732093", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/515538/" ]
I have a lot of associative arrays and i want to use only 1 loop. select the array for loop by a given name I want to select/build a part of the arrayname with a variable and than loop with that name, but it doesn't work. Like in OUTPUT3 and OUTPUT4, but the syntax is wrong. For output 3 i receive: "bash wrong subst...
Use a "nameref": `declare -n a=b` makes variable `a` an alias for variable `b`. ```bash # 3 OUTPUT - use a "nameref" selectkey="3" declare -n ary="a$selectkey" for i in "${!ary[@]}" do echo "$i : ${ary[$i]}" done ``` outputs ```none 3 : 3-3V 2 : 3-2V 1 : 3-1V ``` Associative arrays are inherently unordered. ...
732,105
<p>Indirect variable setting in bash can be done like <a href="https://unix.stackexchange.com/a/210424/557041">so</a>:</p> <pre><code>#!/bin/bash foo=bar ind=foo echo ${!ind} # prints `bar' </code></pre> <p>Trying to run the same as a (GNU) Makefile recipe</p> <pre><code># Makefile test: foo=bar ind=foo e...
[ { "answer_id": 732095, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 0, "selected": false, "text": "<p><code>bash</code> does not have multidimensional arrays. However, you can implement them with an associative arra...
2023/01/17
[ "https://unix.stackexchange.com/questions/732105", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557041/" ]
Indirect variable setting in bash can be done like [so](https://unix.stackexchange.com/a/210424/557041): ``` #!/bin/bash foo=bar ind=foo echo ${!ind} # prints `bar' ``` Trying to run the same as a (GNU) Makefile recipe ``` # Makefile test: foo=bar ind=foo echo $$\{!ind\} echo $${!ind} ``` both w...
Use a "nameref": `declare -n a=b` makes variable `a` an alias for variable `b`. ```bash # 3 OUTPUT - use a "nameref" selectkey="3" declare -n ary="a$selectkey" for i in "${!ary[@]}" do echo "$i : ${ary[$i]}" done ``` outputs ```none 3 : 3-3V 2 : 3-2V 1 : 3-1V ``` Associative arrays are inherently unordered. ...
732,129
<p>Newbie question, but hopefully someone can help.</p> <p>I'm writing a function in a bash script that has error checking built in. I'd like to return an error message contining the line number, e.g.</p> <p><code>Error, parameter not provided, please check line 57</code></p> <p>I've found the <code>caller</code> comma...
[ { "answer_id": 732162, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 3, "selected": true, "text": "<p>The <code>caller</code> instruction in <code>bash</code> returns two space separated values: the line number and f...
2023/01/17
[ "https://unix.stackexchange.com/questions/732129", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/556532/" ]
Newbie question, but hopefully someone can help. I'm writing a function in a bash script that has error checking built in. I'd like to return an error message contining the line number, e.g. `Error, parameter not provided, please check line 57` I've found the `caller` command, but this returns `57 filename.sh` I'v...
The `caller` instruction in `bash` returns two space separated values: the line number and file name of the caller. For example, ``` 57 filename.sh ``` All you need here is to pick out the first parameter, and `awk` can do that very easily: ``` caller | awk '{ print $1 }' ``` Result ``` 57 ```
732,207
<p>I have two I2C devices I want to connect to my Linux device. A temperature sensor, TMP117, worked fine by writing it to the <code>/sys/bus/i2c/devices/i2c-x/new_device</code>. In addition, I want to add an accelerometer, ADXL343. However, when using the same method as with the TMP117, I receive an error in <code>dme...
[ { "answer_id": 732162, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 3, "selected": true, "text": "<p>The <code>caller</code> instruction in <code>bash</code> returns two space separated values: the line number and f...
2023/01/18
[ "https://unix.stackexchange.com/questions/732207", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557142/" ]
I have two I2C devices I want to connect to my Linux device. A temperature sensor, TMP117, worked fine by writing it to the `/sys/bus/i2c/devices/i2c-x/new_device`. In addition, I want to add an accelerometer, ADXL343. However, when using the same method as with the TMP117, I receive an error in `dmesg` that the GPIO f...
The `caller` instruction in `bash` returns two space separated values: the line number and file name of the caller. For example, ``` 57 filename.sh ``` All you need here is to pick out the first parameter, and `awk` can do that very easily: ``` caller | awk '{ print $1 }' ``` Result ``` 57 ```
732,227
<p>from sar command on saX file we can get the disks utilization as the follwing</p> <pre><code>sar -d -f /var/log/sa/sa18 | grep Average Average: dev8-0 1.24 0.00 150.06 121.40 0.04 30.40 4.72 0.58 Average: dev253-0 0.32 0.00 3.75 11.83 0.01 17....
[ { "answer_id": 732232, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 2, "selected": false, "text": "<p>The documentation <code>man sar</code> tells you how to get name lookups for <code>sar -d</code>:</p>\n<blockquot...
2023/01/18
[ "https://unix.stackexchange.com/questions/732227", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/237298/" ]
from sar command on saX file we can get the disks utilization as the follwing ``` sar -d -f /var/log/sa/sa18 | grep Average Average: dev8-0 1.24 0.00 150.06 121.40 0.04 30.40 4.72 0.58 Average: dev253-0 0.32 0.00 3.75 11.83 0.01 17.95 3.48 ...
Try this: ```bash #! /bin/bash devrez() { l=/sys/dev/block/`echo "$1" | sed 's/dev//g;s/-/:/g'` test ! -L "$l" && echo "[$1] not found" && return -1 readlink -f "$l" | awk -F / '{ORS="";print "\t"$NF}' } export -f devrez sar -d -f /var/log/sa/sa18 | awk '{OFS="\t";ORS="";print $1; system("/bin/bash -c '...
732,238
<p>In a Amazon s3 bucket we have Debian packages stored in different folders. Each folder contains different amounts of files.</p> <p>While calling Debian packages from the s3 bucket (AWS) the packages are separated with spaces. Now I need to convert those space-separated packages lists into newline-separated list, i.e...
[ { "answer_id": 732232, "author": "roaima", "author_id": 100397, "author_profile": "https://unix.stackexchange.com/users/100397", "pm_score": 2, "selected": false, "text": "<p>The documentation <code>man sar</code> tells you how to get name lookups for <code>sar -d</code>:</p>\n<blockquot...
2023/01/18
[ "https://unix.stackexchange.com/questions/732238", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557187/" ]
In a Amazon s3 bucket we have Debian packages stored in different folders. Each folder contains different amounts of files. While calling Debian packages from the s3 bucket (AWS) the packages are separated with spaces. Now I need to convert those space-separated packages lists into newline-separated list, i.e. one pac...
Try this: ```bash #! /bin/bash devrez() { l=/sys/dev/block/`echo "$1" | sed 's/dev//g;s/-/:/g'` test ! -L "$l" && echo "[$1] not found" && return -1 readlink -f "$l" | awk -F / '{ORS="";print "\t"$NF}' } export -f devrez sar -d -f /var/log/sa/sa18 | awk '{OFS="\t";ORS="";print $1; system("/bin/bash -c '...
732,260
<p>I have a set of files with the following filename structure:</p> <pre><code>aa_bbbbb_cccccccc_dddddd.txt </code></pre> <p>I want to replace the third element <code>cccccccc</code> with the value of the variable <code>value</code> which I extract from the content of the file.</p> <p>The values of the 4 components of ...
[ { "answer_id": 732262, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 0, "selected": false, "text": "<h3>Example of a file with <code>value</code> variable</h3>\n<pre><code>value=xxx\n</code></pre>\n<p>Then, usin...
2023/01/18
[ "https://unix.stackexchange.com/questions/732260", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557226/" ]
I have a set of files with the following filename structure: ``` aa_bbbbb_cccccccc_dddddd.txt ``` I want to replace the third element `cccccccc` with the value of the variable `value` which I extract from the content of the file. The values of the 4 components of the filename change, so I cannot replace using strin...
`bash` does have a splitting operator, the same awkward one as in ksh or in POSIX `sh`: the IFS-splitting that is performed (and most often unwanted) whem you leave a parameter expansion unquoted. ``` cmd $var ``` *does* split `$var` on `$IFS` characters (and also performs globbing), also known as the infamous split...
732,338
<p>Given a file like this</p> <pre class="lang-none prettyprint-override"><code>value,value,value,value value1,value1,value,value1 value2,value2,value,value2 </code></pre> <p>How can I transform it to look like this:</p> <pre class="lang-none prettyprint-override"><code>value,value,value,value value1,value1, ,value1...
[ { "answer_id": 732306, "author": "Stephen Kitt", "author_id": 86440, "author_profile": "https://unix.stackexchange.com/users/86440", "pm_score": 2, "selected": false, "text": "<p>Yes, on Debian-derived systems the canonical location for udev files is <code>/lib/udev</code>. However you s...
2023/01/19
[ "https://unix.stackexchange.com/questions/732338", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557329/" ]
Given a file like this ```none value,value,value,value value1,value1,value,value1 value2,value2,value,value2 ``` How can I transform it to look like this: ```none value,value,value,value value1,value1, ,value1 value2,value2, ,value2 ``` Basically, to merge duplicate values in column 3 and present it in firs...
Yes, on Debian-derived systems the canonical location for udev files is `/lib/udev`. However you shouldn’t have to care about that in your package build, at least if you’re building using a source package: [`dh_installudev`](https://manpages.debian.org/bullseye/debhelper/dh_installudev.1) will install them in the right...
732,378
<pre><code>INPUT | grep --color=always &quot;$string\{1,1\}&quot; </code></pre> <p>... alas, every instance of $string is highlighted. As I read the docs, the '{1,1}' should insure that only the first instance is highlighted. Or is there a better tool? I can't use sed</p> <pre><code>INPUT | sed -r &quot;s|$string|${...
[ { "answer_id": 732380, "author": "LSerni", "author_id": 41216, "author_profile": "https://unix.stackexchange.com/users/41216", "pm_score": 2, "selected": true, "text": "<p>I think you <em>can</em> use <code>sed</code> if you use pattern substitution (the match is case insensitive, but th...
2023/01/19
[ "https://unix.stackexchange.com/questions/732378", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/56145/" ]
``` INPUT | grep --color=always "$string\{1,1\}" ``` ... alas, every instance of $string is highlighted. As I read the docs, the '{1,1}' should insure that only the first instance is highlighted. Or is there a better tool? I can't use sed ``` INPUT | sed -r "s|$string|${red}$string${nrm}|I" ``` ( ${red} and ${nrm}...
I think you *can* use `sed` if you use pattern substitution (the match is case insensitive, but the replacement uses the captured pattern, not the searched one): ``` INPUT | sed -r "s|(${string})|${red}\\1${nrm}|I" ``` Also, as @don\_crissti noticed, if you want to colorize the *entire* found pattern, you needn't ev...
732,431
<p><code>wsl.exe</code> help (shown by <code>wsl.exe --help</code>) talks about &quot;the system distribution&quot;:</p> <pre><code>Options: ... --system Launches a shell for the system distribution. </code></pre> <p>What is it? Searching in WSL docs for &quot;system distribution&quot; gave me only the foll...
[ { "answer_id": 732380, "author": "LSerni", "author_id": 41216, "author_profile": "https://unix.stackexchange.com/users/41216", "pm_score": 2, "selected": true, "text": "<p>I think you <em>can</em> use <code>sed</code> if you use pattern substitution (the match is case insensitive, but th...
2023/01/20
[ "https://unix.stackexchange.com/questions/732431", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/455802/" ]
`wsl.exe` help (shown by `wsl.exe --help`) talks about "the system distribution": ``` Options: ... --system Launches a shell for the system distribution. ``` What is it? Searching in WSL docs for "system distribution" gave me only the following hit in the section [How to manage WSL disk space](https://le...
I think you *can* use `sed` if you use pattern substitution (the match is case insensitive, but the replacement uses the captured pattern, not the searched one): ``` INPUT | sed -r "s|(${string})|${red}\\1${nrm}|I" ``` Also, as @don\_crissti noticed, if you want to colorize the *entire* found pattern, you needn't ev...
732,440
<p>I have data which are in &quot;Key:value&quot; form where keys are <code>901</code>,<code>902</code>,<code>903</code>,<code>904</code> and respective values are <code>S</code>,<code>M</code>,<code>F,</code>WAP`, with space as delimiter.</p> <ul> <li>Input example <pre><code>901 S 902 M 903 F 904 WAP ..... </code></p...
[ { "answer_id": 732380, "author": "LSerni", "author_id": 41216, "author_profile": "https://unix.stackexchange.com/users/41216", "pm_score": 2, "selected": true, "text": "<p>I think you <em>can</em> use <code>sed</code> if you use pattern substitution (the match is case insensitive, but th...
2023/01/20
[ "https://unix.stackexchange.com/questions/732440", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557446/" ]
I have data which are in "Key:value" form where keys are `901`,`902`,`903`,`904` and respective values are `S`,`M`,`F,`WAP`, with space as delimiter. * Input example ``` 901 S 902 M 903 F 904 WAP ..... ``` I want to convert into `key:value,key:value` format. * Desired output: ``` 901:S,902:M,903:F,904:WAP ..... ...
I think you *can* use `sed` if you use pattern substitution (the match is case insensitive, but the replacement uses the captured pattern, not the searched one): ``` INPUT | sed -r "s|(${string})|${red}\\1${nrm}|I" ``` Also, as @don\_crissti noticed, if you want to colorize the *entire* found pattern, you needn't ev...
732,441
<p>How can I find the directory with the longest path (contains the largest number of subdirectories) , in the current directory , using <code>ls ~ -R</code> commmand</p>
[ { "answer_id": 732447, "author": "AdminBee", "author_id": 377345, "author_profile": "https://unix.stackexchange.com/users/377345", "pm_score": 2, "selected": false, "text": "<p>The following will assume that your directory names don't contain newlines. If that is the case, the following ...
2023/01/20
[ "https://unix.stackexchange.com/questions/732441", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/554815/" ]
How can I find the directory with the longest path (contains the largest number of subdirectories) , in the current directory , using `ls ~ -R` commmand
The following will assume that your directory names don't contain newlines. If that is the case, the following will work: ```sh find . -type d | awk -F'/' 'NF>max{longest=$0;max=NF} END{if (max) print longest}' ``` This will use `find` to search all sub-directories of the current directory. It will feed the output t...
732,451
<p>I have the following command I'd like to run in all subfolders:</p> <pre><code>for f in *.mp4; do ffmpeg -i &quot;${f}&quot; -c:v libx264 -b:v 1.5M -c:a aac &quot;tmp_${f}&quot; &amp;&amp; mv &quot;tmp_${f}&quot; &quot;${f}&quot; done </code></pre> <p>Folder structure: In the base folder 2019 I want to execute in al...
[ { "answer_id": 732447, "author": "AdminBee", "author_id": 377345, "author_profile": "https://unix.stackexchange.com/users/377345", "pm_score": 2, "selected": false, "text": "<p>The following will assume that your directory names don't contain newlines. If that is the case, the following ...
2023/01/20
[ "https://unix.stackexchange.com/questions/732451", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557093/" ]
I have the following command I'd like to run in all subfolders: ``` for f in *.mp4; do ffmpeg -i "${f}" -c:v libx264 -b:v 1.5M -c:a aac "tmp_${f}" && mv "tmp_${f}" "${f}" done ``` Folder structure: In the base folder 2019 I want to execute in all subfolders the command. There is a folder for every month, i.e. for ja...
The following will assume that your directory names don't contain newlines. If that is the case, the following will work: ```sh find . -type d | awk -F'/' 'NF>max{longest=$0;max=NF} END{if (max) print longest}' ``` This will use `find` to search all sub-directories of the current directory. It will feed the output t...
732,473
<p>I'm trying to make a bash shell script that mounts, from some pre-obtained variables, a text file.</p> <p>For this I use sed, changing the flags of the file by the desired:</p> <pre><code>sed &quot;s/this is a line in text/$var/g&quot; file </code></pre> <p>It works correctly and without problems. However, the <code...
[ { "answer_id": 732476, "author": "choroba", "author_id": 13792, "author_profile": "https://unix.stackexchange.com/users/13792", "pm_score": 2, "selected": false, "text": "<p>In case of the certificate, there are only two problematic characters: a slash and newline. You can use parameter ...
2023/01/20
[ "https://unix.stackexchange.com/questions/732473", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/373893/" ]
I'm trying to make a bash shell script that mounts, from some pre-obtained variables, a text file. For this I use sed, changing the flags of the file by the desired: ``` sed "s/this is a line in text/$var/g" file ``` It works correctly and without problems. However, the `$var` variable often has strange characters,...
If you insert the contents of a file (not the value of a variable) with `sed`, it's easier: ```bash sed -e '/^this is a line in text$/r mycert' -e '//d' file ``` This will parse the file called `file`. If a line which matches the expression `^this is a line in text$` is found, the file called `mycert` is inserted, w...
732,485
<p>I would like to make a script to start the <a href="https://waydro.id/" rel="nofollow noreferrer">Waydroid</a> Android container (LineageOS).</p> <p>Currently, I can start a <a href="https://lineageos.org/" rel="nofollow noreferrer">LineageOS</a> virtual phone without issues with:</p> <pre><code>sudo systemctl start...
[ { "answer_id": 732476, "author": "choroba", "author_id": 13792, "author_profile": "https://unix.stackexchange.com/users/13792", "pm_score": 2, "selected": false, "text": "<p>In case of the certificate, there are only two problematic characters: a slash and newline. You can use parameter ...
2023/01/20
[ "https://unix.stackexchange.com/questions/732485", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/44919/" ]
I would like to make a script to start the [Waydroid](https://waydro.id/) Android container (LineageOS). Currently, I can start a [LineageOS](https://lineageos.org/) virtual phone without issues with: ``` sudo systemctl start waydroid-container weston ``` And then, inside the `weston-terminal`: ``` waydroid sessio...
If you insert the contents of a file (not the value of a variable) with `sed`, it's easier: ```bash sed -e '/^this is a line in text$/r mycert' -e '//d' file ``` This will parse the file called `file`. If a line which matches the expression `^this is a line in text$` is found, the file called `mycert` is inserted, w...
732,503
<p>I have a POSIX shell script which has its standard output <code>1</code> redirected to a pipe. At some point of the script execution, the pipe will break and I'd like to find out (in my shell script) when that happens.</p> <p>So I tried this:</p> <pre class="lang-bash prettyprint-override"><code>( trap &quot;&quot...
[ { "answer_id": 736767, "author": "theguy123", "author_id": 558229, "author_profile": "https://unix.stackexchange.com/users/558229", "pm_score": -1, "selected": false, "text": "<p>I don't think that pipe will break. When you use the OR operator (||) in bash, it almost always disregards it...
2023/01/20
[ "https://unix.stackexchange.com/questions/732503", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/296048/" ]
I have a POSIX shell script which has its standard output `1` redirected to a pipe. At some point of the script execution, the pipe will break and I'd like to find out (in my shell script) when that happens. So I tried this: ```bash ( trap "" PIPE # prevent shell from terminating due to SIGPIPE while :; do e...
> > At some point of the script execution, the pipe will break and I'd like to find out when that happens. > > > You can only tell that if you try to write to the pipe. Based on the Linux man pages, it looks to me like any `write()` call to the write-end of a pipe with no reader should give the signal/error, even...
732,509
<p>I have a folder with multiple .NET projects, let's call the parent directory <code>projects</code>. Each .NET project has a <code>bin</code> folder with the binaries built for that project. Now I want to get the sum of the sizes of the files in all of these folders.</p> <p>So far, I can get a list of each <code>bin<...
[ { "answer_id": 736767, "author": "theguy123", "author_id": 558229, "author_profile": "https://unix.stackexchange.com/users/558229", "pm_score": -1, "selected": false, "text": "<p>I don't think that pipe will break. When you use the OR operator (||) in bash, it almost always disregards it...
2023/01/20
[ "https://unix.stackexchange.com/questions/732509", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/21888/" ]
I have a folder with multiple .NET projects, let's call the parent directory `projects`. Each .NET project has a `bin` folder with the binaries built for that project. Now I want to get the sum of the sizes of the files in all of these folders. So far, I can get a list of each `bin` directory with ``` du -h | grep 'b...
> > At some point of the script execution, the pipe will break and I'd like to find out when that happens. > > > You can only tell that if you try to write to the pipe. Based on the Linux man pages, it looks to me like any `write()` call to the write-end of a pipe with no reader should give the signal/error, even...
732,523
<p>I am making a bash script where I need to run a command using a specific ID. But a single ID can be used only 10 times. After that the ID should change</p> <p>For Example I have three IDs</p> <pre><code>ID=(abcd1 abcd2 abcd3) echo $ID </code></pre> <p>Now when this script is executed 10 times then the value of ID s...
[ { "answer_id": 732527, "author": "xiota", "author_id": 209257, "author_profile": "https://unix.stackexchange.com/users/209257", "pm_score": 1, "selected": false, "text": "<p>You can put counters in the script. Then have the script update them each time it's run.</p>\n<pre><code>#!/usr/b...
2023/01/20
[ "https://unix.stackexchange.com/questions/732523", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525521/" ]
I am making a bash script where I need to run a command using a specific ID. But a single ID can be used only 10 times. After that the ID should change For Example I have three IDs ``` ID=(abcd1 abcd2 abcd3) echo $ID ``` Now when this script is executed 10 times then the value of ID should change to abcd2.. more a...
You can put counters in the script. Then have the script update them each time it's run. ``` #!/usr/bin/env bash _list=( abc def ghi ) _list_index=0 # autoupdate _list_usage_counter=0 # autoupdate max_uses=10 if [ $((_list_usage_counter)) -eq $((max_uses - 1)) ] ; then # reset counter sed -Ei \ -e "s/^...
732,529
<p>I have a large file containing data set names and dates/time:</p> <pre><code>ss:Type=&quot;String&quot;&gt;EDII.HA5274.FNS99R.R999999.LFN5913.G1795V00&lt;/Data&gt; ss:Type=&quot;DateTime&quot;&gt;2022-12-28T00:00:00.000&lt;/Data&gt; ss:Type=&quot;DateTime&quot;&gt;1899-12-31T23:50:14.000&lt;/Data&gt; ss:Type=&quot;S...
[ { "answer_id": 732530, "author": "glenn jackman", "author_id": 4667, "author_profile": "https://unix.stackexchange.com/users/4667", "pm_score": 2, "selected": false, "text": "<p>I'd use <a href=\"/questions/tagged/awk\" class=\"post-tag\" title=\"show questions tagged &#39;awk&#39;\" ari...
2023/01/20
[ "https://unix.stackexchange.com/questions/732529", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/100557/" ]
I have a large file containing data set names and dates/time: ``` ss:Type="String">EDII.HA5274.FNS99R.R999999.LFN5913.G1795V00</Data> ss:Type="DateTime">2022-12-28T00:00:00.000</Data> ss:Type="DateTime">1899-12-31T23:50:14.000</Data> ss:Type="String">EDII.HA5273.FNS9901R.R999999.LFN5913.G1796V00</Data> ss:Type="DateTi...
I'd use [awk](/questions/tagged/awk "show questions tagged 'awk'"). If the line contains "String" print it without a newline, otherwise with one. ```bash awk ' BEGIN {FS = "\""; RS = "\r\n"} {printf "%s%s", $0, $2 == "String" ? "" : RS} ' The_File.txt ```
732,543
<p>I have a directory with ogg file, and want to change file names starting with <code>i-</code>.</p> <p>What can I do? For instance, doing <code>rename 's/i-nuovi/nuovi/g' *</code> gave me</p> <pre><code>Unknown option: marino-barreto-cinque-minuti-ancora.ogg Usage: rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-...
[ { "answer_id": 732546, "author": "Gilles Quénot", "author_id": 12574, "author_profile": "https://unix.stackexchange.com/users/12574", "pm_score": 1, "selected": true, "text": "<p>Different implementations of <a href=\"https://unix.stackexchange.com/questions/730894/what-about-rename-diff...
2023/01/21
[ "https://unix.stackexchange.com/questions/732543", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/540882/" ]
I have a directory with ogg file, and want to change file names starting with `i-`. What can I do? For instance, doing `rename 's/i-nuovi/nuovi/g' *` gave me ``` Unknown option: marino-barreto-cinque-minuti-ancora.ogg Usage: rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E perlexpr]*|perlexpr [ files ] ``` ...
Different implementations of [Perl's `rename`](https://unix.stackexchange.com/questions/730894/what-about-rename-different-versions-and-usage-what-is-the-recommended-way-to/730895#730895): Try ``` rename --version ``` and check my link Then ``` rename -n 's/^i-nuovi/nuovi/g' -- ./*.ogg # ...
732,555
<p>I have a output like this in a text file, where <code>^M</code> represents CR</p> <pre><code>Last login: Sat Jan 22 09:49:50 2023 from 10.1.1.1^M Cisco Router uptime exit -f Connecting user mike from 10.1.1.1 ****************************************** Warning ******************************************^M ^M Warning...
[ { "answer_id": 732557, "author": "Arnaud Valmary", "author_id": 489056, "author_profile": "https://unix.stackexchange.com/users/489056", "pm_score": 1, "selected": true, "text": "<p>Try this:</p>\n<pre class=\"lang-bash prettyprint-override\"><code>cat testbeta1.text | tr -d &quot;\\r&qu...
2023/01/21
[ "https://unix.stackexchange.com/questions/732555", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/172771/" ]
I have a output like this in a text file, where `^M` represents CR ``` Last login: Sat Jan 22 09:49:50 2023 from 10.1.1.1^M Cisco Router uptime exit -f Connecting user mike from 10.1.1.1 ****************************************** Warning ******************************************^M ^M Warning monitoring.^M ^M ******...
Try this: ```bash cat testbeta1.text | tr -d "\r" | tr "\n" " " | tr -s " " | grep -Eo 'mike@[^>]+> uptime [0-9]+ days, [0-9]+:[0-9]+' | cut -d "@" -f 2- ``` Explanations: * `tr -d "\r"`: remove all CR characters * `tr "\n" " "`: replace each LF character by one space * `tr -s " "`: replace each sequence of a repea...
732,574
<p>I'm building an app where it makes sense for the user to be able to select a different timezone than their actual own timezone for certain operations, without going too much into details, I can assure you it actually makes sense to support multiple timezones for certain niche operations.</p> <p>I'm aware of the IANA...
[ { "answer_id": 732557, "author": "Arnaud Valmary", "author_id": 489056, "author_profile": "https://unix.stackexchange.com/users/489056", "pm_score": 1, "selected": true, "text": "<p>Try this:</p>\n<pre class=\"lang-bash prettyprint-override\"><code>cat testbeta1.text | tr -d &quot;\\r&qu...
2023/01/21
[ "https://unix.stackexchange.com/questions/732574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557592/" ]
I'm building an app where it makes sense for the user to be able to select a different timezone than their actual own timezone for certain operations, without going too much into details, I can assure you it actually makes sense to support multiple timezones for certain niche operations. I'm aware of the IANA TZ Datab...
Try this: ```bash cat testbeta1.text | tr -d "\r" | tr "\n" " " | tr -s " " | grep -Eo 'mike@[^>]+> uptime [0-9]+ days, [0-9]+:[0-9]+' | cut -d "@" -f 2- ``` Explanations: * `tr -d "\r"`: remove all CR characters * `tr "\n" " "`: replace each LF character by one space * `tr -s " "`: replace each sequence of a repea...
732,578
<p>When I tried to change my password on an ssh key, I received the following error message:</p> <pre><code>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/Users/use...
[ { "answer_id": 732579, "author": "Jens", "author_id": 276921, "author_profile": "https://unix.stackexchange.com/users/276921", "pm_score": 0, "selected": false, "text": "<p>Form the man page:</p>\n<pre><code>ssh-keygen -p [-f keyfile] [-m format] [-N new_passphrase]\n [...
2023/01/16
[ "https://unix.stackexchange.com/questions/732578", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557602/" ]
When I tried to change my password on an ssh key, I received the following error message: ``` @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/Users/username/.ssh/id...
``` sudo ssh-keygen -f ~/.ssh/YOU_PRIVATE_SSH_KEY -p ``` If the terminal displays the message `Permissions 0644` then run the command as `root` If the terminal displays the message `failed: Permission denied` To fix permission issues, first you need to set the correct ownership and permissions for the home director...
732,602
<p>I have a file which has list of cidr's. How can I create a big json with below format using bash script <strong>With single CIDR</strong></p> <pre><code>[{&quot;source&quot;:&quot;1.1.1.0/32&quot;,&quot;protocol&quot;:&quot;17&quot;,&quot;isStateless&quot;:true,&quot;udpOptions&quot;:{&quot;destinationPortRange&quot...
[ { "answer_id": 732608, "author": "NetIceCat", "author_id": 80264, "author_profile": "https://unix.stackexchange.com/users/80264", "pm_score": 0, "selected": false, "text": "<h3>Answer</h3>\n<p>This should get you the exact syntax you require:</p>\n<p>In the example , the file containing ...
2023/01/21
[ "https://unix.stackexchange.com/questions/732602", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/525521/" ]
I have a file which has list of cidr's. How can I create a big json with below format using bash script **With single CIDR** ``` [{"source":"1.1.1.0/32","protocol":"17","isStateless":true,"udpOptions":{"destinationPortRange":{"max":65535,"min":1},"sourcePortRange":{"min":521,"max":65535}}}] ``` **With Multiple CIDR*...
There are two main issues in your data and code: 1. You have an input file in DOS or Windows text file format. 2. Your code creates multiple single-element arrays rather than a single array with multiple elements. Your input file, `lol`, appears to be a text file in DOS/Windows format. This means that when a utility ...
732,624
<p>I'm somewhat of a beginner with Linux, sorry for the dumb question.</p> <p>I installed a persistent Linux Mint install to a USB drive. It has been working well, but now I want to install it directly to a new SSD drive I bought.</p> <p>I thought that using the &quot;Install&quot; option would already copy all my apps...
[ { "answer_id": 732608, "author": "NetIceCat", "author_id": 80264, "author_profile": "https://unix.stackexchange.com/users/80264", "pm_score": 0, "selected": false, "text": "<h3>Answer</h3>\n<p>This should get you the exact syntax you require:</p>\n<p>In the example , the file containing ...
2023/01/22
[ "https://unix.stackexchange.com/questions/732624", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/281429/" ]
I'm somewhat of a beginner with Linux, sorry for the dumb question. I installed a persistent Linux Mint install to a USB drive. It has been working well, but now I want to install it directly to a new SSD drive I bought. I thought that using the "Install" option would already copy all my apps and user files to the dr...
There are two main issues in your data and code: 1. You have an input file in DOS or Windows text file format. 2. Your code creates multiple single-element arrays rather than a single array with multiple elements. Your input file, `lol`, appears to be a text file in DOS/Windows format. This means that when a utility ...
732,678
<p>I have a SD card that is giving me some trouble. I followed some instructions from here <a href="https://forums.linuxmint.com/viewtopic.php?t=368230" rel="nofollow noreferrer">https://forums.linuxmint.com/viewtopic.php?t=368230</a> and used the command</p> <pre><code>sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1 </...
[ { "answer_id": 732680, "author": "Marcus Müller", "author_id": 106650, "author_profile": "https://unix.stackexchange.com/users/106650", "pm_score": 2, "selected": true, "text": "<p>When a card suddenly changes to 0 capacity, that's not under the control of your PC: that's the controller ...
2023/01/22
[ "https://unix.stackexchange.com/questions/732678", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557692/" ]
I have a SD card that is giving me some trouble. I followed some instructions from here <https://forums.linuxmint.com/viewtopic.php?t=368230> and used the command ``` sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1 ``` (I know this is dangerous. i've done it because the card was really cheap, and I suspect it is bogu...
When a card suddenly changes to 0 capacity, that's not under the control of your PC: that's the controller within the SD card stopping to work. Since you have no way of debugging the software running on that controller, nor any way to look inside its hardware: Your card is e-waste. That was essentially clear when you...
732,682
<p>I am trying to speed up a <code>find</code> command which accesses files on multiple harddrives by utilizing parallelization. Unfortunately, either the parallelization is ignored or the variable is not filled.</p> <pre><code>found=&quot;&quot;; IFS=$'\n' for hdd in &quot;${hdd_list[@]}&quot; do found+=$'\n'$(fi...
[ { "answer_id": 732704, "author": "gfaster", "author_id": 545231, "author_profile": "https://unix.stackexchange.com/users/545231", "pm_score": 1, "selected": false, "text": "<p>Specifically for parallelizing <code>find</code>, check out <a href=\"https://github.com/sharkdp/fd\" rel=\"nofo...
2023/01/22
[ "https://unix.stackexchange.com/questions/732682", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/328125/" ]
I am trying to speed up a `find` command which accesses files on multiple harddrives by utilizing parallelization. Unfortunately, either the parallelization is ignored or the variable is not filled. ``` found=""; IFS=$'\n' for hdd in "${hdd_list[@]}" do found+=$'\n'$(find "$hdd" -name "*filter*" -type f &) # igno...
Command substitutions wait to get all the data from the pipe opened to the command inside before they continue. Having the shell continue reading the data in the background while continuing with the script would be far more complicated than is necessary. (Incidentally, this also means that even if the command inside th...
732,729
<p>I have data which are in &quot;Key:value&quot; form (901 S 902 M 905 F 906 WAPENC 907 31 908 371 909 38765469947/TYPE=PLMN and so on ) where keys are 901,902,905,906.....so on and respective values are after spaces S,M,F,WAPENC,31...so on .</p> <p>Input example</p> <pre><code>901 S 902 M 905 F 906 WAPENC 907 31 908 ...
[ { "answer_id": 732730, "author": "ilkkachu", "author_id": 170373, "author_profile": "https://unix.stackexchange.com/users/170373", "pm_score": 1, "selected": true, "text": "<p>Like so?</p>\n<pre><code>% perl -pe 's/(\\S+) (\\S+) ?/$1:$2,/g; s/,$//' file.txt\n901:S,902:M,905:F,906:WAPENC,...
2023/01/23
[ "https://unix.stackexchange.com/questions/732729", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557446/" ]
I have data which are in "Key:value" form (901 S 902 M 905 F 906 WAPENC 907 31 908 371 909 38765469947/TYPE=PLMN and so on ) where keys are 901,902,905,906.....so on and respective values are after spaces S,M,F,WAPENC,31...so on . Input example ``` 901 S 902 M 905 F 906 WAPENC 907 31 908 371 909 38765469947/TYPE=PLMN...
Like so? ``` % perl -pe 's/(\S+) (\S+) ?/$1:$2,/g; s/,$//' file.txt 901:S,902:M,905:F,906:WAPENC,907:31,908:371,909:38765469947/TYPE=PLMN ``` or ``` % sed -E -e 's/([^ ]+) ([^ ]+) ?/\1:\2,/g; s/,$//' file.txt 901:S,902:M,905:F,906:WAPENC,907:31,908:371,909:38765469947/TYPE=PLMN ``` Both basically say to take a st...
732,753
<p>I got a 1.5TB datacenter-grade SAS SSD, and I am now installing a new install of CentOS 7 on it (CentOS 7 will be changed to CloudLinux later).</p> <p>I am setting up the partition scheme and I have plenty of space to work with. My server has 256GB of RAM, so I'm not going to make SWAP 1.5x that obviously.</p> <p>A ...
[ { "answer_id": 732762, "author": "Marcus Müller", "author_id": 106650, "author_profile": "https://unix.stackexchange.com/users/106650", "pm_score": 0, "selected": false, "text": "<p>For anything server-sized, you <em>Really</em> don't want to rely on static partitioning. Assuming this is...
2023/01/23
[ "https://unix.stackexchange.com/questions/732753", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557788/" ]
I got a 1.5TB datacenter-grade SAS SSD, and I am now installing a new install of CentOS 7 on it (CentOS 7 will be changed to CloudLinux later). I am setting up the partition scheme and I have plenty of space to work with. My server has 256GB of RAM, so I'm not going to make SWAP 1.5x that obviously. A lot of web acti...
> > Here is what I came up with. What would you change? > > > my **recommendation** would be to do like this ``` /boot 1gb (or 2gb would be fine) /boot/efi 100mb (or 200mb would be fine) / max (remaining space of your N tb ssd) ``` here is why I say this, take it fwiw * Been runn...
732,755
<p>I have been trying to do this myself based on other examples but have failed. I want awk to reprint a tab delimited file but add an extra column at the end which starts at 1 and increases as long as column1 is the same, when column1 has a new value, last column gets reset to 1....</p> <p>Brief example, input if colu...
[ { "answer_id": 732760, "author": "Freddy", "author_id": 332764, "author_profile": "https://unix.stackexchange.com/users/332764", "pm_score": 2, "selected": false, "text": "<p>Given your example, you only need to remember the value of the first field of the last run and a counter variable...
2023/01/23
[ "https://unix.stackexchange.com/questions/732755", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/557789/" ]
I have been trying to do this myself based on other examples but have failed. I want awk to reprint a tab delimited file but add an extra column at the end which starts at 1 and increases as long as column1 is the same, when column1 has a new value, last column gets reset to 1.... Brief example, input if columns 1-3 a...
```bash $ awk -F '\t' 'BEGIN { OFS=FS } $1 != save { counter = 1; save = $1 } { print $0, counter++ }' file A11R Q9Y5X3 SNX5 1 A12L Q9Y316 MEMO1 1 A12L Q70CQ2 USP34 2 A12L Q8N7H5 PAF1 3 A12L Q8IZL8 PELP1 4 A13L Q5SY16 NOL9 1 A13L Q6P1J9 CDC73 2 A13L Q8WVC0 LEO1 3 A13L...
732,767
<p>I have the below for loop in my shell script:</p> <pre><code>#!bin/ksh touch output.dat IFS=&quot;&gt;&gt;&gt;&quot; i=0 for stm in `grep &quot;cpdctl dsjob run-pipeline --project &quot; input_file` do echo &quot;the current stmt is : $stm&quot; done </code></pre> <p>In my input file <strong>input_file</strong> I ha...
[ { "answer_id": 732777, "author": "Marius_Couet", "author_id": 539768, "author_profile": "https://unix.stackexchange.com/users/539768", "pm_score": 2, "selected": false, "text": "<p>Using <code>awk</code> :</p>\n<pre class=\"lang-bash prettyprint-override\"><code>awk '/cpdctl dsjob run-pi...
2023/01/23
[ "https://unix.stackexchange.com/questions/732767", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/535046/" ]
I have the below for loop in my shell script: ``` #!bin/ksh touch output.dat IFS=">>>" i=0 for stm in `grep "cpdctl dsjob run-pipeline --project " input_file` do echo "the current stmt is : $stm" done ``` In my input file **input\_file** I have two records matching the pattern. So I expected the output to be like `...
Using `awk` : ```bash awk '/cpdctl dsjob run-pipeline --project / {print "the current stmt is :", $0}' input ``` This will print each line containing `cpdctl dsjob run-pipeline --project`
732,773
<p>I have large csv file and want to build simple ranking:</p> <pre><code>$ cat file.csv 2022-12-01 RED 1 2022-12-01 RED 1 2022-12-01 RED 2 2022-12-01 RED 2 2022-12-01 RED 2 2022-12-01 YELLOW 1 2022-12-01 YELLOW 1 2022-12-01 ...
[ { "answer_id": 732780, "author": "terdon", "author_id": 22222, "author_profile": "https://unix.stackexchange.com/users/22222", "pm_score": 3, "selected": true, "text": "<p>It sounds like all you want to do is simply move the number from the first field to the last. You don't specify this...
2023/01/23
[ "https://unix.stackexchange.com/questions/732773", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/459074/" ]
I have large csv file and want to build simple ranking: ``` $ cat file.csv 2022-12-01 RED 1 2022-12-01 RED 1 2022-12-01 RED 2 2022-12-01 RED 2 2022-12-01 RED 2 2022-12-01 YELLOW 1 2022-12-01 YELLOW 1 2022-12-01 YELLOW 2 ...
It sounds like all you want to do is simply move the number from the first field to the last. You don't specify this, but given the `cut` command you show, that should mean that your file is tab-delimited. If so, given that the `uniq -c` output will pad the line with spaces (which you also haven't shown), and will not ...