id
int64
site
string
title
string
question_body
string
question_body_md
string
question_score
int32
question_view_count
int32
question_answer_count
int32
question_comment_count
int32
question_favorite_count
int32
question_tags
list
question_creation_date
string
question_last_edit_date
string
question_user_id
int64
accepted_answer_id
int64
answers
list
best_answer
string
text
string
char_length
int32
tokens_estimate
int32
meta
dict
665,218
unix.stackexchange.com
grep should find a hex value in a file but doesn't
<p>Here is the beginning of a file:</p> <pre><code># hexdump -n 550 myFile 0000000 f0f2 f5f0 f7f9 f1f1 f1f0 f0f0 e3f1 f3c8 0000010 f3f5 0000 0000 000c 0000 0000 0000 000c 0000020 0000 0c00 0000 0000 0000 0c00 0000 0000 0000030 000c 0000 0000 0000 000c 0000 0c00 0000 0000040 0000 0000 0c00 0000 0000 000c 0000 0000 00000...
Here is the beginning of a file: ``` # hexdump -n 550 myFile 0000000 f0f2 f5f0 f7f9 f1f1 f1f0 f0f0 e3f1 f3c8 0000010 f3f5 0000 0000 000c 0000 0000 0000 000c 0000020 0000 0c00 0000 0000 0000 0c00 0000 0000 0000030 000c 0000 0000 0000 000c 0000 0c00 0000 0000040 0000 0000 0c00 0000 0000 000c 0000 0000 0000050 0000 000c 0...
6
793
1
12
0
[ "<grep><hex>" ]
2021-08-18T15:46:03.380
2021-08-18T15:57:47.297
487,450
665,225
[ { "id": 665225, "body": "<p><code>\\x0a</code> isn't just any hex value - it's the hex value corresponding to the ASCII linefeed character.</p>\n<p>Since grep is (by default) line-based, the linefeed characters are stripped out before pattern matching takes place. At least with GNU grep, you can change this...
`\x0a` isn't just any hex value - it's the hex value corresponding to the ASCII linefeed character. Since grep is (by default) line-based, the linefeed characters are stripped out before pattern matching takes place. At least with GNU grep, you can change this behavior with the `-z` option: ``` -z, --null-data Treat in...
# grep should find a hex value in a file but doesn't **Tags:** <grep><hex> **Question (score 6):** Here is the beginning of a file: ``` # hexdump -n 550 myFile 0000000 f0f2 f5f0 f7f9 f1f1 f1f0 f0f0 e3f1 f3c8 0000010 f3f5 0000 0000 000c 0000 0000 0000 000c 0000020 0000 0c00 0000 0000 0000 0c00 0000 0000 0000030 000c ...
2,154
538
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
665,326
unix.stackexchange.com
How can I print a '@' in a Linux shell?
<p>I have a problem with a remote server having a keyboard layout in the console different from my physical keyboard.</p> <p>I need to copy a <code>@</code> letter to be able to paste in a browser forum.</p> <p>The server is in a VPN without external access, so a simple googling for 'at symbol' doesn't work.</p> <p>Is ...
I have a problem with a remote server having a keyboard layout in the console different from my physical keyboard. I need to copy a `@` letter to be able to paste in a browser forum. The server is in a VPN without external access, so a simple googling for 'at symbol' doesn't work. Is there some trick to have a `@` prin...
7
2,839
6
4
3
[ "<bash>" ]
2021-08-19T11:35:42.103
2021-08-25T13:16:17.313
167,205
665,328
[ { "id": 665328, "body": "<p>With the bash shell:</p>\n<pre><code>echo $'\\x40'\n</code></pre>\n<p>With a POSIX shell:</p>\n<pre><code>printf '\\100'\n</code></pre>\n", "body_md": "With the bash shell: ``` echo $'\\x40' ``` With a POSIX shell: ``` printf '\\100' ```", "score": 41, "creation_date"...
With the bash shell: ``` echo $'\x40' ``` With a POSIX shell: ``` printf '\100' ```
# How can I print a '@' in a Linux shell? **Tags:** <bash> **Question (score 7):** I have a problem with a remote server having a keyboard layout in the console different from my physical keyboard. I need to copy a `@` letter to be able to paste in a browser forum. The server is in a VPN without external access, so ...
3,576
894
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
665,444
unix.stackexchange.com
how to jq nested array without key (only value) and convert to csv
<p>I hope someone can guide me how do I convert below json to csv that I'm expecting for.</p> <p>Much appreciated in advance.</p> <p>Update: thanks for the solutions provided, but I found that sometimes array does not exist when the 2nd column has only 1 record, example below is &quot;ASite&quot; has only 1 record &quo...
I hope someone can guide me how do I convert below json to csv that I'm expecting for. Much appreciated in advance. Update: thanks for the solutions provided, but I found that sometimes array does not exist when the 2nd column has only 1 record, example below is "ASite" has only 1 record "unixhost1123" paired to it. so...
8
947
2
0
0
[ "<csv><array><json><jq>" ]
2021-08-20T07:41:39.627
2021-08-20T16:00:36.620
487,692
665,456
[ { "id": 665456, "body": "<p><code>.[].results[]</code> is a set of arrays. In each array, the first element is what you want to have in the first column, and the second element is another array that we want to loop over.</p>\n<p>So let's keep track of the first element in <code>$name</code> (assuming this ...
`.[].results[]` is a set of arrays. In each array, the first element is what you want to have in the first column, and the second element is another array that we want to loop over. So let's keep track of the first element in `$name` (assuming this is a cluster name of some sort), and then output this together with eac...
# how to jq nested array without key (only value) and convert to csv **Tags:** <csv><array><json><jq> **Question (score 8):** I hope someone can guide me how do I convert below json to csv that I'm expecting for. Much appreciated in advance. Update: thanks for the solutions provided, but I found that sometimes array...
4,459
1,114
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
665,588
unix.stackexchange.com
Why can't I copy all files in a directory to a USB storage device?
<p>The <code>sdc1</code> was mounted on <code>/media/debian/Ventoy</code>.</p> <pre><code>debian@debian:~$ sudo blkid | grep Ventoy /dev/sdc1: LABEL=&quot;Ventoy&quot; UUID=&quot;F82D-76BE&quot; BLOCK_SIZE=&quot;512&quot; TYPE=&quot;exfat&quot; PTTYPE=&quot;dos&quot; PARTUUID=&quot;1af31d46-01&quot; debian@debian:~$ d...
The `sdc1` was mounted on `/media/debian/Ventoy`. ``` debian@debian:~$ sudo blkid | grep Ventoy /dev/sdc1: LABEL="Ventoy" UUID="F82D-76BE" BLOCK_SIZE="512" TYPE="exfat" PTTYPE="dos" PARTUUID="1af31d46-01" debian@debian:~$ df /media/debian/Ventoy Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdc1 15324256 797...
10
1,637
1
1
1
[ "<filesystems><filenames><cp><usb-drive><exfat>" ]
2021-08-21T06:21:27.530
2021-08-23T03:17:58.937
102,745
665,590
[ { "id": 665590, "body": "<p>My eyes jump straight to the fact that your file name has a pipe <code>|</code> in it.</p>\n<p>According to your output the file system type is <code>exfat</code>. FAT and its derivatives do not support inclusion of pipe, along with a few other things, in file names.</p>\n<p>If y...
My eyes jump straight to the fact that your file name has a pipe `|` in it. According to your output the file system type is `exfat`. FAT and its derivatives do not support inclusion of pipe, along with a few other things, in file names. If you were to rename the file to strip the problematic characters I’d imagine you...
# Why can't I copy all files in a directory to a USB storage device? **Tags:** <filesystems><filenames><cp><usb-drive><exfat> **Question (score 10):** The `sdc1` was mounted on `/media/debian/Ventoy`. ``` debian@debian:~$ sudo blkid | grep Ventoy /dev/sdc1: LABEL="Ventoy" UUID="F82D-76BE" BLOCK_SIZE="512" TYPE="exfa...
2,148
537
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
665,692
unix.stackexchange.com
Which nix-package provides a given file/binary/command?
<p>How can I figure out which <a href="https://github.com/NixOS/nixpkgs/" rel="noreferrer">nixpgs</a>-package provides a given file/command, that may or may note be installed on the system?</p> <p>Other package managers offer this functionality as follows:</p> <ul> <li>apt has <a href="http://manpages.ubuntu.com/manpag...
How can I figure out which nixpgs (https://github.com/NixOS/nixpkgs/)-package provides a given file/command, that may or may note be installed on the system? Other package managers offer this functionality as follows: - apt has apt-file (http://manpages.ubuntu.com/manpages/bionic/man1/apt-file.1.html) - rpm (https://ww...
6
140
2
4
0
[ "<nix>" ]
2021-08-03T18:15:58.470
2021-08-22T01:19:28.817
87,826
665,693
[ { "id": 665693, "body": "<p>You can install the <code>nix-index</code> package, build the index and then use <code>nix-locate</code> command:</p>\n<pre><code>[nix-shell:~]$ nix-locate 'bin/grep'\nperl532Packages.grepmail.out 75,569 x /nix/store/i4krsr02b3yymqhzz9kbz066rkjkn5zl-perl5.32.1...
You can install the `nix-index` package, build the index and then use `nix-locate` command: ``` [nix-shell:~]$ nix-locate 'bin/grep' perl532Packages.grepmail.out 75,569 x /nix/store/i4krsr02b3yymqhzz9kbz066rkjkn5zl-perl5.32.1-grepmail-5.3111/bin/grepmail perl530Packages.grepmail.out 75,569 x /nix/store/vc2iv0zi7kb0fr04...
# Which nix-package provides a given file/binary/command? **Tags:** <nix> **Question (score 6):** How can I figure out which nixpgs (https://github.com/NixOS/nixpkgs/)-package provides a given file/command, that may or may note be installed on the system? Other package managers offer this functionality as follows: -...
2,322
580
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
665,871
unix.stackexchange.com
How is that possible : the same partition mounted twice, and each mount shows a different content?
<p>Same partition mounted twice, showing a different content on each mountpoint. How is that possible ?</p> <pre><code># mkdir /mnt/tmp # mount -t ext4 -o noatime /dev/block/sda1 /mnt/tmp/ # mount | grep sda1 /dev/block/sda1 on /data type ext4 (rw,seclabel,noatime) /dev/block/sda1 on /mnt/tmp type ext4 (rw,seclabel,no...
Same partition mounted twice, showing a different content on each mountpoint. How is that possible ? ``` # mkdir /mnt/tmp # mount -t ext4 -o noatime /dev/block/sda1 /mnt/tmp/ # mount | grep sda1 /dev/block/sda1 on /data type ext4 (rw,seclabel,noatime) /dev/block/sda1 on /mnt/tmp type ext4 (rw,seclabel,noatime) # ll /da...
6
190
1
2
0
[ "<mount>" ]
2021-08-23T10:38:01.123
2021-08-23T13:41:06.470
152,418
665,877
[ { "id": 665877, "body": "<p>Here's how:</p>\n<pre><code># cd /tmp\n# mkdir foo bar\n# mount -B /usr/bin foo\n# mount -B /var/log bar\n# mount | egrep 'foo|bar'\n/dev/sda1 on /tmp/foo type ext4 (rw,relatime,errors=remount-ro)\n/dev/sda1 on /tmp/bar type ext4 (rw,relatime,errors=remount-ro)\n</code></pre>\n<p...
Here's how: ``` # cd /tmp # mkdir foo bar # mount -B /usr/bin foo # mount -B /var/log bar # mount | egrep 'foo|bar' /dev/sda1 on /tmp/foo type ext4 (rw,relatime,errors=remount-ro) /dev/sda1 on /tmp/bar type ext4 (rw,relatime,errors=remount-ro) ``` tl;dr; the output of the `mount` command is not reliable on modern versi...
# How is that possible : the same partition mounted twice, and each mount shows a different content? **Tags:** <mount> **Question (score 6):** Same partition mounted twice, showing a different content on each mountpoint. How is that possible ? ``` # mkdir /mnt/tmp # mount -t ext4 -o noatime /dev/block/sda1 /mnt/tmp/...
2,753
688
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
665,887
unix.stackexchange.com
Equivalent of executing a file (with shebang line) by entering its path?
<p>Say I have a file <em>hello</em>:</p> <pre class="lang-sh prettyprint-override"><code>#!/bin/sh echo &quot;Hello World!&quot; </code></pre> <p>Provided the executable bit is set on that file, I can execute it by entering its path on the prompt:</p> <pre class="lang-sh prettyprint-override"><code>$ ./hello Hello Wor...
Say I have a file hello: ``` #!/bin/sh echo "Hello World!" ``` Provided the executable bit is set on that file, I can execute it by entering its path on the prompt: ``` $ ./hello Hello World! ``` Is there a more explicit equivalent to the above? Something akin to: ``` $ execute hello ``` I know I can pass hello as an a...
7
757
2
4
1
[ "<shell-script><executable><shebang>" ]
2021-08-23T13:16:44.837
2021-08-24T16:14:00.053
73,254
665,896
[ { "id": 665896, "body": "<p>You can use <code>perl</code>:</p>\n<pre><code>perl hello\n</code></pre>\n<p>From <a href=\"https://perldoc.perl.org/perlrun\" rel=\"noreferrer\"><code>perl</code> docs</a>:</p>\n<blockquote>\n<p>If the #! line does not contain the word &quot;perl&quot; nor the word &quot;indir&q...
You can use `perl`: ``` perl hello ``` From `perl` docs (https://perldoc.perl.org/perlrun): If the #! line does not contain the word "perl" nor the word "indir", the program named after the #! is executed instead of the Perl interpreter. This is slightly bizarre, but it helps people on machines that don't do #!, becaus...
# Equivalent of executing a file (with shebang line) by entering its path? **Tags:** <shell-script><executable><shebang> **Question (score 7):** Say I have a file hello: ``` #!/bin/sh echo "Hello World!" ``` Provided the executable bit is set on that file, I can execute it by entering its path on the prompt: ``` $ ....
1,438
359
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
666,165
unix.stackexchange.com
Print contents of a file only after last occurrence of a token?
<p>I have long-running programs that can restart their internal state. I want to see the log file entries only for the most recent state (to load into <code>vim</code>'s quickfix). How can I show all lines after the <em>last</em> occurrence of the string <code>STARTING SESSION</code>?</p> <p>My current solution (log fi...
I have long-running programs that can restart their internal state. I want to see the log file entries only for the most recent state (to load into `vim`'s quickfix). How can I show all lines after the last occurrence of the string `STARTING SESSION`? My current solution (log files are sometimes gigabytes long, so I ne...
8
475
2
1
1
[ "<text-processing><grep><gnu>" ]
2021-08-25T05:32:06.970
2021-08-26T10:24:08.727
21,401
null
[ { "id": 666166, "body": "<p>Reverse the file, display it until the first occurrence, and reverse the output again:</p>\n<pre><code>tac logfile.log | sed '/STARTING SESSION/q' | tac\n</code></pre>\n<p><a href=\"https://serverfault.com/q/663038/268281\"><code>tac</code> is efficient when given a regular (seek...
Reverse the file, display it until the first occurrence, and reverse the output again: ``` tac logfile.log | sed '/STARTING SESSION/q' | tac ``` `tac` is efficient when given a regular (seekable) file to process (https://serverfault.com/q/663038/268281), and since `sed` exits as soon as it sees the start line, the whol...
# Print contents of a file only after last occurrence of a token? **Tags:** <text-processing><grep><gnu> **Question (score 8):** I have long-running programs that can restart their internal state. I want to see the log file entries only for the most recent state (to load into `vim`'s quickfix). How can I show all li...
4,375
1,093
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
666,404
unix.stackexchange.com
How can I pipe a scp copy from a machine to another?
<p>Let’s say we have three machines: A, B and C.</p> <ul> <li>Machine A can't reach machine B from any network, so I can't send files between both.</li> <li>But both A and B can be reached from C (my machine).</li> </ul> <p>Today I have to copy a huge file from A to B.</p> <p>Currently I would need to copy it first fro...
Let’s say we have three machines: A, B and C. - Machine A can't reach machine B from any network, so I can't send files between both. - But both A and B can be reached from C (my machine). Today I have to copy a huge file from A to B. Currently I would need to copy it first from A to C and then from C to B. Is there a ...
5
615
2
3
1
[ "<scp>" ]
2021-08-26T18:43:47.107
2021-08-30T10:37:06.663
182,393
666,408
[ { "id": 666408, "body": "<p><code>man scp</code> writes (with my emphasis)</p>\n<blockquote>\n<p><strong><code>-3</code></strong> Copies between two remote hosts are transferred <em>through the local host</em>. Without this option the data is copied directly between the two remote hosts. [...]</p>\n</blockq...
`man scp` writes (with my emphasis) `-3` Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. [...] So what you need is a copy command that routes via your local system (I almost always include `-p`, to preserve timestamps ...
# How can I pipe a scp copy from a machine to another? **Tags:** <scp> **Question (score 5):** Let’s say we have three machines: A, B and C. - Machine A can't reach machine B from any network, so I can't send files between both. - But both A and B can be reached from C (my machine). Today I have to copy a huge file ...
1,356
339
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
666,673
unix.stackexchange.com
SSH login instead of getty with local fallback
<p>I don't know exactly how to title my question.</p> <p>Scenerio is I have a server that has a suite of TUI programs that suits my needs.</p> <p>I'd like for other users of the network to turn on something smaller like a raspi or dinosaur computer, and when it boots the user isn't presented with a getty for local logi...
I don't know exactly how to title my question. Scenerio is I have a server that has a suite of TUI programs that suits my needs. I'd like for other users of the network to turn on something smaller like a raspi or dinosaur computer, and when it boots the user isn't presented with a getty for local login as normal... th...
5
316
2
0
0
[ "<ssh>" ]
2021-08-28T21:48:27.717
2021-08-30T03:39:49.493
417,490
null
[ { "id": 666680, "body": "<p>That is indeed quite achievable: I did something very much like that in university, back in 1998 or so.</p>\n<p>Basically, you'll need to configure the <code>getty</code> process of the RasPi to call your own custom version of the <code>login</code> program instead of the standar...
That is indeed quite achievable: I did something very much like that in university, back in 1998 or so. Basically, you'll need to configure the `getty` process of the RasPi to call your own custom version of the `login` program instead of the standard `/bin/login`. That part is easy. Your custom `login` replacement can...
# SSH login instead of getty with local fallback **Tags:** <ssh> **Question (score 5):** I don't know exactly how to title my question. Scenerio is I have a server that has a suite of TUI programs that suits my needs. I'd like for other users of the network to turn on something smaller like a raspi or dinosaur compu...
3,452
863
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
666,766
unix.stackexchange.com
Is `yes | rm -r` safer than `rm -rf`?
<p>I have heard many times that issuing <code>rm -rf</code> is dangerous since users can accidentally remove the entire system. But sometimes I want to remove a directory recursively without being asked every time. I am thinking about using <code>yes | rm -r</code> instead.</p> <p>The thing I am thinking is that, is <c...
I have heard many times that issuing `rm -rf` is dangerous since users can accidentally remove the entire system. But sometimes I want to remove a directory recursively without being asked every time. I am thinking about using `yes | rm -r` instead. The thing I am thinking is that, is `yes | rm -r` safer than `rm -rf`?...
23
7,813
9
8
5
[ "<rm>" ]
2021-08-29T10:00:04.557
2021-09-01T14:44:26.810
169,459
666,810
[ { "id": 666767, "body": "<h1>Short answer</h1>\n<p><strong>No</strong>. However, I really like your creativity of piping commands together. Still, <code>yes|rm -r</code> is a nice example of UUOC (<strong>u</strong>seless <strong>u</strong>se <strong>o</strong>f <strong>c</strong>at) - an acronym (or better...
# Short answer No. However, I really like your creativity of piping commands together. Still, `yes|rm -r` is a nice example of UUOC (useless use of cat) - an acronym (or better jargon) for command line constructs that only provide a function of convenience to the user. # Long Answer I really like your question, as it c...
# Is `yes | rm -r` safer than `rm -rf`? **Tags:** <rm> **Question (score 23):** I have heard many times that issuing `rm -rf` is dangerous since users can accidentally remove the entire system. But sometimes I want to remove a directory recursively without being asked every time. I am thinking about using `yes | rm ...
12,736
3,184
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
666,931
unix.stackexchange.com
"Command not found: #" in sourced multiline command with comments
<p>In <em>foo.sh</em>, I have some commands (or functions) split to multiple lines and added comments, for readability:</p> <pre><code>#!/bin/zsh # # foo.sh: print computer information foo() { uname \ -p `# processor arch` \ -s `# os name` \ -v `# os version` } foo </code></pre> <hr /> <h5...
In foo.sh, I have some commands (or functions) split to multiple lines and added comments, for readability: ``` #!/bin/zsh # # foo.sh: print computer information foo() { uname \ -p `# processor arch` \ -s `# os name` \ -v `# os version` } foo ``` ##### What works I can run it okay: ``` $ ./foo.sh Darwin 123... (correct...
7
434
1
8
0
[ "<zsh>" ]
2021-08-30T21:06:03.630
2021-08-30T23:11:21.913
205,857
666,932
[ { "id": 666932, "body": "<p>By default, zsh only recognizes comments in scripts, not when running interactively. This should apply to sourced scripts, but in recent versions (I've reproduced this behavior in 5.8, but 5.4.2 accepts your code just fine), this also applies to some code that is parsed after loa...
By default, zsh only recognizes comments in scripts, not when running interactively. This should apply to sourced scripts, but in recent versions (I've reproduced this behavior in 5.8, but 5.4.2 accepts your code just fine), this also applies to some code that is parsed after loading, such as code inside command substi...
# "Command not found: #" in sourced multiline command with comments **Tags:** <zsh> **Question (score 7):** In foo.sh, I have some commands (or functions) split to multiple lines and added comments, for readability: ``` #!/bin/zsh # # foo.sh: print computer information foo() { uname \ -p `# processor arch` \ -s `# o...
1,975
493
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
667,101
unix.stackexchange.com
Who owns the UNIX trademark?
<p>I am currently enrolled in a course that is teaching me UNIX fundamentals, such as common commands and such. After doing some digging on UNIX, I came across the rabbit hole of legal battles over who owns UNIX, and the UNIX wars. I have done some research, but the sources are sort of dated (circa 2003 - 2004) and hav...
I am currently enrolled in a course that is teaching me UNIX fundamentals, such as common commands and such. After doing some digging on UNIX, I came across the rabbit hole of legal battles over who owns UNIX, and the UNIX wars. I have done some research, but the sources are sort of dated (circa 2003 - 2004) and have c...
41
8,220
3
10
7
[ "<historical-unix>" ]
2021-08-31T22:31:02.677
2021-09-03T12:17:09.063
489,364
null
[ { "id": 667112, "body": "<h1>TLDR</h1>\n<p>As of today, and talking about the USA, the <a href=\"https://unix.org/trademark.html\" rel=\"noreferrer\">UNIX trademark</a> is owned by <strong>The Open Group</strong> (you can see it on <a href=\"https://tsdr.uspto.gov/#caseNumber=73544900&amp;caseType=SERIAL_NO...
# TLDR As of today, and talking about the USA, the UNIX trademark (https://unix.org/trademark.html) is owned by The Open Group (you can see it on the USPTO website (https://tsdr.uspto.gov/#caseNumber=73544900&caseType=SERIAL_NO&searchType=statusSearch)) for "COMPUTER PROGRAMS, * NAMELY, TEST SUITES USED TO DETERMINE CO...
# Who owns the UNIX trademark? **Tags:** <historical-unix> **Question (score 41):** I am currently enrolled in a course that is teaching me UNIX fundamentals, such as common commands and such. After doing some digging on UNIX, I came across the rabbit hole of legal battles over who owns UNIX, and the UNIX wars. I ha...
7,990
1,997
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
667,204
unix.stackexchange.com
cp command follows symlink at target and obliterates file instead of overwriting symlink
<p>I have a symlink <code>sd/common.py -&gt; actual_file</code></p> <p>I would like to replace the symlink with a generated file, but when I do:</p> <p><code>cp /tmp/Star_Wrangler/common.py sd/common.py</code></p> <p>It copies from common.py and obliterates the actual_file instead of just copying over the symlink like ...
I have a symlink `sd/common.py -> actual_file` I would like to replace the symlink with a generated file, but when I do: `cp /tmp/Star_Wrangler/common.py sd/common.py` It copies from common.py and obliterates the actual_file instead of just copying over the symlink like I want it to. This keeps happening every time whe...
11
653
2
2
0
[ "<symlink><cp>" ]
2021-09-01T16:48:52.207
2021-10-09T20:45:54.197
350,958
667,208
[ { "id": 667208, "body": "<p>This depends on what Unix you are using.</p>\n<p>On some BSD systems (OpenBSD, FreeBSD), you will find that <code>cp -f</code> will unlink (remove) the symbolic link and replace it with the source.</p>\n<p>Using GNU <code>cp</code>, this would not have the same effect, and you wo...
This depends on what Unix you are using. On some BSD systems (OpenBSD, FreeBSD), you will find that `cp -f` will unlink (remove) the symbolic link and replace it with the source. Using GNU `cp`, this would not have the same effect, and you would need to use the long option `--remove-destination` instead. On macOS, use ...
# cp command follows symlink at target and obliterates file instead of overwriting symlink **Tags:** <symlink><cp> **Question (score 11):** I have a symlink `sd/common.py -> actual_file` I would like to replace the symlink with a generated file, but when I do: `cp /tmp/Star_Wrangler/common.py sd/common.py` It copies...
1,835
458
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
667,288
unix.stackexchange.com
checkbashisms: what's wrong with `type'?
<pre class="lang-bsh prettyprint-override"><code>#!/bin/sh foo() { echo &quot;in foo&quot; } type foo </code></pre> <p><a href="https://salsa.debian.org/debian/devscripts/-/blob/master/scripts/checkbashisms.pl" rel="noreferrer"><code>checkbashisms.pl</code></a> obviously does not like <code>type</code>, why?</p> <...
``` #!/bin/sh foo() { echo "in foo" } type foo ``` `checkbashisms.pl` (https://salsa.debian.org/debian/devscripts/-/blob/master/scripts/checkbashisms.pl) obviously does not like `type`, why? ``` $ checkbashisms.pl foo.sh possible bashism in foo.sh line 7(type): type foo ``` Is it not POSIX? But it's supported by all co...
6
932
3
1
0
[ "<shell><shell-builtin>" ]
2021-09-02T09:45:01.317
2021-09-03T16:14:14.653
26,407
667,293
[ { "id": 667293, "body": "<p><code>type</code> is <a href=\"https://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html\" rel=\"noreferrer\">part of POSIX</a>, but as part of the X/Open Systems Interfaces option (XSI). <a href=\"https://manpages.debian.org/devscripts/checkbashisms.1\" rel=\"noreferr...
`type` is part of POSIX (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html), but as part of the X/Open Systems Interfaces option (XSI). The `checkbashisms` man page (https://manpages.debian.org/devscripts/checkbashisms.1) explicitly says Note that the definition of a bashism in this context roughly e...
# checkbashisms: what's wrong with `type'? **Tags:** <shell><shell-builtin> **Question (score 6):** ``` #!/bin/sh foo() { echo "in foo" } type foo ``` `checkbashisms.pl` (https://salsa.debian.org/debian/devscripts/-/blob/master/scripts/checkbashisms.pl) obviously does not like `type`, why? ``` $ checkbashisms.pl foo...
5,411
1,352
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
667,812
unix.stackexchange.com
Backup my EFI boot entry for easy restore
<p>Giving that Windows 10 would most likely wipe my Linux EFI boot entry, See the comment after the answer <a href="https://unix.stackexchange.com/a/667659/374303">here</a>:</p> <blockquote> <p>Windows 10 will usually &quot;self-heal&quot; its firmware boot entry if you manage to get Windows booting even once. In the p...
Giving that Windows 10 would most likely wipe my Linux EFI boot entry, See the comment after the answer here (https://unix.stackexchange.com/a/667659/374303): Windows 10 will usually "self-heal" its firmware boot entry if you manage to get Windows booting even once. In the process, if there is no existing Windows boot ...
9
884
2
2
3
[ "<boot><backup><uefi><restore>" ]
2021-09-05T23:18:02.760
2021-09-07T02:39:42.613
374,303
667,817
[ { "id": 667817, "body": "<p>It's easy enough to recreate a boot entry from scratch once you know how... and have the <code>efibootmgr</code> tool at hand, of course.</p>\n<blockquote>\n<p><code>Boot0000* debian HD(13,GPT,007a058a-8e5e-45df-8d97-6575b66b5355,0x1afa9000,0x113000)/File(\\EFI\\debian\\gr...
It's easy enough to recreate a boot entry from scratch once you know how... and have the `efibootmgr` tool at hand, of course. `Boot0000* debian HD(13,GPT,007a058a-8e5e-45df-8d97-6575b66b5355,0x1afa9000,0x113000)/File(\EFI\debian\grubx64.efi)` The `007a058a-8e5e-45df-8d97-6575b66b5355` is the PARTUUID of the ESP partit...
# Backup my EFI boot entry for easy restore **Tags:** <boot><backup><uefi><restore> **Question (score 9):** Giving that Windows 10 would most likely wipe my Linux EFI boot entry, See the comment after the answer here (https://unix.stackexchange.com/a/667659/374303): Windows 10 will usually "self-heal" its firmware b...
3,967
991
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
667,940
unix.stackexchange.com
How to install docker-engine in macOS without docker desktop?
<p>Recently Docker announced that Docker Desktop would cease to be free for some kinds of users. See announcement in <a href="https://www.docker.com/blog/updating-product-subscriptions/" rel="noreferrer">blog post</a>.</p> <p>I don't need any of the features that are exclusive to Docker Desktop®. I have used docker in ...
Recently Docker announced that Docker Desktop would cease to be free for some kinds of users. See announcement in blog post (https://www.docker.com/blog/updating-product-subscriptions/). I don't need any of the features that are exclusive to Docker Desktop®. I have used docker in a laptop with debian on it and that ver...
10
4,416
4
2
2
[ "<docker><macos>" ]
2021-09-06T21:27:30.397
2021-11-05T07:57:23.477
168,588
null
[ { "id": 672202, "body": "<p>There is an alternative to docker, it is <a href=\"https://podman.io\" rel=\"noreferrer\">podman</a>.</p>\n<ol>\n<li>Install: <code>brew install podman</code></li>\n<li>Download and prepare the VM: <code>podman machine init</code></li>\n<li>Turn on the VM: <code>podman machine st...
There is an alternative to docker, it is podman (https://podman.io). - Install: `brew install podman` - Download and prepare the VM: `podman machine init` - Turn on the VM: `podman machine start` - Uses as a docker: `podman run -d -p 8000:80 nginx` - Verify container: `podman ps` - Interact with it: `curl localhost:800...
# How to install docker-engine in macOS without docker desktop? **Tags:** <docker><macos> **Question (score 10):** Recently Docker announced that Docker Desktop would cease to be free for some kinds of users. See announcement in blog post (https://www.docker.com/blog/updating-product-subscriptions/). I don't need an...
2,229
557
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
667,998
unix.stackexchange.com
Can not execute "Hello, World!" C program with user other than 'root'
<p>I have written a <a href="https://en.wikipedia.org/wiki/%22Hello,_World!%22_program" rel="noreferrer">&quot;Hello, World!&quot;</a> C file <code>myCFile.c</code> on an x86 embedded board on the Debian OS.</p> <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt; int main() { printf(&quot;hello\n&...
I have written a "Hello, World!" (https://en.wikipedia.org/wiki/%22Hello,_World!%22_program) C file `myCFile.c` on an x86 embedded board on the Debian OS. ``` #include int main() { printf("hello\n") } ``` I compile the program: `gcc myCFile.c` However, ``` tester@localhost:~/test$ ./a.out -bash: ./a.out: Permission den...
10
2,253
1
3
2
[ "<permissions><filesystems><gcc><yocto>" ]
2021-09-07T08:51:31.513
2021-09-08T08:26:58.567
456,306
668,001
[ { "id": 668001, "body": "<blockquote>\n<p>Is it something related NOEXEC flag?</p>\n</blockquote>\n<p>Yes; presumably <code>/home</code> is mounted <code>noexec</code>, which means you can’t run binaries there. <code>/tmp/user/1000</code> works because it’s a on different file system, as is <code>/root</cod...
Is it something related NOEXEC flag? Yes; presumably `/home` is mounted `noexec`, which means you can’t run binaries there. `/tmp/user/1000` works because it’s a on different file system, as is `/root` (`root`’s home directory). In your case, ``` mount -o remount,exec /persistent ``` should allow you to execute files i...
# Can not execute "Hello, World!" C program with user other than 'root' **Tags:** <permissions><filesystems><gcc><yocto> **Question (score 10):** I have written a "Hello, World!" (https://en.wikipedia.org/wiki/%22Hello,_World!%22_program) C file `myCFile.c` on an x86 embedded board on the Debian OS. ``` #include int...
1,846
461
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
668,262
unix.stackexchange.com
CentOS 7: What is /bin/sh? It looks like Bash but seems to be something else
<p>When I run a Centos 7 Docker Image like this</p> <pre><code>docker run -it centos:7 bash </code></pre> <p>Running something which is uses <em>Process Substitution</em> is fine (as expected, as Bash supports Process Substitution since the beginning of time - Bash 1.4.x actually).</p> <p>For example:</p> <pre><code>wh...
When I run a Centos 7 Docker Image like this ``` docker run -it centos:7 bash ``` Running something which is uses Process Substitution is fine (as expected, as Bash supports Process Substitution since the beginning of time - Bash 1.4.x actually). For example: ``` while IFS= read -r test; do echo $test; done /bin/sh the...
17
3,107
4
8
3
[ "<bash><shell><centos><process-substitution>" ]
2021-09-09T06:05:06.667
2021-09-09T10:59:27.883
2,726
668,265
[ { "id": 668265, "body": "<p>Yes, <code>bash</code>, when called as <code>sh</code>, runs in POSIX mode, disabling all its bash only features. From the manual - <a href=\"https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Bash-Startup-Files\" rel=\"noreferrer\">Invoked with name sh</a...
Yes, `bash`, when called as `sh`, runs in POSIX mode, disabling all its bash only features. From the manual - Invoked with name sh (https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Bash-Startup-Files) If Bash is invoked with the name sh, it tries to mimic the startup behavior of historical ver...
# CentOS 7: What is /bin/sh? It looks like Bash but seems to be something else **Tags:** <bash><shell><centos><process-substitution> **Question (score 17):** When I run a Centos 7 Docker Image like this ``` docker run -it centos:7 bash ``` Running something which is uses Process Substitution is fine (as expected, as...
4,142
1,035
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
668,280
unix.stackexchange.com
Delete lines matching pattern in file1 and save these deleted lines to file2
<p>I have <code>file1</code>, and I need to delete lines matching a pattern. But I would like to save these deleted lines in another <code>file2</code>.</p> <pre><code>sed '/zz/!d' file1 &gt; file2 sed -i '/zz/d' file1 </code></pre> <p>Is there a way to combine these commands into one ?</p> <p>Or is there a more ele...
I have `file1`, and I need to delete lines matching a pattern. But I would like to save these deleted lines in another `file2`. ``` sed '/zz/!d' file1 > file2 sed -i '/zz/d' file1 ``` Is there a way to combine these commands into one ? Or is there a more elegant way to do it?
8
1,245
7
1
2
[ "<text-processing><sed>" ]
2021-09-09T08:15:14.467
2021-09-09T09:51:10.407
155,832
668,286
[ { "id": 668286, "body": "<p>Checked at GNU Sed:</p>\n<pre><code>sed -ni '/zz/!{p;b};w file2' file1\n</code></pre>\n<p>The flags must go in that order <code>-ni</code>.</p>\n<p>Explanation:\nWe do not stop the script with the <code>d</code> command, but set the <code>-n</code> flag (silent) and write lines t...
Checked at GNU Sed: ``` sed -ni '/zz/!{p;b};w file2' file1 ``` The flags must go in that order `-ni`. Explanation: We do not stop the script with the `d` command, but set the `-n` flag (silent) and write lines that do not match the template using the `p` command (Print the current pattern space) and jump with `b` to th...
# Delete lines matching pattern in file1 and save these deleted lines to file2 **Tags:** <text-processing><sed> **Question (score 8):** I have `file1`, and I need to delete lines matching a pattern. But I would like to save these deleted lines in another `file2`. ``` sed '/zz/!d' file1 > file2 sed -i '/zz/d' file1 `...
2,752
688
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
668,320
unix.stackexchange.com
How can I tell if a Linux block device is trimmable or not?
<p><code>fstrim</code> requires the Linux block device to be mounted, and it is not very verbose. <code>blkdiscard</code> could tell, but also that would require a write operation.</p> <p>Can I somehow tell if a block device supports trimming/discarding, without actually trying to trim/discard something on it?</p>
`fstrim` requires the Linux block device to be mounted, and it is not very verbose. `blkdiscard` could tell, but also that would require a write operation. Can I somehow tell if a block device supports trimming/discarding, without actually trying to trim/discard something on it?
7
1,094
3
2
1
[ "<linux><block-device><trim>" ]
2021-09-09T13:46:27.437
2021-09-10T09:17:35.417
52,236
668,323
[ { "id": 668323, "body": "<p>You can check the device’s maximum discard sizes, <em>e.g.</em></p>\n<pre><code>$ cat /sys/block/X/queue/discard_max_bytes\n</code></pre>\n<p>(replacing <code>X</code> as appropriate).</p>\n<p>If this shows a value greater than 0, the device supports discards. Strictly speaking, ...
You can check the device’s maximum discard sizes, e.g. ``` $ cat /sys/block/X/queue/discard_max_bytes ``` (replacing `X` as appropriate). If this shows a value greater than 0, the device supports discards. Strictly speaking, `discard_max_hw_bytes` (https://www.kernel.org/doc/html/latest/block/queue-sysfs.html#discard-m...
# How can I tell if a Linux block device is trimmable or not? **Tags:** <linux><block-device><trim> **Question (score 7):** `fstrim` requires the Linux block device to be mounted, and it is not very verbose. `blkdiscard` could tell, but also that would require a write operation. Can I somehow tell if a block device ...
1,989
497
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
668,693
unix.stackexchange.com
Can I skip syscalls made by the dynamic loader in strace?
<p>When I use <code>strace</code> to examine a program, I often have a hard time finding where the syscalls from the dynamic loader end and the syscalls from the program begin.</p> <p>The output from <code>strace ./hello</code> where <code>hello</code> a simple hello world C program is 36 lines. Here's a sample:</p> <p...
When I use `strace` to examine a program, I often have a hard time finding where the syscalls from the dynamic loader end and the syscalls from the program begin. The output from `strace ./hello` where `hello` a simple hello world C program is 36 lines. Here's a sample: ``` execve("./hello", ["./hello"], 0x7fffb38f4a30...
11
572
1
1
1
[ "<linux><strace><elf>" ]
2021-09-12T16:52:06.223
2021-09-12T17:53:37.740
434,570
668,709
[ { "id": 668709, "body": "<p>On x86_64 the main program starts just after <code>arch_prctl(ARCH_SET_FS)</code> and a couple of <code>mprotect()</code>s, so you can <code>sed 1,/ARCH_SET_FS/d</code> on the <code>strace</code>'s output.</p>\n<p>A trick you can use on all platforms is to <code>LD_PRELOAD</code>...
On x86_64 the main program starts just after `arch_prctl(ARCH_SET_FS)` and a couple of `mprotect()`s, so you can `sed 1,/ARCH_SET_FS/d` on the `strace`'s output. A trick you can use on all platforms is to `LD_PRELOAD` a small library which overides `__libc_start_main()` and does a pointless system call like `write(-1, ...
# Can I skip syscalls made by the dynamic loader in strace? **Tags:** <linux><strace><elf> **Question (score 11):** When I use `strace` to examine a program, I often have a hard time finding where the syscalls from the dynamic loader end and the syscalls from the program begin. The output from `strace ./hello` where...
2,458
614
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
668,715
unix.stackexchange.com
How do I diagnose random UI slowness and slow ssh connection initiation for several minutes after a reboot?
<p>The boot sequence opens up Kodi in full screen. That comes up fine. But when I try to initiate an <code>ssh</code> connection it will often just simply time out. This lasts for about 10 minutes after a reboot. There's also a lot of UI slowness: a window drag will take a few seconds to respond. Checked <code>top</cod...
The boot sequence opens up Kodi in full screen. That comes up fine. But when I try to initiate an `ssh` connection it will often just simply time out. This lasts for about 10 minutes after a reboot. There's also a lot of UI slowness: a window drag will take a few seconds to respond. Checked `top`, CPU is never above 20...
6
799
2
0
0
[ "<performance>" ]
2021-09-12T19:34:18.203
2021-09-14T21:28:11.450
29,679
null
[ { "id": 668718, "body": "<p>(You've solved your specific problem, but I'm posting some general advice for people encountering a similar problem.)</p>\n<p>On many systems, if you turn your computer off at night and boot it or wake it up from suspension in the morning, it'll run various daily jobs, via <a hre...
(You've solved your specific problem, but I'm posting some general advice for people encountering a similar problem.) On many systems, if you turn your computer off at night and boot it or wake it up from suspension in the morning, it'll run various daily jobs, via anacron (https://en.wikipedia.org/wiki/Anacron). This ...
# How do I diagnose random UI slowness and slow ssh connection initiation for several minutes after a reboot? **Tags:** <performance> **Question (score 6):** The boot sequence opens up Kodi in full screen. That comes up fine. But when I try to initiate an `ssh` connection it will often just simply time out. This las...
2,677
669
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
668,793
unix.stackexchange.com
sed : have a range finishing with the last occurrence of a pattern (greedy range)
<p>Take the following file :</p> <pre><code>$ cat f1 stu vwx yza uvw xyz abc abc def ghi def ghi jkl ghi jkl mno jkl mno pqr mno pqr stu pqr stu vwx stu vwx yza </code></pre> <p>To print all lines from the first one containing <code>abc</code> to <strong>the first one</strong> containing <code>mno</code> with GNU <code...
Take the following file : ``` $ cat f1 stu vwx yza uvw xyz abc abc def ghi def ghi jkl ghi jkl mno jkl mno pqr mno pqr stu pqr stu vwx stu vwx yza ``` To print all lines from the first one containing `abc` to the first one containing `mno` with GNU `sed` : ``` $ sed -n '/abc/,/mno/p' f1 uvw xyz abc abc def ghi def ghi ...
9
875
10
4
1
[ "<text-processing><awk><sed><ed>" ]
2021-09-13T09:54:21.857
2021-09-16T07:37:44.633
152,418
668,807
[ { "id": 668800, "body": "<p>You could use <code>awk</code> if it is an option. You could mark the lines for pattern start and pattern stop and print those lines in one-pass of the file (involves storing lines starting from the first line containing <code>abc</code> till the last line in a buffer)</p>\n<pre ...
You could use `awk` if it is an option. You could mark the lines for pattern start and pattern stop and print those lines in one-pass of the file (involves storing lines starting from the first line containing `abc` till the last line in a buffer) ``` awk '/abc/ && !start { start = NR } /mno/ { stop = NR } start { line...
# sed : have a range finishing with the last occurrence of a pattern (greedy range) **Tags:** <text-processing><awk><sed><ed> **Question (score 9):** Take the following file : ``` $ cat f1 stu vwx yza uvw xyz abc abc def ghi def ghi jkl ghi jkl mno jkl mno pqr mno pqr stu pqr stu vwx stu vwx yza ``` To print all lin...
5,007
1,251
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
668,844
unix.stackexchange.com
Why is the Canadian Cross used for cross-compilation in Linux From Scratch?
<p>I'm going through the <a href="https://www.linuxfromscratch.org/lfs/downloads/11.0/LFS-BOOK-11.0.pdf" rel="noreferrer">Linux From Scratch 11.0 book</a>. In <a href="https://www.linuxfromscratch.org/lfs/view/11.0/partintro/toolchaintechnotes.html#cross-compile" rel="noreferrer"><em>III. Building the LFS Cross Toolcha...
I'm going through the Linux From Scratch 11.0 book (https://www.linuxfromscratch.org/lfs/downloads/11.0/LFS-BOOK-11.0.pdf). In III. Building the LFS Cross Toolchain and Temporary Tools, ii. Toolchain Technical Notes (https://www.linuxfromscratch.org/lfs/view/11.0/partintro/toolchaintechnotes.html#cross-compile), there ...
7
2,269
3
0
1
[ "<cross-compilation>" ]
2021-09-13T16:11:08.577
2021-09-14T02:43:30.890
345,969
668,887
[ { "id": 668847, "body": "<p>Scenario described is this</p>\n<ul>\n<li>Machine A is slow and has a compiler</li>\n<li>Machine B is fast, but has no compiler</li>\n<li>Machine C is the target but it is slow, and has no compiler</li>\n</ul>\n<p>You could build all the binaries for C on A, but it would take a l...
Scenario described is this - Machine A is slow and has a compiler - Machine B is fast, but has no compiler - Machine C is the target but it is slow, and has no compiler You could build all the binaries for C on A, but it would take a long time because machine A is slow. The author argues that it is worth taking a small...
# Why is the Canadian Cross used for cross-compilation in Linux From Scratch? **Tags:** <cross-compilation> **Question (score 7):** I'm going through the Linux From Scratch 11.0 book (https://www.linuxfromscratch.org/lfs/downloads/11.0/LFS-BOOK-11.0.pdf). In III. Building the LFS Cross Toolchain and Temporary Tools,...
4,181
1,045
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,062
unix.stackexchange.com
Use awk to delete everything after the ","
<p>I have a variable, <code>var</code>, that contains:</p> <pre><code>XXXX YY ZZZZZ\n aaa,bbb,ccc </code></pre> <p>All I want is <code>aaa</code> in the second line. I tried:</p> <pre><code>out=$(echo &quot;$var&quot; | awk 'NR==2{sub(&quot;,.*&quot;,&quot;&quot;)}' ) </code></pre> <p>but I get no output. I tried using...
I have a variable, `var`, that contains: ``` XXXX YY ZZZZZ\n aaa,bbb,ccc ``` All I want is `aaa` in the second line. I tried: ``` out=$(echo "$var" | awk 'NR==2{sub(",.*","")}' ) ``` but I get no output. I tried using `,` as the FS but I can't get the syntax right. I really want to learn awk/regex syntax. I want to use...
6
999
8
3
0
[ "<bash><text-processing><awk><regular-expression>" ]
2021-09-15T07:20:24.457
2021-09-17T13:23:38.020
475,899
null
[ { "id": 669066, "body": "<p>You don't want regexes there. The entire point of <code>awk</code> is to automatically split a line into fields, so just set the field separator to <code>,</code> and print the first field of the second line:</p>\n<pre><code>$ printf '%s' &quot;$var&quot; | awk -F, 'NR==2{print $...
You don't want regexes there. The entire point of `awk` is to automatically split a line into fields, so just set the field separator to `,` and print the first field of the second line: ``` $ printf '%s' "$var" | awk -F, 'NR==2{print $1}' aaa ``` Or, if your shell supports `<<<`: ``` $ awk -F, 'NR==2{print $1}' <<<"$v...
# Use awk to delete everything after the "," **Tags:** <bash><text-processing><awk><regular-expression> **Question (score 6):** I have a variable, `var`, that contains: ``` XXXX YY ZZZZZ\n aaa,bbb,ccc ``` All I want is `aaa` in the second line. I tried: ``` out=$(echo "$var" | awk 'NR==2{sub(",.*","")}' ) ``` but I ...
3,765
941
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,201
unix.stackexchange.com
What's the best file system for many small files?
<p>I have a Debian 10 server with a 2TB drive where I want to store over 120 million small files. If I use ext4 I run out of inodes.</p> <p>What file system should I use?</p> <p>I've been reading about reiserfs and reiser4, but I'm not sure if either of them are still supported.</p> <p>Is there a file system with a bu...
I have a Debian 10 server with a 2TB drive where I want to store over 120 million small files. If I use ext4 I run out of inodes. What file system should I use? I've been reading about reiserfs and reiser4, but I'm not sure if either of them are still supported. Is there a file system with a built Debian package that I...
5
150
2
3
0
[ "<filesystems><reiserfs>" ]
2021-09-15T21:35:44.913
2021-09-16T22:20:48.457
492,068
669,204
[ { "id": 669204, "body": "<p>Assuming you want to optimise the usage of disk space (not only inode count and perhaps access times):</p>\n<p>You may want a file system with <a href=\"https://en.wikipedia.org/wiki/Block_suballocation\" rel=\"nofollow noreferrer\">block suballocation / tail merging</a> so that ...
Assuming you want to optimise the usage of disk space (not only inode count and perhaps access times): You may want a file system with block suballocation / tail merging (https://en.wikipedia.org/wiki/Block_suballocation) so that small data are merged into one allocation unit ("cluster") on the physical disk. Also, dep...
# What's the best file system for many small files? **Tags:** <filesystems><reiserfs> **Question (score 5):** I have a Debian 10 server with a 2TB drive where I want to store over 120 million small files. If I use ext4 I run out of inodes. What file system should I use? I've been reading about reiserfs and reiser4, ...
2,891
722
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,258
unix.stackexchange.com
How to make a systemd-timer depend on internet connectivity?
<p>I'm using <code>systemd-timer</code> to periodically run a script which consumes a webservice.<br /> Problem is, upon system resume or wake-up, internet connectivity would not get started right away but the timer gets fired and hence the script returns error (If the service waits for a couple of seconds, the script ...
I'm using `systemd-timer` to periodically run a script which consumes a webservice. Problem is, upon system resume or wake-up, internet connectivity would not get started right away but the timer gets fired and hence the script returns error (If the service waits for a couple of seconds, the script would run correctly ...
5
293
1
2
0
[ "<systemd><network-interface><services><systemd-timer><connectivity>" ]
2021-09-16T08:58:28.313
2021-09-16T10:36:22.783
306,382
669,271
[ { "id": 669271, "body": "<p>Add <code>After=network-online.target</code> to the <code>[Unit]</code> section of the timer.</p>\n<p><strong>Explanation:</strong></p>\n<p>Timers do accept all the relative ordering commands in the <code>[Unit]</code> section that are known for services. In fact both the <code>[...
Add `After=network-online.target` to the `[Unit]` section of the timer. Explanation: Timers do accept all the relative ordering commands in the `[Unit]` section that are known for services. In fact both the `[Unit]` and `[Install]` sections are identical for timers and services. Form the official manuals (https://www.f...
# How to make a systemd-timer depend on internet connectivity? **Tags:** <systemd><network-interface><services><systemd-timer><connectivity> **Question (score 5):** I'm using `systemd-timer` to periodically run a script which consumes a webservice. Problem is, upon system resume or wake-up, internet connectivity wou...
2,728
682
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,370
unix.stackexchange.com
Is there a command that's equivalent to physically unplugging a usb device?
<p>I'm doing some tests involving data corruption from unsafely removing a usb drive, but I need a way to consistently remove the drive at a specific time. Is there a command that's equivalent to physically yanking the drive out without flushing any buffers or caches?</p>
I'm doing some tests involving data corruption from unsafely removing a usb drive, but I need a way to consistently remove the drive at a specific time. Is there a command that's equivalent to physically yanking the drive out without flushing any buffers or caches?
5
691
3
3
0
[ "<usb><udev>" ]
2021-09-17T00:10:56.067
2021-09-17T22:04:53.143
303,809
null
[ { "id": 669373, "body": "<p>Some (but few) USB hubs have hardware support for port power control. If you're lucky enough to have one that implements that feature, then you could power off an individual port to mimic removing the device that is plugged into that port.</p>\n<p>See the follow repo for the sou...
Some (but few) USB hubs have hardware support for port power control. If you're lucky enough to have one that implements that feature, then you could power off an individual port to mimic removing the device that is plugged into that port. See the follow repo for the source code for a program that would enable you to c...
# Is there a command that's equivalent to physically unplugging a usb device? **Tags:** <usb><udev> **Question (score 5):** I'm doing some tests involving data corruption from unsafely removing a usb drive, but I need a way to consistently remove the drive at a specific time. Is there a command that's equivalent to ...
1,804
451
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,449
unix.stackexchange.com
Using wildcards to elegantly convert thousands of epub files to mobi
<p>I am executing the below command for 1000 files:</p> <pre><code>ebook-convert &lt;name-of-first-file&gt;.epub &lt;name-of-first-file&gt;.mobi ebook-convert &lt;name-of-second-file&gt;.epub &lt;name-of-second-file&gt;.mobi </code></pre> <p>Apparently, instead of manually doing this for 1000 files, one could write a b...
I am executing the below command for 1000 files: ``` ebook-convert .epub .mobi ebook-convert .epub .mobi ``` Apparently, instead of manually doing this for 1000 files, one could write a bash script for the job. I was wondering if there is an easier way to do something like this in Linux though, a small command that wou...
8
1,174
5
5
4
[ "<scripting><wildcards>" ]
2021-09-17T12:44:16.087
2021-09-19T12:47:33.463
433,400
669,450
[ { "id": 669450, "body": "<p>You can’t do it directly with wildcards, but a <code>for</code> loop can get you there:</p>\n<pre><code>for epub in ./*.epub; do ebook-convert &quot;${epub}&quot; &quot;${epub%.epub}.mobi&quot;; done\n</code></pre>\n<p><a href=\"https://unix.stackexchange.com/a/669451/86440\">Zsh...
You can’t do it directly with wildcards, but a `for` loop can get you there: ``` for epub in ./*.epub; do ebook-convert "${epub}" "${epub%.epub}.mobi"; done ``` Zsh supports a more elegant form of this loop (https://unix.stackexchange.com/a/669451/86440). Instead of a shell script, if your file names don’t contain whit...
# Using wildcards to elegantly convert thousands of epub files to mobi **Tags:** <scripting><wildcards> **Question (score 8):** I am executing the below command for 1000 files: ``` ebook-convert .epub .mobi ebook-convert .epub .mobi ``` Apparently, instead of manually doing this for 1000 files, one could write a bas...
7,523
1,880
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,469
unix.stackexchange.com
Where is the main function in a shell script?
<p>I am using the FUNCNAME array variable that gives us various executing functions' name. While using it, I came across <code>main</code> function inside <code>${FUNCNAME[max_ind]}</code>.</p> <p>Where is this <code>main</code> function defined in our shell script? What code is written inside <code>main</code> and how...
I am using the FUNCNAME array variable that gives us various executing functions' name. While using it, I came across `main` function inside `${FUNCNAME[max_ind]}`. Where is this `main` function defined in our shell script? What code is written inside `main` and how can I use it? Basically all the information of this `...
7
638
1
0
3
[ "<bash><shell-script><shell>" ]
2021-09-17T14:56:14.347
2021-09-19T09:07:17.930
492,758
null
[ { "id": 669472, "body": "<p>It's the main level of the shell script.</p>\n<p><code>FUNCNAME</code> itself seems specific to Bash, and its man page says this:</p>\n<blockquote>\n<p>An array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 ...
It's the main level of the shell script. `FUNCNAME` itself seems specific to Bash, and its man page says this: An array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The bottom-most element (the...
# Where is the main function in a shell script? **Tags:** <bash><shell-script><shell> **Question (score 7):** I am using the FUNCNAME array variable that gives us various executing functions' name. While using it, I came across `main` function inside `${FUNCNAME[max_ind]}`. Where is this `main` function defined in o...
1,965
491
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,543
unix.stackexchange.com
On what UNIX-like system / filesystem is the st_blocks field returned by stat() not a number of 512-byte units?
<p>I always assumed the <code>st_blocks</code> field returned by <code>stat()</code>/<code>lstat()</code>... system calls and which <code>du</code> uses to get the disk usage of files was expressed in 512 bytes units.</p> <p>Checking the <a href="https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html...
I always assumed the `st_blocks` field returned by `stat()`/`lstat()`... system calls and which `du` uses to get the disk usage of files was expressed in 512 bytes units. Checking the POSIX specification (https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html), I now see POSIX makes no guarantee for t...
8
443
1
0
0
[ "<stat><portability><api>" ]
2021-09-18T07:02:17.107
2021-09-18T08:44:40.233
22,565
null
[ { "id": 669545, "body": "<p><code>st_blksize</code> is called &quot;the optimum I/O size&quot; and unrelated to the units used for <code>st_blocks</code>. The optimum I/O size of course is filesystem specific. This is a result from the <code>fast filesystem</code> development from Berlekey in 1981/1982. Bef...
`st_blksize` is called "the optimum I/O size" and unrelated to the units used for `st_blocks`. The optimum I/O size of course is filesystem specific. This is a result from the `fast filesystem` development from Berlekey in 1981/1982. Before, there was no optimum block size in the available filesystem `st_blocks` is exp...
# On what UNIX-like system / filesystem is the st_blocks field returned by stat() not a number of 512-byte units? **Tags:** <stat><portability><api> **Question (score 8):** I always assumed the `st_blocks` field returned by `stat()`/`lstat()`... system calls and which `du` uses to get the disk usage of files was exp...
2,473
618
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,669
unix.stackexchange.com
How to run a script every 64 hours?
<p>I need to run a script every 64 hours. I couldn't find the answer with <code>cron</code>. Is it possible with it, or should I use a loop in a shell script?</p>
I need to run a script every 64 hours. I couldn't find the answer with `cron`. Is it possible with it, or should I use a loop in a shell script?
24
6,275
5
6
8
[ "<scripting><cron>" ]
2021-09-19T09:33:48.933
2021-09-22T14:54:46.240
239,796
669,678
[ { "id": 669716, "body": "<p>Just run every hour and check that the number of hours since some arbitrary instant (for instance, instant 0 of the Unix epoch time) is a multiple of 64:</p>\n<pre><code>0 * * * * t=$(date +\\%s); [ &quot;$(( (t / 3600) \\% 64 ))&quot; -eq 0 ] &amp;&amp; your-command\n</code></pr...
Just run every hour and check that the number of hours since some arbitrary instant (for instance, instant 0 of the Unix epoch time) is a multiple of 64: ``` 0 * * * * t=$(date +\%s); [ "$(( (t / 3600) \% 64 ))" -eq 0 ] && your-command ```
# How to run a script every 64 hours? **Tags:** <scripting><cron> **Question (score 24):** I need to run a script every 64 hours. I couldn't find the answer with `cron`. Is it possible with it, or should I use a loop in a shell script? ### Answer (score 48) Just run every hour and check that the number of hours sin...
4,040
1,010
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,812
unix.stackexchange.com
When is swap file harmful?
<p>In discussions about swap files (&quot;should I create one?&quot;) I often see an obscure mention along the lines &quot;in certain situations swap file can do more harm than good&quot;. That comes up often in conjunction with &quot;if you have X GB of RAM or more you don't need a swap&quot;, usually backed by credib...
In discussions about swap files ("should I create one?") I often see an obscure mention along the lines "in certain situations swap file can do more harm than good". That comes up often in conjunction with "if you have X GB of RAM or more you don't need a swap", usually backed by credible arguments. Then there are obvi...
20
5,504
9
20
4
[ "<swap>" ]
2021-09-20T11:07:14.647
2021-09-20T12:06:04.483
90,878
null
[ { "id": 669825, "body": "<p>Swap can be bad in that it may make some failure cases last <em>longer</em>. Consider a situation where some process starts using excessive amounts of memory, due to a bug or a misconfiguration or other such reason. If there's no swap, it'll eventually run the system out of memor...
Swap can be bad in that it may make some failure cases last longer. Consider a situation where some process starts using excessive amounts of memory, due to a bug or a misconfiguration or other such reason. If there's no swap, it'll eventually run the system out of memory, causing the OS to resolve the issue by eventua...
# When is swap file harmful? **Tags:** <swap> **Question (score 20):** In discussions about swap files ("should I create one?") I often see an obscure mention along the lines "in certain situations swap file can do more harm than good". That comes up often in conjunction with "if you have X GB of RAM or more you don...
9,178
2,294
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,926
unix.stackexchange.com
No temperature reading on Ryzen 5700G?
<p>I've built a new computer with a AMD Ryzen 5700G and to my surprise, no sensor information is picked up whatsoever. I thought perhaps the new AMD chips would not yet be recognized by Linux, but the docs say otherwise.</p> <p>Here's <code>sudo sensors-detect</code>:</p> <pre><code># sensors-detect version 3.6.0+git #...
I've built a new computer with a AMD Ryzen 5700G and to my surprise, no sensor information is picked up whatsoever. I thought perhaps the new AMD chips would not yet be recognized by Linux, but the docs say otherwise. Here's `sudo sensors-detect`: ``` # sensors-detect version 3.6.0+git # System: Gigabyte Technology Co....
5
676
1
3
1
[ "<kernel-modules><amd><sensors>" ]
2021-09-21T07:51:11.773
2021-09-21T16:57:41.983
41,321
669,928
[ { "id": 669928, "body": "<p>The driver in Linux 5.14 doesn't support these APUs yet, it will be available in 5.15 but you can grab it now and compile in 5.14 (must be safe).</p>\n", "body_md": "The driver in Linux 5.14 doesn't support these APUs yet, it will be available in 5.15 but you can grab it now ...
The driver in Linux 5.14 doesn't support these APUs yet, it will be available in 5.15 but you can grab it now and compile in 5.14 (must be safe).
# No temperature reading on Ryzen 5700G? **Tags:** <kernel-modules><amd><sensors> **Question (score 5):** I've built a new computer with a AMD Ryzen 5700G and to my surprise, no sensor information is picked up whatsoever. I thought perhaps the new AMD chips would not yet be recognized by Linux, but the docs say othe...
2,436
609
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
669,947
unix.stackexchange.com
Compact way to generate variable with 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
<p>A <code>bash</code> script is using a variable <code>Q</code> for some purpose (outside the scope of this question):</p> <pre><code>Q=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ </code></pre> <p>As this script is used in an environment where each byte counts, this is waste. But some workaround like</p> <pre><code>Q=0$(seq ...
A `bash` script is using a variable `Q` for some purpose (outside the scope of this question): ``` Q=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ``` As this script is used in an environment where each byte counts, this is waste. But some workaround like ``` Q=0$(seq -s "" 9)$(echo {A..Z}|tr -d " ") ``` (for `C` locale) is eve...
8
2,735
4
11
1
[ "<bash><shell-script><text-processing>" ]
2021-09-21T10:19:35.737
2021-09-22T10:49:35.413
216,004
669,951
[ { "id": 669951, "body": "<p>For any shell capable of brace expansion:</p>\n<p>Using <code>printf</code>:</p>\n<pre><code>$ printf %s {0..9} {A..Z}\n0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\n</code></pre>\n<p>--&gt;</p>\n<pre><code>Q=$(printf %s {0..9} {A..Z})\n</code></pre>\n<p>Backticks instead of <code>$()</c...
For any shell capable of brace expansion: Using `printf`: ``` $ printf %s {0..9} {A..Z} 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ``` --> ``` Q=$(printf %s {0..9} {A..Z}) ``` Backticks instead of `$()` saves one byte. For Bash specifically, `printf -v var` to printf into a variable is nice but no shorter than backticks. ```...
# Compact way to generate variable with 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ **Tags:** <bash><shell-script><text-processing> **Question (score 8):** A `bash` script is using a variable `Q` for some purpose (outside the scope of this question): ``` Q=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ``` As this script is used in ...
2,048
512
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
670,154
unix.stackexchange.com
Why doesn't bash interpret the asterisk character when used with xargs command?
<p>As far as I understand, the asterisk character <code>*</code> has a special meaning in Bash and in order to print the literal character we need to either escape it (<code>\*</code>) or quote it (<code>&quot;*&quot;</code> or <code>'*'</code>.</p> <p>However, when I have tried the following:</p> <pre><code>$ seq 3 | ...
As far as I understand, the asterisk character `*` has a special meaning in Bash and in order to print the literal character we need to either escape it (`\*`) or quote it (`"*"` or `'*'`. However, when I have tried the following: ``` $ seq 3 | xargs -I * echo * 1 2 3 ``` Why doesn't Bash interpret `*` in the example a...
8
604
1
0
0
[ "<bash><wildcards>" ]
2021-09-22T16:55:58.340
2021-09-23T14:04:19.447
493,431
670,156
[ { "id": 670156, "body": "<p>Bash <em>did</em> expand the star in your first example.</p>\n<p>Assuming that the current directory contains only one file, <code>main.py</code>,\nhere is what happened:</p>\n<pre class=\"lang-bsh prettyprint-override\"><code>$ seq 3 | xargs -I * echo *\n# Expands to:\n$ seq 3 ...
Bash did expand the star in your first example. Assuming that the current directory contains only one file, `main.py`, here is what happened: ``` $ seq 3 | xargs -I * echo * # Expands to: $ seq 3 | xargs -I main.py echo main.py ``` This asks to do `echo main.py` on each input, replacing `main.py` with that input (becau...
# Why doesn't bash interpret the asterisk character when used with xargs command? **Tags:** <bash><wildcards> **Question (score 8):** As far as I understand, the asterisk character `*` has a special meaning in Bash and in order to print the literal character we need to either escape it (`\*`) or quote it (`"*"` or `...
3,006
751
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
670,284
unix.stackexchange.com
awk not working on piped output from sed
<p>I have a log file which roughly looks like this:</p> <pre><code>Sep 23 10:28:26 node kernel: em0: device is going DOWN Sep 23 10:28:26 node kernel: em0: device is going UP Sep 23 10:29:14 node cdsmon: /tmp/instance0 ; core dumped Sep 23 10:29:14 node cdsmon: /tmp/instance0 ; core dumped Sep 23 10:28:26 node kernel: ...
I have a log file which roughly looks like this: ``` Sep 23 10:28:26 node kernel: em0: device is going DOWN Sep 23 10:28:26 node kernel: em0: device is going UP Sep 23 10:29:14 node cdsmon: /tmp/instance0 ; core dumped Sep 23 10:29:14 node cdsmon: /tmp/instance0 ; core dumped Sep 23 10:28:26 node kernel: em0: device is...
5
769
4
3
0
[ "<awk><sed><zsh><pipe>" ]
2021-09-23T11:17:04.923
2021-09-23T11:33:18.793
257,183
670,287
[ { "id": 670287, "body": "<p>The reason for the behavior of <code>awk</code> is that you have enclosed the program in <em>double</em> quotes, which leaves the string open to variable expansion by the shell. That means the shell from which you are running the program will first expand <code>$1</code>, and sin...
The reason for the behavior of `awk` is that you have enclosed the program in double quotes, which leaves the string open to variable expansion by the shell. That means the shell from which you are running the program will first expand `$1`, and since that is likely undefined, it expands to the empty string. So, your p...
# awk not working on piped output from sed **Tags:** <awk><sed><zsh><pipe> **Question (score 5):** I have a log file which roughly looks like this: ``` Sep 23 10:28:26 node kernel: em0: device is going DOWN Sep 23 10:28:26 node kernel: em0: device is going UP Sep 23 10:29:14 node cdsmon: /tmp/instance0 ; core dumped...
5,313
1,328
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
670,505
unix.stackexchange.com
Stop Cisco VPN AnyConnect from detecting logoff under linux
<p>Cisco VPN AnyConnect automatically detects when the user that initiated the VPN session logs off and then also disconnects the VPN connection. I want to prevent this from happening. I tried to use a screen session which is persistent after logoff but the VPN still got disconnected.</p> <p>The questions are:</p> <ul>...
Cisco VPN AnyConnect automatically detects when the user that initiated the VPN session logs off and then also disconnects the VPN connection. I want to prevent this from happening. I tried to use a screen session which is persistent after logoff but the VPN still got disconnected. The questions are: - what could be th...
6
71
1
0
1
[ "<login><vpn>" ]
2021-09-24T18:01:16.813
2021-09-27T07:44:41.630
32,756
670,802
[ { "id": 670802, "body": "<p>After analyzing the behavior of the vpn client a bit deeper, I found out that it doesn't look for the process or its parent processes but simply keeps track of all login sessions at the time the VPN connection is made.</p>\n<p>This means, if you have 2 login sessions A and B open...
After analyzing the behavior of the vpn client a bit deeper, I found out that it doesn't look for the process or its parent processes but simply keeps track of all login sessions at the time the VPN connection is made. This means, if you have 2 login sessions A and B open while you connect the VPN and you close any of ...
# Stop Cisco VPN AnyConnect from detecting logoff under linux **Tags:** <login><vpn> **Question (score 6):** Cisco VPN AnyConnect automatically detects when the user that initiated the VPN session logs off and then also disconnects the VPN connection. I want to prevent this from happening. I tried to use a screen se...
2,695
673
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
670,551
unix.stackexchange.com
Why does ".." in a symlinked directory in Linux reference the "incorrect" directory?
<p>Please, try to run the following script:</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/bash mkdir a mkdir a/asub mkdir b ln -sfr a/asub b/bsub touch a/this_file_is_in_a touch b/this_file_is_in_b cd b/bsub echo &quot;I'm in directory: $(pwd)&quot; echo This is the contents of the upper directory: ls .....
Please, try to run the following script: ``` #!/bin/bash mkdir a mkdir a/asub mkdir b ln -sfr a/asub b/bsub touch a/this_file_is_in_a touch b/this_file_is_in_b cd b/bsub echo "I'm in directory: $(pwd)" echo This is the contents of the upper directory: ls .. ``` What would you expect to get? Probably the contents of dir...
9
306
1
3
0
[ "<bash><symlink>" ]
2021-09-24T23:38:36.197
2021-09-25T13:39:54.427
60,841
null
[ { "id": 670553, "body": "<p>Think of <em>directories</em> as little files, essentially lists or tables.</p>\n<p>The reason why a directory &quot;knows&quot; its parent directory is because behind the curtains, the full directories are used. As a convenience, links to the upper and current directory exist in...
Think of directories as little files, essentially lists or tables. The reason why a directory "knows" its parent directory is because behind the curtains, the full directories are used. As a convenience, links to the upper and current directory exist in every directory. A symbolic link to a directory is like a link to ...
# Why does ".." in a symlinked directory in Linux reference the "incorrect" directory? **Tags:** <bash><symlink> **Question (score 9):** Please, try to run the following script: ``` #!/bin/bash mkdir a mkdir a/asub mkdir b ln -sfr a/asub b/bsub touch a/this_file_is_in_a touch b/this_file_is_in_b cd b/bsub echo "I'm ...
3,308
827
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
670,636
unix.stackexchange.com
Unable to use USB dongle based on USB-serial converter chip
<p>I have a USB Zigbee dongle, but I'm unable to connect to it. It briefly shows up in <code>/dev/ttyUSB0</code>, but then quickly disappears. I see the following output in the console:</p> <pre><code>$ dmesg --follow ... [ 738.365561] usb 1-10: new full-speed USB device number 8 using xhci_hcd [ 738.607730] usb 1-10...
I have a USB Zigbee dongle, but I'm unable to connect to it. It briefly shows up in `/dev/ttyUSB0`, but then quickly disappears. I see the following output in the console: ``` $ dmesg --follow ... [ 738.365561] usb 1-10: new full-speed USB device number 8 using xhci_hcd [ 738.607730] usb 1-10: New USB device found, idV...
5
1,220
2
0
1
[ "<linux><usb>" ]
2021-09-25T22:01:52.800
2021-10-27T06:27:12.257
70,735
670,637
[ { "id": 670637, "body": "<p>The problem here is BRLTTY, a program that &quot;provides access to the Linux/Unix console (when in text mode) for a blind person using a refreshable braille display&quot;.</p>\n<p>If you are not blind, you can disable BRLTTY in two different ways:</p>\n<h2>Remove udev rules</h2>...
The problem here is BRLTTY, a program that "provides access to the Linux/Unix console (when in text mode) for a blind person using a refreshable braille display". If you are not blind, you can disable BRLTTY in two different ways: ## Remove udev rules BRLTTY uses udev rules to get permissions to mess with the TTYs with...
# Unable to use USB dongle based on USB-serial converter chip **Tags:** <linux><usb> **Question (score 5):** I have a USB Zigbee dongle, but I'm unable to connect to it. It briefly shows up in `/dev/ttyUSB0`, but then quickly disappears. I see the following output in the console: ``` $ dmesg --follow ... [ 738.36556...
2,500
625
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
670,959
unix.stackexchange.com
Remove sshd identification string
<p>When I do nmap scan on SSH port I got</p> <pre><code>22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) </code></pre> <p>Is it possible to modify SSH identification string or hide it?</p>
When I do nmap scan on SSH port I got ``` 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) ``` Is it possible to modify SSH identification string or hide it?
5
367
1
0
0
[ "<ssh>" ]
2021-09-28T09:06:20.257
2021-09-28T09:38:48.830
11,318
null
[ { "id": 670962, "body": "<p>This identification string is probably returned by SSH service itself. Try this:</p>\n<pre><code>echo &quot;blah&quot; | nc YOUR.SERVER.ADDRESS 22\n</code></pre>\n<p>This gives response somewhat similar to this:</p>\n<pre><code>SSH-2.0-OpenSSH_8.6\nInvalid SSH identification stri...
This identification string is probably returned by SSH service itself. Try this: ``` echo "blah" | nc YOUR.SERVER.ADDRESS 22 ``` This gives response somewhat similar to this: ``` SSH-2.0-OpenSSH_8.6 Invalid SSH identification string. ``` Unfortunately this is a string embedded inside `sshd` binary. You've got few optio...
# Remove sshd identification string **Tags:** <ssh> **Question (score 5):** When I do nmap scan on SSH port I got ``` 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) ``` Is it possible to modify SSH identification string or hide it? ### Answer (score 3) This identification string is pro...
1,538
384
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
671,142
unix.stackexchange.com
How do I recursively run "chgrp" without changing the group if it matches a specific group?
<p>I just copied all the files/subdirectories in my home directory to another user's home directory.</p> <p>Then I did a recursive <code>chown</code> on his home directory, so that he became the owner of all his files/subdirectories.</p> <p>The last thing I need to do is a recursive <code>chgrp</code> on his home direc...
I just copied all the files/subdirectories in my home directory to another user's home directory. Then I did a recursive `chown` on his home directory, so that he became the owner of all his files/subdirectories. The last thing I need to do is a recursive `chgrp` on his home directory, so that his username will be the ...
6
560
2
0
0
[ "<files><directory><group><recursive><chgrp>" ]
2021-09-29T15:40:32.187
2021-10-02T18:40:26.133
72,548
671,143
[ { "id": 671143, "body": "<p>Use <code>find</code> to exclude anything owned by group <code>docker</code>; starting from the target home directory:</p>\n<pre><code>find . ! -group docker -exec chgrp newgroup {} +\n</code></pre>\n<p>replacing <code>newgroup</code> as appropriate.</p>\n<p>Alternatively, look f...
Use `find` to exclude anything owned by group `docker`; starting from the target home directory: ``` find . ! -group docker -exec chgrp newgroup {} + ``` replacing `newgroup` as appropriate. Alternatively, look for anything owned by your group: ``` find . -group oldgroup -exec chgrp newgroup {} + ``` replacing `oldgrou...
# How do I recursively run "chgrp" without changing the group if it matches a specific group? **Tags:** <files><directory><group><recursive><chgrp> **Question (score 6):** I just copied all the files/subdirectories in my home directory to another user's home directory. Then I did a recursive `chown` on his home dire...
2,629
657
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
671,246
unix.stackexchange.com
Why is Bash not evaluating the executable bit correctly in Alpine 3.14.2?
<p>In a dockerized Alpine 3.14.2 running Bash 5.1.4(1), I encountered a strange behaviour in a Bash script. The essential line is a test for executability of a file, which always fails. This is the if test in a nutshell:</p> <pre class="lang-bash prettyprint-override"><code>bash-5.1# if [ ! -x /opt/java/openjdk/bin/jav...
In a dockerized Alpine 3.14.2 running Bash 5.1.4(1), I encountered a strange behaviour in a Bash script. The essential line is a test for executability of a file, which always fails. This is the if test in a nutshell: ``` bash-5.1# if [ ! -x /opt/java/openjdk/bin/java ]; then echo "something strange just happened"; fi ...
8
417
1
3
0
[ "<bash><test><alpine-linux>" ]
2021-09-30T09:24:30.457
2021-09-30T13:46:56.377
494,983
null
[ { "id": 671279, "body": "<p>It seems as though Alpine 3.14 is pertinent to a known bug here. All the technical details are part of an already <a href=\"https://github.com/alpinelinux/docker-alpine/issues/156\" rel=\"noreferrer\">open issue there</a> (which I initially did not find because I was always looki...
It seems as though Alpine 3.14 is pertinent to a known bug here. All the technical details are part of an already open issue there (https://github.com/alpinelinux/docker-alpine/issues/156) (which I initially did not find because I was always looking for the "executable" bit). The short answer is to not use Bash in Alpi...
# Why is Bash not evaluating the executable bit correctly in Alpine 3.14.2? **Tags:** <bash><test><alpine-linux> **Question (score 8):** In a dockerized Alpine 3.14.2 running Bash 5.1.4(1), I encountered a strange behaviour in a Bash script. The essential line is a test for executability of a file, which always fail...
3,751
937
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
671,272
unix.stackexchange.com
What does a backslash in front of the delimiter mean in a here document (cat <<\EOF)
<p>I came across the following syntax in a here document not mentioned in <code>bash</code>’s man page</p> <pre><code>cat &lt;&lt;\EOF hello world EOF </code></pre> <p>The man page only mentions quotes around the delimiter and a <code>-</code> in front of it. So what does it mean?</p>
I came across the following syntax in a here document not mentioned in `bash`’s man page ``` cat <<\EOF hello world EOF ``` The man page only mentions quotes around the delimiter and a `-` in front of it. So what does it mean?
7
854
1
3
0
[ "<shell-script><shell>" ]
2021-09-30T12:48:37.287
2021-09-30T13:39:33.360
188,466
null
[ { "id": 671273, "body": "<p>In fact the man page is thorough about this since it reads</p>\n<blockquote>\n<p>If any part of <em>word</em> is quoted</p>\n</blockquote>\n<p>where »quoting« can be any operator of <code>'</code>, <code>&quot;</code> or <code>\\</code>.\n<code>\\EOF</code> quotes <code>E</code> ...
In fact the man page is thorough about this since it reads If any part of word is quoted where »quoting« can be any operator of `'`, `"` or `\`. `\EOF` quotes `E` and serves the same purpose as quoting `WORD` entirely thus preventing parameter expansion in the here document. ``` a="something" cat WORD « can be quoted y...
# What does a backslash in front of the delimiter mean in a here document (cat <<\EOF) **Tags:** <shell-script><shell> **Question (score 7):** I came across the following syntax in a here document not mentioned in `bash`’s man page ``` cat <<\EOF hello world EOF ``` The man page only mentions quotes around the delim...
764
191
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
671,655
unix.stackexchange.com
How do I restore the default sources.list file on Debian 11 (bullseye)?
<p>I installed Debian 11 (Bullseye) onto a device with no internet. I used the &quot;firmware CD&quot; version of the ISO. I have configured the network, so I can do <code>ping 8.8.8.8</code>. I tried to run <code>sudo apt update</code>, but I discovered that there weren't any sources in the <code>sources.list</code> f...
I installed Debian 11 (Bullseye) onto a device with no internet. I used the "firmware CD" version of the ISO. I have configured the network, so I can do `ping 8.8.8.8`. I tried to run `sudo apt update`, but I discovered that there weren't any sources in the `sources.list` file (e.g., it was empty). I found this questio...
6
867
1
0
0
[ "<debian><apt>" ]
2021-10-03T15:12:07.103
2021-10-04T00:41:45.967
495,409
671,660
[ { "id": 671660, "body": "<p>You can find all the information about <code>sources.list</code> in <a href=\"https://wiki.debian.org/SourcesList\" rel=\"noreferrer\">the official Debian wiki site</a>, specifically about your question under <a href=\"https://wiki.debian.org/SourcesList#Example_sources.list\" re...
You can find all the information about `sources.list` in the official Debian wiki site (https://wiki.debian.org/SourcesList), specifically about your question under Example sources.list (https://wiki.debian.org/SourcesList#Example_sources.list): ``` deb http://deb.debian.org/debian bullseye main contrib non-free deb-sr...
# How do I restore the default sources.list file on Debian 11 (bullseye)? **Tags:** <debian><apt> **Question (score 6):** I installed Debian 11 (Bullseye) onto a device with no internet. I used the "firmware CD" version of the ISO. I have configured the network, so I can do `ping 8.8.8.8`. I tried to run `sudo apt u...
1,893
473
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
671,666
unix.stackexchange.com
Regex to match on a single instance of a character
<p>I have this thing that I maintain at work, and it has a pretty arcane DSL that it uses. And the tooling for it is not great. To deal with the poor tooling, I've written some scripts to try to find some issues with the code before I send it to production.</p> <p>The current problem I'm trying to solve has to do with ...
I have this thing that I maintain at work, and it has a pretty arcane DSL that it uses. And the tooling for it is not great. To deal with the poor tooling, I've written some scripts to try to find some issues with the code before I send it to production. The current problem I'm trying to solve has to do with variable n...
8
868
7
6
1
[ "<text-processing><awk><regular-expression>" ]
2021-10-03T16:36:25.733
2021-10-04T08:02:40.673
21,312
671,668
[ { "id": 671670, "body": "<pre class=\"lang-none prettyprint-override\"><code>$ sed 'h;s/@@[^@ ]*@@//g;/@/!d;g' file\n@Var1@@ words words words @@Var2@@ #This will fail because Var1 is wrong.\n@@Var1@ words words words @@Var2@@ #This will fail because Var1 is wrong.\n@@Var1@@ words words words @Var2@@ ...
``` $ sed 'h;s/@@[^@ ]*@@//g;/@/!d;g' file @Var1@@ words words words @@Var2@@ #This will fail because Var1 is wrong. @@Var1@ words words words @@Var2@@ #This will fail because Var1 is wrong. @@Var1@@ words words words @Var2@@ #This will fail because Var2 is wrong. @@Var1@@ words words words @@Var2@ #This will fail beca...
# Regex to match on a single instance of a character **Tags:** <text-processing><awk><regular-expression> **Question (score 8):** I have this thing that I maintain at work, and it has a pretty arcane DSL that it uses. And the tooling for it is not great. To deal with the poor tooling, I've written some scripts to tr...
4,966
1,241
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
671,747
unix.stackexchange.com
How can I write a range of /16 IP addresses in a single expression?
<p>I'd like to ban this range of Chinese IP addresses in nginx:</p> <pre><code> '223.64.0.0 - 223.117.255.255' </code></pre> <p>I know how to ban each of <code>/16</code> range like:</p> <pre><code>deny 223.64.0.0/16; </code></pre> <p>But it will take many lines to include the whole <code>223.64 - 223.117</code> range....
I'd like to ban this range of Chinese IP addresses in nginx: ``` '223.64.0.0 - 223.117.255.255' ``` I know how to ban each of `/16` range like: ``` deny 223.64.0.0/16; ``` But it will take many lines to include the whole `223.64 - 223.117` range. Is there a shorthand notation to do so in one line?
11
1,142
2
0
2
[ "<ip>" ]
2021-10-04T08:53:53.037
2021-10-13T21:54:20.517
495,497
671,755
[ { "id": 671755, "body": "<p><a href=\"http://jodies.de/ipcalc\" rel=\"noreferrer\">ipcalc</a> (<code>ipcalc</code> package on Debian) can help you <em>deaggregate</em> a range into a number of matching <a href=\"https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation\" rel=\"noreferrer\">...
ipcalc (http://jodies.de/ipcalc) (`ipcalc` package on Debian) can help you deaggregate a range into a number of matching CIDR (https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation)s: ``` $ ipcalc -r 223.64.0.0 - 223.117.255.255 deaggregate 223.64.0.0 - 223.117.255.255 223.64.0.0/11 223.96.0.0/12 2...
# How can I write a range of /16 IP addresses in a single expression? **Tags:** <ip> **Question (score 11):** I'd like to ban this range of Chinese IP addresses in nginx: ``` '223.64.0.0 - 223.117.255.255' ``` I know how to ban each of `/16` range like: ``` deny 223.64.0.0/16; ``` But it will take many lines to incl...
4,487
1,121
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
671,818
unix.stackexchange.com
Why 'let' exits with code 1 when calculation result equals to 0?
<p>I came across <a href="https://unix.stackexchange.com/questions/63166/bash-e-exits-when-let-or-expr-evaluates-to-0">this</a> question whose author had dealt with problem caused by: <code>let x=1-1</code> exits with code 1.</p> <p>According to <a href="https://www.gnu.org/software/bash/manual/bash.pdf" rel="noreferre...
I came across this (https://unix.stackexchange.com/questions/63166/bash-e-exits-when-let-or-expr-evaluates-to-0) question whose author had dealt with problem caused by: `let x=1-1` exits with code 1. According to bash manual (https://www.gnu.org/software/bash/manual/bash.pdf): If the last expression evaluates to 0, let...
7
658
1
1
1
[ "<bash><exit-status><math>" ]
2021-10-04T16:43:51.680
2021-10-04T20:24:47.473
495,562
671,823
[ { "id": 671823, "body": "<p>A zero integer value evaluates to <em>false</em> when used in a boolean context in most general programming languages. This fact means you may have code like the following C code.</p>\n<pre class=\"lang-c prettyprint-override\"><code>c = 100;\nwhile (--c) { /* do something while...
A zero integer value evaluates to false when used in a boolean context in most general programming languages. This fact means you may have code like the following C code. ``` c = 100; while (--c) { /* do something while c is non-zero */ } ``` In the shell, an exit status of one evaluates to false when used in a conditi...
# Why 'let' exits with code 1 when calculation result equals to 0? **Tags:** <bash><exit-status><math> **Question (score 7):** I came across this (https://unix.stackexchange.com/questions/63166/bash-e-exits-when-let-or-expr-evaluates-to-0) question whose author had dealt with problem caused by: `let x=1-1` exits wit...
1,732
433
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
672,249
unix.stackexchange.com
On `tty <&1` vs `echo $(tty <&1)` vs `echo $(tty <&2)`
<p>The key statements in the snippet below (i.e. other than those for printing labels and blank lines, for spacing) come in pairs. In each pair, the first and second statements have the forms <code>tty...</code> and <code>echo $(tty...)</code>, respectively.</p> <pre class="lang-bsh prettyprint-override"><code>echo st...
The key statements in the snippet below (i.e. other than those for printing labels and blank lines, for spacing) come in pairs. In each pair, the first and second statements have the forms `tty...` and `echo $(tty...)`, respectively. ``` echo stdin: tty echo $(tty) echo echo stdout: tty 1 (I added the line numbers afte...
5
183
1
0
0
[ "<tty><stdout><file-descriptors>" ]
2021-10-07T11:00:20.590
2021-10-07T11:22:06.767
10,618
672,275
[ { "id": 672275, "body": "<p><code>tty</code> reports (on its stdout) the name of tty device that is opened on its standard input (its fd 0).</p>\n<p>In:</p>\n<pre><code>tty &lt;&amp;2\n</code></pre>\n<p>Which is short for</p>\n<pre><code>tty 0&lt;&amp;2\n</code></pre>\n<p>The shell redirects fd 0 to the sam...
`tty` reports (on its stdout) the name of tty device that is opened on its standard input (its fd 0). In: ``` tty - 3: same as the outer 1 - 1: a pipe - 2: untouched - 0: same as 3, so same as outer 1 So `tty` can write to that pipe the path of the tty device that is connected to the outer stdout. As tty doesn't need t...
# On `tty <&1` vs `echo $(tty <&1)` vs `echo $(tty <&2)` **Tags:** <tty><stdout><file-descriptors> **Question (score 5):** The key statements in the snippet below (i.e. other than those for printing labels and blank lines, for spacing) come in pairs. In each pair, the first and second statements have the forms `tty....
2,407
601
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
672,274
unix.stackexchange.com
What is the difference between echo 0>file.txt and echo 0 > file.txt?
<p>I see that this has the behavior:</p> <pre class="lang-none prettyprint-override"><code>[root@divinity test]# echo 0 &gt; file.txt [root@divinity test]# cat file.txt 0 [root@divinity test]# echo 0&gt; file.txt [root@divinity test]# cat file.txt </code></pre> <p>I also noticed that if I include <code>&quot;&quot;</...
I see that this has the behavior: ``` [root@divinity test]# echo 0 > file.txt [root@divinity test]# cat file.txt 0 [root@divinity test]# echo 0> file.txt [root@divinity test]# cat file.txt ``` I also noticed that if I include `""` then it works as expected: ``` [root@divinity test]# echo 0""> file.txt [root@divinity te...
28
2,972
2
5
3
[ "<shell><io-redirection>" ]
2021-10-07T13:08:44.263
2021-10-07T13:13:14.460
137,794
672,279
[ { "id": 672279, "body": "<p>In <code>echo 0 &gt; file.txt</code>, with the spaces, <code>&gt; file.txt</code> causes the shell to redirect standard output so that it is written to <code>file.txt</code> (after truncating the file if it already exists). The rest of the command, <code>echo 0</code>, is run wit...
In `echo 0 > file.txt`, with the spaces, `> file.txt` causes the shell to redirect standard output so that it is written to `file.txt` (after truncating the file if it already exists). The rest of the command, `echo 0`, is run with the redirections in place. When a redirection operator (https://unix.stackexchange.com/q...
# What is the difference between echo 0>file.txt and echo 0 > file.txt? **Tags:** <shell><io-redirection> **Question (score 28):** I see that this has the behavior: ``` [root@divinity test]# echo 0 > file.txt [root@divinity test]# cat file.txt 0 [root@divinity test]# echo 0> file.txt [root@divinity test]# cat file.t...
2,050
512
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
672,295
unix.stackexchange.com
Run script without pressing enter
<p>Is there any way to run a program without pressing enter?</p> <p>I could then have a script that cd's one folder up. Then I could hold down ctrl and every time i would hit a button, that script would run.</p> <p>That could make life easier in the shell as I could go up the folder structure faster. And could even cle...
Is there any way to run a program without pressing enter? I could then have a script that cd's one folder up. Then I could hold down ctrl and every time i would hit a button, that script would run. That could make life easier in the shell as I could go up the folder structure faster. And could even clear the screen eac...
12
1,152
2
0
6
[ "<shell><scripting>" ]
2021-10-07T14:56:46.777
2021-10-09T17:27:56.137
8,563
672,299
[ { "id": 672299, "body": "<p>You can do this using bash's <code>.inputrc</code> file, the <code>readline</code> startup configuration file. First, edit the file <code>~/.inputrc</code> (this means a file named <code>.inputrc</code> in your <code>$HOME</code> directory; create it if it doesn't exist) and add ...
You can do this using bash's `.inputrc` file, the `readline` startup configuration file. First, edit the file `~/.inputrc` (this means a file named `.inputrc` in your `$HOME` directory; create it if it doesn't exist) and add this line: ``` Control-u: "cd ../\n" ``` That sets the keyboard shortcut Ctrl+u to insert `cd ....
# Run script without pressing enter **Tags:** <shell><scripting> **Question (score 12):** Is there any way to run a program without pressing enter? I could then have a script that cd's one folder up. Then I could hold down ctrl and every time i would hit a button, that script would run. That could make life easier i...
1,124
281
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
672,609
unix.stackexchange.com
How do you make a process a service under systemd?
<p>what is the command or how would you make a process into a service in Linux? isn't a service basically a daemon?</p>
what is the command or how would you make a process into a service in Linux? isn't a service basically a daemon?
7
1,334
3
6
0
[ "<linux><systemd><services><daemon>" ]
2021-10-10T04:31:48.533
2021-10-12T16:22:44.343
496,227
672,615
[ { "id": 672615, "body": "<p>An example of a user service is the easiest way to describe how to do this.</p>\n<p>Let's assume that you have a binary or a script, called <code>mytask</code>, that you want to run as a service, and it is located in <code>/usr/local/bin/</code>.</p>\n<p>Create a <code>systemd</c...
An example of a user service is the easiest way to describe how to do this. Let's assume that you have a binary or a script, called `mytask`, that you want to run as a service, and it is located in `/usr/local/bin/`. Create a `systemd` unit file, called `my_example.service`, in your home directory, `~/.config/systemd/u...
# How do you make a process a service under systemd? **Tags:** <linux><systemd><services><daemon> **Question (score 7):** what is the command or how would you make a process into a service in Linux? isn't a service basically a daemon? ### Answer (score 13 · accepted) An example of a user service is the easiest way ...
3,153
788
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
672,871
unix.stackexchange.com
Is there a method to indicate the last iteration in a loop over lines of an input file?
<p>Suppose I have a file <code>direction</code> with the lines</p> <pre><code>east north south west south-west </code></pre> <p>and using a loop and <code>echo</code> in a shell script I want to generate this output:</p> <pre><code>Direction: east Direction: north Direction: south Direction: west Last direction: south...
Suppose I have a file `direction` with the lines ``` east north south west south-west ``` and using a loop and `echo` in a shell script I want to generate this output: ``` Direction: east Direction: north Direction: south Direction: west Last direction: south-west ``` So in other words I want to do something different ...
11
2,254
10
0
0
[ "<shell-script><text-processing>" ]
2021-10-12T09:49:55.453
2021-10-15T12:51:59.427
117,409
672,877
[ { "id": 672877, "body": "<p><code>bash</code> can't detect the end of a file (without trying to read the next line and failing), but perl can with its <code>eof</code> function:</p>\n<pre><code>$ perl -n -e 'print &quot;Last &quot; if eof; print &quot;Direction: $_&quot;' direction \nDirection: east\nDirect...
`bash` can't detect the end of a file (without trying to read the next line and failing), but perl can with its `eof` function: ``` $ perl -n -e 'print "Last " if eof; print "Direction: $_"' direction Direction: east Direction: north Direction: south Direction: west Last Direction: south-west ``` note: unlike `echo` in...
# Is there a method to indicate the last iteration in a loop over lines of an input file? **Tags:** <shell-script><text-processing> **Question (score 11):** Suppose I have a file `direction` with the lines ``` east north south west south-west ``` and using a loop and `echo` in a shell script I want to generate this ...
4,496
1,124
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
672,996
unix.stackexchange.com
How can I see if a consecutive number name file is missing some file?
<p>If I give <code>ls -1</code> I get like this,</p> <pre><code>file_0001.jpeg file_0002.jpeg file_0003.jpeg file_0004.jpeg file_0005.jpeg file_0006.jpeg file_0007.jpeg file_0008.jpeg file_0009.jpeg file_0010.jpeg file_0011.jpeg file_0012.jpeg file_0013.jpeg file_0014.jpeg file_0015.jpeg file_0016.jpeg file_0017.jpeg f...
If I give `ls -1` I get like this, ``` file_0001.jpeg file_0002.jpeg file_0003.jpeg file_0004.jpeg file_0005.jpeg file_0006.jpeg file_0007.jpeg file_0008.jpeg file_0009.jpeg file_0010.jpeg file_0011.jpeg file_0012.jpeg file_0013.jpeg file_0014.jpeg file_0015.jpeg file_0016.jpeg file_0017.jpeg file_0018.jpeg file_0019.j...
5
1,188
7
6
3
[ "<awk><utilities>" ]
2021-10-13T07:53:15.253
2021-10-17T10:02:24.757
22,558
673,000
[ { "id": 673092, "body": "<p>If you're using the <code>bash</code> shell, you can use <code>seq</code> or <code>jot</code> to create a &quot;perfect&quot; output reference sample, then compare the output of <code>ls -1</code> to that reference:</p>\n<pre><code>$ diff &lt;(ls -1) &lt;(seq -f 'file_%04g.jpeg' ...
If you're using the `bash` shell, you can use `seq` or `jot` to create a "perfect" output reference sample, then compare the output of `ls -1` to that reference: ``` $ diff <(ls -1) <(seq -f 'file_%04g.jpeg' 999) ``` This will not only show you any missing files, it will also find extraneous files.
# How can I see if a consecutive number name file is missing some file? **Tags:** <awk><utilities> **Question (score 5):** If I give `ls -1` I get like this, ``` file_0001.jpeg file_0002.jpeg file_0003.jpeg file_0004.jpeg file_0005.jpeg file_0006.jpeg file_0007.jpeg file_0008.jpeg file_0009.jpeg file_0010.jpeg file_...
3,656
914
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
673,037
unix.stackexchange.com
what is the use of egrep [[:print:]] command in bash?
<p>I am working on an enhancement of a shell script which reads a file and processes it. Basically the input file contains a header record followed by number of detail records. I want to get only the header record from the file.</p> <pre><code>$ cat sample_file.txt header1,header2,header3,header4 value1,value2,value3,v...
I am working on an enhancement of a shell script which reads a file and processes it. Basically the input file contains a header record followed by number of detail records. I want to get only the header record from the file. ``` $ cat sample_file.txt header1,header2,header3,header4 value1,value2,value3,value4 ``` The ...
5
194
2
1
0
[ "<linux><bash><shell><grep>" ]
2021-10-13T11:22:55.280
2021-10-13T11:33:26.060
496,785
673,046
[ { "id": 673046, "body": "<p>A bracket expression is something like <code>[abc]</code>, which matches any one of the characters inside it. E.g. <code>[abc]</code> would match <code>a</code> or <code>b</code>, but not <code>d</code> or <code>:</code>. Character classes can be used within a bracket expression ...
A bracket expression is something like `[abc]`, which matches any one of the characters inside it. E.g. `[abc]` would match `a` or `b`, but not `d` or `:`. Character classes can be used within a bracket expression to add the whole class to the set the bracket expression matches. `[[:print:]]` would match a single print...
# what is the use of egrep [[:print:]] command in bash? **Tags:** <linux><bash><shell><grep> **Question (score 5):** I am working on an enhancement of a shell script which reads a file and processes it. Basically the input file contains a header record followed by number of detail records. I want to get only the hea...
4,593
1,148
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
673,591
unix.stackexchange.com
swap files instead of cp with temp file?
<p>There is this famous entry level programming exercise where you're asked to swap two variables. The obvious solution is to use a third, ephemeral variable. But if your language has something like tuples, you can write a very simple helper function that returns its arguments in reversed order:</p> <pre class="lang-sc...
There is this famous entry level programming exercise where you're asked to swap two variables. The obvious solution is to use a third, ephemeral variable. But if your language has something like tuples, you can write a very simple helper function that returns its arguments in reversed order: ``` def swap(a: Int, b: In...
5
342
4
4
0
[ "<linux><files>" ]
2021-10-17T16:51:34.217
2021-10-18T07:08:54.580
424,482
673,601
[ { "id": 673601, "body": "<p>There is a Linux-specific system call able to do this, at the kernel level.</p>\n<p>The relevant system call is <a href=\"https://manpages.debian.org/renameat2.2.en.html\" rel=\"noreferrer\"><code>renameat2()</code></a> which is a Linux-specific extension to <code>renameat()</cod...
There is a Linux-specific system call able to do this, at the kernel level. The relevant system call is `renameat2()` (https://manpages.debian.org/renameat2.2.en.html) which is a Linux-specific extension to `renameat()` and can be used with an additional specific flag to address this question. It was added in Linux 3.1...
# swap files instead of cp with temp file? **Tags:** <linux><files> **Question (score 5):** There is this famous entry level programming exercise where you're asked to swap two variables. The obvious solution is to use a third, ephemeral variable. But if your language has something like tuples, you can write a very ...
4,594
1,148
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
673,641
unix.stackexchange.com
Is there any reason why /proc/*/cmdline is world-readable?
<p>Maybe I haven't had enough coffee yet today, but I can't remember or think of any reason why <code>/proc/PID/cmdline</code> should be world-readable - after all, <code>/proc/PID/environ</code> isn't.</p> <p>Making it readable only by the user (and maybe the group. and root, of course) would prevent casual exposure ...
Maybe I haven't had enough coffee yet today, but I can't remember or think of any reason why `/proc/PID/cmdline` should be world-readable - after all, `/proc/PID/environ` isn't. Making it readable only by the user (and maybe the group. and root, of course) would prevent casual exposure of passwords entered as command-l...
30
5,624
2
5
5
[ "<linux><permissions><proc>" ]
2021-10-18T04:06:44.443
2021-10-18T17:37:21.527
7,696
673,645
[ { "id": 673645, "body": "<p>I suspect the main, and perhaps only, reason is historical — <code>/proc/.../cmdline</code> was initially world-readable, so it remains that way for backwards compatibility. <code>cmdline</code> was added in 0.98.6, released on December 2, 1992, with mode 444; the changelog says<...
I suspect the main, and perhaps only, reason is historical — `/proc/.../cmdline` was initially world-readable, so it remains that way for backwards compatibility. `cmdline` was added in 0.98.6, released on December 2, 1992, with mode 444; the changelog says ``` - /proc filesystem extensions. Based on ideas (and some co...
# Is there any reason why /proc/*/cmdline is world-readable? **Tags:** <linux><permissions><proc> **Question (score 30):** Maybe I haven't had enough coffee yet today, but I can't remember or think of any reason why `/proc/PID/cmdline` should be world-readable - after all, `/proc/PID/environ` isn't. Making it readab...
3,799
949
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
674,031
unix.stackexchange.com
Concatenate files by table values
<p>I have a number of files each containing a specific pattern in their names like <code>ABC1234001</code> which carry information about certain groups of my data (tables of multiple columns). I also have a table <code>info.tsv</code> like this:</p> <pre><code>group1 ABC1234001 ABC1234010 group2 ABC1234011 ...
I have a number of files each containing a specific pattern in their names like `ABC1234001` which carry information about certain groups of my data (tables of multiple columns). I also have a table `info.tsv` like this: ``` group1 ABC1234001 ABC1234010 group2 ABC1234011 ABC1234018 group3 ABC1234019 ABC1234028 ... ... ...
7
230
3
3
1
[ "<bash><shell-script><text-processing>" ]
2021-10-20T13:44:22.933
2021-10-20T14:24:49.743
497,772
674,042
[ { "id": 674042, "body": "<p>The script below assumes that all files that you may want to concatenate matches the pattern <code>*.tsv</code>. If you know that they all match <code>ABC*.tsv</code>, then you may want to use that pattern at the start of the script in place of <code>*.tsv</code>.</p>\n<p>The sc...
The script below assumes that all files that you may want to concatenate matches the pattern `*.tsv`. If you know that they all match `ABC*.tsv`, then you may want to use that pattern at the start of the script in place of `*.tsv`. The script furthermore assumes that all names of files that goes into a specific group a...
# Concatenate files by table values **Tags:** <bash><shell-script><text-processing> **Question (score 7):** I have a number of files each containing a specific pattern in their names like `ABC1234001` which carry information about certain groups of my data (tables of multiple columns). I also have a table `info.tsv`...
3,575
893
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
674,540
unix.stackexchange.com
Chrome window gets too big when maximizing on linux mint xfce
<p>I have following problem. I am new to Linux and went with Mint as my distro. On windows I always used Chrome as my go to browser because I do a lot of webdev and like to have the best support for browser features so I also went for Google Chrome here on Linux. I found out that when I maximize the Screen of Chrome th...
I have following problem. I am new to Linux and went with Mint as my distro. On windows I always used Chrome as my go to browser because I do a lot of webdev and like to have the best support for browser features so I also went for Google Chrome here on Linux. I found out that when I maximize the Screen of Chrome that ...
19
2,271
3
5
0
[ "<linux-mint><xfce><chrome><window-manager><compton>" ]
2021-10-23T20:54:32.147
2021-12-04T12:06:39.980
498,197
674,701
[ { "id": 674701, "body": "<p><strong>UPDATE</strong></p>\n<p>Seems like it is fixed with this version: <em>Version 96.0.4664.45 (Official Build) (64-bit)</em></p>\n<hr />\n<p>seems like it is a bug within chrome. since no other window on my machine has this behavior and it just appeared after updating chrome...
UPDATE Seems like it is fixed with this version: Version 96.0.4664.45 (Official Build) (64-bit) seems like it is a bug within chrome. since no other window on my machine has this behavior and it just appeared after updating chrome.. found an open bug, too: https://bugs.chromium.org/p/chromium/issues/detail?id=1261797&q...
# Chrome window gets too big when maximizing on linux mint xfce **Tags:** <linux-mint><xfce><chrome><window-manager><compton> **Question (score 19):** I have following problem. I am new to Linux and went with Mint as my distro. On windows I always used Chrome as my go to browser because I do a lot of webdev and like...
3,089
772
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
674,823
unix.stackexchange.com
Can I make the clear command behave like Ctrl-L in Bash?
<p>It seems that <code>clear</code> and bash <kbd>Ctrl</kbd>-<kbd>L</kbd> are quite different; <code>clear</code> completely removes all previous terminal information (so you cannot scroll up) while <kbd>Ctrl</kbd>-<kbd>L</kbd> just scrolls the screen so that the cursor is at the top of the page so that you can still s...
It seems that `clear` and bash Ctrl-L are quite different; `clear` completely removes all previous terminal information (so you cannot scroll up) while Ctrl-L just scrolls the screen so that the cursor is at the top of the page so that you can still scroll up and see previous information. I much prefer the Ctrl-L syste...
11
838
2
5
2
[ "<bash><terminal><inputrc>" ]
2021-10-26T07:20:47.290
2021-10-28T04:16:34.697
441,685
674,864
[ { "id": 674864, "body": "<blockquote>\n<p>Is there a way to override clear so that it does a Ctrl-L instead of wiping all previous terminal information?</p>\n</blockquote>\n<pre><code>alias clear='tput -x clear'\n</code></pre>\n<p>Yes, <code>Ctrl-L</code> in bash (while in <code>set -o emacs</code> mode) do...
Is there a way to override clear so that it does a Ctrl-L instead of wiping all previous terminal information? ``` alias clear='tput -x clear' ``` Yes, `Ctrl-L` in bash (while in `set -o emacs` mode) does exactly the same thing. Or you can just hardwire the escape with `alias clear='printf "\033[H\033[2J"'` which shoul...
# Can I make the clear command behave like Ctrl-L in Bash? **Tags:** <bash><terminal><inputrc> **Question (score 11):** It seems that `clear` and bash Ctrl-L are quite different; `clear` completely removes all previous terminal information (so you cannot scroll up) while Ctrl-L just scrolls the screen so that the cu...
2,700
675
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
675,165
unix.stackexchange.com
Excluding directories in find
<p><code>find</code> is always a complete mystery to me whenever I use it; I just want to exclude everything under <code>/mnt</code> (I am in bash on Ubuntu 20.04 on WSL so don't want it to search in the Windows space) from my search, but <code>find</code> just blunders into those directories completely ignoring me. I ...
`find` is always a complete mystery to me whenever I use it; I just want to exclude everything under `/mnt` (I am in bash on Ubuntu 20.04 on WSL so don't want it to search in the Windows space) from my search, but `find` just blunders into those directories completely ignoring me. I found syntax from this page. https:/...
9
408
2
0
1
[ "<find>" ]
2021-10-28T15:07:47.930
2021-10-28T15:44:37.233
441,685
null
[ { "id": 675169, "body": "<p>Find's <code>-path</code> doesn't exclude paths, it means &quot;do not report any matches whose name matches this path&quot;. It will still descend into the directories and will search them. What you want is <code>-prune</code> (from <code>man find</code>):</p>\n<pre><code> ...
Find's `-path` doesn't exclude paths, it means "do not report any matches whose name matches this path". It will still descend into the directories and will search them. What you want is `-prune` (from `man find`): ``` -prune True; if the file is a directory, do not descend into it. If -depth is given, then -prune has ...
# Excluding directories in find **Tags:** <find> **Question (score 9):** `find` is always a complete mystery to me whenever I use it; I just want to exclude everything under `/mnt` (I am in bash on Ubuntu 20.04 on WSL so don't want it to search in the Windows space) from my search, but `find` just blunders into thos...
3,098
774
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
675,412
unix.stackexchange.com
Why am I not able to give write permission to users using chmod in linux?
<p>The current file permissions look like this:</p> <pre><code>$ ls -l file -rwxrwxr-x 1 chiranjitd chiranjitd 0 Oct 30 14:52 file </code></pre> <p>Now I try to give write permissions using <code>chmod</code>:</p> <pre><code>$ chmod +x+r+w file </code></pre> <p>After that, the file permissions still look like this:</p>...
The current file permissions look like this: ``` $ ls -l file -rwxrwxr-x 1 chiranjitd chiranjitd 0 Oct 30 14:52 file ``` Now I try to give write permissions using `chmod`: ``` $ chmod +x+r+w file ``` After that, the file permissions still look like this: ``` $ ls -l file -rwxrwxr-x 1 chiranjitd chiranjitd 0 Oct 30 14:5...
5
733
1
0
1
[ "<linux><chmod>" ]
2021-10-30T09:34:49.163
2021-11-02T10:20:28.853
498,828
null
[ { "id": 675417, "body": "<p>When you run <code>chmod +x+r+w file</code>, <a href=\"https://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html\" rel=\"noreferrer\">all the bits are set, except those masked by your <code>umask</code></a>. Your <code>umask</code> presumably masks (at least) other us...
When you run `chmod +x+r+w file`, all the bits are set, except those masked by your `umask` (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html). Your `umask` presumably masks (at least) other users’ write bit, so the `+w` part ends up being ignored for them. Thus for a typical `umask` of 022, any `c...
# Why am I not able to give write permission to users using chmod in linux? **Tags:** <linux><chmod> **Question (score 5):** The current file permissions look like this: ``` $ ls -l file -rwxrwxr-x 1 chiranjitd chiranjitd 0 Oct 30 14:52 file ``` Now I try to give write permissions using `chmod`: ``` $ chmod +x+r+w f...
1,860
465
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
675,621
unix.stackexchange.com
How to get names of the files which contain the specified text only
<p>I have a directory named &quot;labels&quot; in which there are text files which contain labels for &quot;cat&quot; or &quot;dog&quot; or both on separate lines.<br /> Contents of files in labels directory are:</p> <pre><code>cat labels/1.txt cat cat labels/2.txt dog cat labels/3.txt cat dog </code></pre> <p>I wa...
I have a directory named "labels" in which there are text files which contain labels for "cat" or "dog" or both on separate lines. Contents of files in labels directory are: ``` cat labels/1.txt cat cat labels/2.txt dog cat labels/3.txt cat dog ``` I want to get the names of files which contain label "cat" only. I trie...
5
823
8
0
1
[ "<files><grep>" ]
2021-11-01T05:42:02.930
2021-11-01T08:40:26.530
499,312
675,633
[ { "id": 675633, "body": "<p>You could use <code>grep</code> twice: a) for listing all files with <code>cat</code>, then b) sieve out <code>dog</code>-containing ones. Use <code>-l</code> and <code>-L</code>, respectively, where <code>-l</code> lists filenames with matches and <code>-L</code> filenames witho...
You could use `grep` twice: a) for listing all files with `cat`, then b) sieve out `dog`-containing ones. Use `-l` and `-L`, respectively, where `-l` lists filenames with matches and `-L` filenames without matches: ``` grep -L 'dog' $(grep -l 'cat' ) ``` See `man grep`: -L, --files-without-match Suppress normal output;...
# How to get names of the files which contain the specified text only **Tags:** <files><grep> **Question (score 5):** I have a directory named "labels" in which there are text files which contain labels for "cat" or "dog" or both on separate lines. Contents of files in labels directory are: ``` cat labels/1.txt cat ...
3,101
775
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
675,781
unix.stackexchange.com
Check dd's progress without USR1?
<p>I'm on a Linux <code>busybox 1.27</code> only system so no <code>output=progress</code> available, no busybox's own implementation of <code>pv</code> which is <code>pipe_progress</code> nor <code>pv</code> itself.</p> <p>I have two questions. The first is based on <a href="https://www.linux.com/training-tutorials/sh...
I'm on a Linux `busybox 1.27` only system so no `output=progress` available, no busybox's own implementation of `pv` which is `pipe_progress` nor `pv` itself. I have two questions. The first is based on https://www.linux.com/training-tutorials/show-progress-when-using-dd/ (https://www.linux.com/training-tutorials/show-...
8
630
2
4
0
[ "<linux><dd><busybox>" ]
2021-11-02T06:38:34.220
2021-11-02T16:13:29.760
491,396
675,788
[ { "id": 675788, "body": "<blockquote>\n<p><code>dd if=/dev/zero of=/dev/null bs=1048576 count=1024</code></p>\n</blockquote>\n<p>Note that <a href=\"https://unix.stackexchange.com/questions/32988/why-does-dd-from-dev-random-give-different-file-sizes/33009#33009\"><code>dd</code> can mangle data</a>, at leas...
`dd if=/dev/zero of=/dev/null bs=1048576 count=1024` Note that `dd` can mangle data (https://unix.stackexchange.com/questions/32988/why-does-dd-from-dev-random-give-different-file-sizes/33009#33009), at least when using the `bs` parameter (https://unix.stackexchange.com/questions/17295/when-is-dd-suitable-for-copying-d...
# Check dd's progress without USR1? **Tags:** <linux><dd><busybox> **Question (score 8):** I'm on a Linux `busybox 1.27` only system so no `output=progress` available, no busybox's own implementation of `pv` which is `pipe_progress` nor `pv` itself. I have two questions. The first is based on https://www.linux.com/t...
5,736
1,434
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,199
unix.stackexchange.com
How should I set up a systemd service to auto-start a server and let me pass commands to it?
<h4>Goal:</h4> <p>I'm trying to get a Minecraft server to run on computer boot with systemd on Fedora. I have a few self-imposed criteria that I need to meet to be able to properly manage my server(s):</p> <ol> <li>It has to run as the <code>minecraft</code> system user I made with the home dir <code>/opt/minecraft</co...
#### Goal: I'm trying to get a Minecraft server to run on computer boot with systemd on Fedora. I have a few self-imposed criteria that I need to meet to be able to properly manage my server(s): - It has to run as the `minecraft` system user I made with the home dir `/opt/minecraft`. I attempted this one by `adduser`in...
5
91
1
0
2
[ "<fedora><systemd><fifo><minecraft>" ]
2021-11-04T18:58:50.263
2021-11-11T02:30:28.600
441,512
676,292
[ { "id": 676292, "body": "<p>I don't have a full answer for you because I can't reproduce the problem. But I've tried to put togeather a minimum verifiable example and had some ideas for troubleshooting:</p>\n<pre><code># /etc/systemd/system/sockinst@.service\n[Service]\nExecStart=cat -\nUser=stew\nSockets=...
I don't have a full answer for you because I can't reproduce the problem. But I've tried to put togeather a minimum verifiable example and had some ideas for troubleshooting: ``` # /etc/systemd/system/sockinst@.service [Service] ExecStart=cat - User=stew Sockets=sockinst@%i.socket StandardInput=socket StandardOutput=jo...
# How should I set up a systemd service to auto-start a server and let me pass commands to it? **Tags:** <fedora><systemd><fifo><minecraft> **Question (score 5):** #### Goal: I'm trying to get a Minecraft server to run on computer boot with systemd on Fedora. I have a few self-imposed criteria that I need to meet to...
10,145
2,536
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,202
unix.stackexchange.com
Splitting a small file into 512 byte segments changes it, but splitting it in 1k segments doesn't
<p>So I'm trying to split a 64MB file <code>FileCarve.001</code> into 512 byte segments (each block is 512 bytes long). I need to make sure the file has the same data when split into smaller files, so I <code>cat</code> all the files to standard out and pipe it into <code>sha256sum</code> (there's a lot of files, so I ...
So I'm trying to split a 64MB file `FileCarve.001` into 512 byte segments (each block is 512 bytes long). I need to make sure the file has the same data when split into smaller files, so I `cat` all the files to standard out and pipe it into `sha256sum` (there's a lot of files, so I need to do this with `find` and `xar...
16
1,953
1
0
1
[ "<find><wildcards><dd><split><checksum>" ]
2021-11-04T19:28:46.940
2021-11-10T16:48:19.877
248,296
676,208
[ { "id": 676208, "body": "<p>The order <code>find</code> processes the files is not deterministic. It may be just the same order as the underlying system call gives, which probably depends on the underlying filesystem structure and can be essentially random. Some implementations might process the list someho...
The order `find` processes the files is not deterministic. It may be just the same order as the underlying system call gives, which probably depends on the underlying filesystem structure and can be essentially random. Some implementations might process the list somehow, but don't expect it to be sorted. Let's try with...
# Splitting a small file into 512 byte segments changes it, but splitting it in 1k segments doesn't **Tags:** <find><wildcards><dd><split><checksum> **Question (score 16):** So I'm trying to split a 64MB file `FileCarve.001` into 512 byte segments (each block is 512 bytes long). I need to make sure the file has the ...
3,697
924
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,309
unix.stackexchange.com
System unresponsive after mounting /dev/sdc2 on /
<p>So, I tried to mount a hard disk <code>/dev/sdc2</code> on <code>/</code> directory in my Ubuntu workstation, and upon mounting, I am not able to remote into the Ubuntu workstation anymore. The exact command I run to mount is</p> <pre><code>sudo mount /dev/sdc2 / </code></pre> <p>I am not sure what has gone wrong, b...
So, I tried to mount a hard disk `/dev/sdc2` on `/` directory in my Ubuntu workstation, and upon mounting, I am not able to remote into the Ubuntu workstation anymore. The exact command I run to mount is ``` sudo mount /dev/sdc2 / ``` I am not sure what has gone wrong, but I thought mounting a hard disk on `/` director...
5
436
2
0
0
[ "<ubuntu><mount><root>" ]
2021-11-05T12:10:02.700
2021-11-05T12:24:12.830
500,012
676,312
[ { "id": 676312, "body": "<p>Unfortunately, mounting any filesystem on the <code>/</code> mount-point of a <em>running</em> Linux installation is fatal, unless that newly-mounted filesystem happens to contain in itself a complete Linux installation (and even then it is a bad idea).</p>\n<p>The reason is as f...
Unfortunately, mounting any filesystem on the `/` mount-point of a running Linux installation is fatal, unless that newly-mounted filesystem happens to contain in itself a complete Linux installation (and even then it is a bad idea). The reason is as follows: - `/` is the root mount point to which the entire filesystem...
# System unresponsive after mounting /dev/sdc2 on / **Tags:** <ubuntu><mount><root> **Question (score 5):** So, I tried to mount a hard disk `/dev/sdc2` on `/` directory in my Ubuntu workstation, and upon mounting, I am not able to remote into the Ubuntu workstation anymore. The exact command I run to mount is ``` s...
2,566
641
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,403
unix.stackexchange.com
Connecting to Bluetooth but Connection Failed: No audio endpoints registered
<p>I do dual boot Kali-Linux with Windows11. So the problem is I want to connect with my Bluetooth speaker (JBL GO), but unfortunately I cannot connect. I use both GUI and CLI to connect to my speaker. It was working perfectly before. I can connect in Windows, but not in my Kali.</p> <p>Here is the message using GUI: <...
I do dual boot Kali-Linux with Windows11. So the problem is I want to connect with my Bluetooth speaker (JBL GO), but unfortunately I cannot connect. I use both GUI and CLI to connect to my speaker. It was working perfectly before. I can connect in Windows, but not in my Kali. Here is the message using GUI: And here is...
5
1,569
2
0
2
[ "<bluetooth><bluez><blueman>" ]
2021-11-06T02:27:30.053
2021-11-13T18:49:47.487
474,428
676,829
[ { "id": 676829, "body": "<p>I have been beating my head about this issue. I have been encountering it for a few days since the latest round of apt updates available for Kali. After doing some digging I discovered that there are some package changes associated with PipeWire and pulseaudio components (specifi...
I have been beating my head about this issue. I have been encountering it for a few days since the latest round of apt updates available for Kali. After doing some digging I discovered that there are some package changes associated with PipeWire and pulseaudio components (specifically the removal of pipewire-media-sess...
# Connecting to Bluetooth but Connection Failed: No audio endpoints registered **Tags:** <bluetooth><bluez><blueman> **Question (score 5):** I do dual boot Kali-Linux with Windows11. So the problem is I want to connect with my Bluetooth speaker (JBL GO), but unfortunately I cannot connect. I use both GUI and CLI to ...
7,302
1,825
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,523
unix.stackexchange.com
Replacing counter in a filename for all files in a directory
<p>After importing several 1000 Files from a camera onto a hard drive I realized, that the counter, used in the process of renaming the file - does not start from 0. This leads to file structure like this:</p> <pre><code>My vacation 2018-05-03 2345.jpg My vacation 2018-05-03 2346.jpg My vacation 2018-05-04 2347.jpg </c...
After importing several 1000 Files from a camera onto a hard drive I realized, that the counter, used in the process of renaming the file - does not start from 0. This leads to file structure like this: ``` My vacation 2018-05-03 2345.jpg My vacation 2018-05-03 2346.jpg My vacation 2018-05-04 2347.jpg ``` I would like ...
6
338
4
2
0
[ "<regular-expression><rename><batch-jobs>" ]
2021-11-07T16:45:09.433
2021-11-09T17:08:33.603
500,298
676,531
[ { "id": 676524, "body": "<p>With <code>zsh</code>:</p>\n<pre><code>$ autoload -Uz zmv\n$ zmv -n '(* )(&lt;-&gt;)(.jpg)' '$1${(l[4][0])$(($2 - 2344))}$3'\nmv -- 'My vacation 2018-05-03 2345.jpg' 'My vacation 2018-05-03 0001.jpg'\nmv -- 'My vacation 2018-05-03 2346.jpg' 'My vacation 2018-05-03 0002.jpg'\nmv -...
With `zsh`: ``` $ autoload -Uz zmv $ zmv -n '(* )()(.jpg)' '$1${(l[4][0])$(($2 - 2344))}$3' mv -- 'My vacation 2018-05-03 2345.jpg' 'My vacation 2018-05-03 0001.jpg' mv -- 'My vacation 2018-05-03 2346.jpg' 'My vacation 2018-05-03 0002.jpg' mv -- 'My vacation 2018-05-04 2347.jpg' 'My vacation 2018-05-04 0003.jpg' ``` (t...
# Replacing counter in a filename for all files in a directory **Tags:** <regular-expression><rename><batch-jobs> **Question (score 6):** After importing several 1000 Files from a camera onto a hard drive I realized, that the counter, used in the process of renaming the file - does not start from 0. This leads to fi...
3,463
865
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,608
unix.stackexchange.com
Bash negation of -a (file exists) does not change result, whereas for ! -e changes result
<p>I'm perplexed but still guess I misunderstood Bash somehow.</p> <pre><code>/$ if [ -e /bin/grep ]; then echo yea; else echo nay ; fi yea /$ if [ ! -e /bin/grep ]; then echo yea; else echo nay ; fi nay /$ if [ -a /bin/grep ]; then echo yea; else echo nay ; fi yea /$ if [ ! -a /bin/grep ]; then echo yea; else echo...
I'm perplexed but still guess I misunderstood Bash somehow. ``` /$ if [ -e /bin/grep ]; then echo yea; else echo nay ; fi yea /$ if [ ! -e /bin/grep ]; then echo yea; else echo nay ; fi nay /$ if [ -a /bin/grep ]; then echo yea; else echo nay ; fi yea /$ if [ ! -a /bin/grep ]; then echo yea; else echo nay ; fi yea ``` ...
16
1,005
2
6
2
[ "<bash><test>" ]
2021-11-08T13:45:40.837
2021-11-09T18:29:19.533
446,998
676,611
[ { "id": 676611, "body": "<p><code>-a</code> is both a unary (for <code>a</code>ccessible, added for compatibility with the Korn shell, but otherwise non-standard and now redundant with <code>-e</code>) and binary (for <code>a</code>nd, in POSIX (with XSI) but deprecated there) operator.</p>\n<p>Here <code>[...
`-a` is both a unary (for `a`ccessible, added for compatibility with the Korn shell, but otherwise non-standard and now redundant with `-e`) and binary (for `a`nd, in POSIX (with XSI) but deprecated there) operator. Here `[ ! -a /bin/grep ]` invokes the binary operator as required by POSIX. It's `[ "$a" -a "$b" ]` to t...
# Bash negation of -a (file exists) does not change result, whereas for ! -e changes result **Tags:** <bash><test> **Question (score 16):** I'm perplexed but still guess I misunderstood Bash somehow. ``` /$ if [ -e /bin/grep ]; then echo yea; else echo nay ; fi yea /$ if [ ! -e /bin/grep ]; then echo yea; else echo ...
5,543
1,385
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,733
unix.stackexchange.com
Need the exit code of condition function when a Bash "while" loop terminates
<p>I'm trying to get the exit code of the function that I'm repeatedly calling in the &quot;condition&quot; part of a Bash <code>while</code> loop:</p> <pre class="lang-bash prettyprint-override"><code>while &lt;function&gt;; do &lt;stuff&gt; done </code></pre> <p>When this loop terminates due to an error, I nee...
I'm trying to get the exit code of the function that I'm repeatedly calling in the "condition" part of a Bash `while` loop: ``` while ; do done ``` When this loop terminates due to an error, I need the exit code of `<function>`. Any thoughts on how I can get that?
14
960
4
0
2
[ "<bash><shell-script><error-handling>" ]
2021-11-09T11:55:47.747
2021-11-09T12:21:53.983
58,343
676,740
[ { "id": 676740, "body": "<p>You can capture the exit value from the condition and propagate that forward:</p>\n<pre><code>while rmdir FOO; ss=$?; [[ $ss -eq 0 ]]\ndo\n echo in loop\ndone\necho &quot;out of loop with ?=$? but ss=$ss&quot;\n</code></pre>\n<p>Output</p>\n<pre><code>rmdir: failed to remove '...
You can capture the exit value from the condition and propagate that forward: ``` while rmdir FOO; ss=$?; [[ $ss -eq 0 ]] do echo in loop done echo "out of loop with ?=$? but ss=$ss" ``` Output ``` rmdir: failed to remove 'FOO': No such file or directory out of loop with ?=0 but ss=1 ``` In this instance the exit statu...
# Need the exit code of condition function when a Bash "while" loop terminates **Tags:** <bash><shell-script><error-handling> **Question (score 14):** I'm trying to get the exit code of the function that I'm repeatedly calling in the "condition" part of a Bash `while` loop: ``` while ; do done ``` When this loop ter...
3,507
876
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,868
unix.stackexchange.com
In bash, what is the difference between IFS= and IFS=$'\n'
<p>Is there any difference between these three code blocks in bash?</p> <p>Using <code>IFS= </code>:</p> <pre class="lang-bsh prettyprint-override"><code>#!/usr/bin/env bash while IFS= read -r item; do echo &quot;[$item]&quot; done &lt;/dev/stdin </code></pre> <p>Using <code>IFS=$'\n'</code>:</p> <pre class="lang-b...
Is there any difference between these three code blocks in bash? Using `IFS= `: ``` #!/usr/bin/env bash while IFS= read -r item; do echo "[$item]" done </dev/stdin ``` Using `IFS=$'\n'`: ``` #!/usr/bin/env bash while IFS=$'\n' read -r item; do echo "[$item]" done </dev/stdin ``` Using `-d $'\n'`: ``` #!/usr/bin/env bas...
6
447
2
2
1
[ "<bash><read>" ]
2021-11-10T09:51:19.407
2021-11-10T09:58:17.200
50,703
null
[ { "id": 676870, "body": "<p><code>IFS=</code> and <code>IFS=$'\\n'</code> are identical when it comes to <code>read</code> (assuming the <code>read</code> delimiter is not changed from the default), since the only difference is whether a newline inside a line separates words, but a newline never appears ins...
`IFS=` and `IFS=$'\n'` are identical when it comes to `read` (assuming the `read` delimiter is not changed from the default), since the only difference is whether a newline inside a line separates words, but a newline never appears inside a line. `read` and `read -d $'\n'` are identical since `$'\n'` (newline) is the d...
# In bash, what is the difference between IFS= and IFS=$'\n' **Tags:** <bash><read> **Question (score 6):** Is there any difference between these three code blocks in bash? Using `IFS= `: ``` #!/usr/bin/env bash while IFS= read -r item; do echo "[$item]" done </dev/stdin ``` Using `IFS=$'\n'`: ``` #!/usr/bin/env bas...
6,604
1,651
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
676,944
unix.stackexchange.com
Is it mostly safe to install any software from default repos? ( "yum install" "apt-get install" , etc)
<p>Coming from the Windows world, where I'm in the habit of putting every new EXE or Installation file through something like Virustotal, or searching Stack Exchange/Reddit for reviews on the safety (no malware, no spyware, etc) of a particular piece of software before installing it.</p> <p>With Linux, is it <em>mostly...
Coming from the Windows world, where I'm in the habit of putting every new EXE or Installation file through something like Virustotal, or searching Stack Exchange/Reddit for reviews on the safety (no malware, no spyware, etc) of a particular piece of software before installing it. With Linux, is it mostly completely sa...
15
2,972
4
7
1
[ "<linux><software-installation><repository>" ]
2021-11-10T19:38:47.800
2021-11-11T12:39:32.683
500,782
676,954
[ { "id": 676954, "body": "<h2>Short answer</h2>\n<p>Yes, it is 'mostly safe' to install any utility or software so long as you are using the default repositories that come with new installs of the OS. The default repositories contain software that is tested by the developers and/or maintainers of the Linux d...
## Short answer Yes, it is 'mostly safe' to install any utility or software so long as you are using the default repositories that come with new installs of the OS. The default repositories contain software that is tested by the developers and/or maintainers of the Linux distro. ## Example There are levels of security....
# Is it mostly safe to install any software from default repos? ( "yum install" "apt-get install" , etc) **Tags:** <linux><software-installation><repository> **Question (score 15):** Coming from the Windows world, where I'm in the habit of putting every new EXE or Installation file through something like Virustotal,...
7,458
1,864
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
677,427
unix.stackexchange.com
Run command every time regex is matched, reading from stdin which does not have an EOF
<p>I am attempting to write a BASH script that creates a timestamp (to be written to file) every time a certain string is found within the output of dbus-monitor (parameters specified later in post). The main purpose of my script is to save the time (including milliseconds) and date whenever a song starts playing on Sp...
I am attempting to write a BASH script that creates a timestamp (to be written to file) every time a certain string is found within the output of dbus-monitor (parameters specified later in post). The main purpose of my script is to save the time (including milliseconds) and date whenever a song starts playing on Spoti...
6
557
4
3
1
[ "<bash><d-bus><notifications>" ]
2021-11-14T02:08:44.133
2021-11-15T14:20:30.500
469,714
677,460
[ { "id": 677464, "body": "<p>Use <code>awk</code> instead of <code>grep</code> - something like:</p>\n<pre><code>dbus-monitor ... | awk '/Spotify/ {\n system(&quot;date -u +%Y%m%d-%H%M%S.%N &gt;&gt; timestamp.txt&quot;)\n }'\n</code></pre>\n<p>(note the use of <code>%Y%m%d</code> instead of <code>%Y%M%D<...
Use `awk` instead of `grep` - something like: ``` dbus-monitor ... | awk '/Spotify/ { system("date -u +%Y%m%d-%H%M%S.%N >> timestamp.txt") }' ``` (note the use of `%Y%m%d` instead of `%Y%M%D` - capital-M is minutes, not months. And capital-D is equivalent to `%m/%d/%y`) This will use awk's `system()` function to run th...
# Run command every time regex is matched, reading from stdin which does not have an EOF **Tags:** <bash><d-bus><notifications> **Question (score 6):** I am attempting to write a BASH script that creates a timestamp (to be written to file) every time a certain string is found within the output of dbus-monitor (param...
3,996
999
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
677,478
unix.stackexchange.com
What does chmod g=- do?
<p>I'm wondering what do the <code>+</code>/<code>-</code> signs do in <code>chmod</code>?</p> <p>So for example, what does command <code>chmod u=-</code> do? My understanding is that it does nothing, because it lacks <code>r</code>/<code>w</code>/<code>x</code>. Is it correct? In order to actually do something, we wou...
I'm wondering what do the `+`/`-` signs do in `chmod`? So for example, what does command `chmod u=-` do? My understanding is that it does nothing, because it lacks `r`/`w`/`x`. Is it correct? In order to actually do something, we would have to specify which permission we want to add or subtract.
6
780
1
0
0
[ "<permissions>" ]
2021-11-14T15:06:57.167
2021-11-15T10:50:01.770
501,248
null
[ { "id": 677479, "body": "<p><code>=</code> with no permission bits <a href=\"https://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html\" rel=\"nofollow noreferrer\">clears all the permission bits corresponding to “who”</a>:</p>\n<blockquote>\n<p>Clear the file mode bits specified by the <strong>...
`=` with no permission bits clears all the permission bits corresponding to “who” (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html): Clear the file mode bits specified by the who value, or, if no who value is specified, all of the file mode bits specified in this volume of POSIX.1-2017. `-` with n...
# What does chmod g=- do? **Tags:** <permissions> **Question (score 6):** I'm wondering what do the `+`/`-` signs do in `chmod`? So for example, what does command `chmod u=-` do? My understanding is that it does nothing, because it lacks `r`/`w`/`x`. Is it correct? In order to actually do something, we would have to...
1,142
285
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
677,581
unix.stackexchange.com
Different timestamps in SFTP "ls -l" vs. "ls -lh"
<p>I have a 3rd-party SFTP server on which I want to check some file timestamps.</p> <p>However, I do get different results for the same file if I use <code>ls -l</code> vs. <code>ls -lh</code>:</p> <pre class="lang-none prettyprint-override"><code>sftp&gt; ls -l [...] -rwxrwxrwx 1 0 0 1963 Nov 15 ...
I have a 3rd-party SFTP server on which I want to check some file timestamps. However, I do get different results for the same file if I use `ls -l` vs. `ls -lh`: ``` sftp> ls -l [...] -rwxrwxrwx 1 0 0 1963 Nov 15 08:49 foo.txt [...] sftp> ls -lh [...] -rwxrwxrwx 0 0 0 1.9K Nov 15 07:49 foo.txt [...] sftp> ls -l foo.tx...
6
316
1
0
0
[ "<sftp><timestamps><timezone>" ]
2021-11-15T09:20:40.983
2021-11-18T10:12:23.900
30,497
677,584
[ { "id": 677584, "body": "<p>When listing a directory using SFTP protocol, the server provides both structured metadata of files (name, timestamp, size, etc) and textual listing of files.</p>\n<p>The OpenSSH <code>sftp</code> with <code>-l</code> switch prints the textual representation (as formatted by the ...
When listing a directory using SFTP protocol, the server provides both structured metadata of files (name, timestamp, size, etc) and textual listing of files. The OpenSSH `sftp` with `-l` switch prints the textual representation (as formatted by the server). In this case the times are printed according to the server's ...
# Different timestamps in SFTP "ls -l" vs. "ls -lh" **Tags:** <sftp><timestamps><timezone> **Question (score 6):** I have a 3rd-party SFTP server on which I want to check some file timestamps. However, I do get different results for the same file if I use `ls -l` vs. `ls -lh`: ``` sftp> ls -l [...] -rwxrwxrwx 1 0 0 ...
2,953
738
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
677,591
unix.stackexchange.com
How to restore a broken sudoers file without being able to use sudo?
<p>I'm getting the following error from <code>sudo</code>:</p> <pre><code>$ sudo ls sudo: /etc/sudoers is owned by uid 1000, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin </code></pre> <p>Of course I can't <code>chown</code> it back to <code>root</code> without usin...
I'm getting the following error from `sudo`: ``` $ sudo ls sudo: /etc/sudoers is owned by uid 1000, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin ``` Of course I can't `chown` it back to `root` without using `sudo`. We don't have a password on the `root` account eit...
29
3,043
3
4
10
[ "<linux><sudo>" ]
2021-11-15T10:24:50.760
2021-11-15T10:44:04.657
177,652
677,592
[ { "id": 677592, "body": "<p>The procedure described <a href=\"https://metamug.com/amp/networking/unable-to-access-sudoers-owned-by-uid-1000.html\" rel=\"noreferrer\">here</a> (which may itself be an imperfect copy of <a href=\"https://askubuntu.com/a/1053617/77109\">this Ask Ubuntu answer</a>) performed the...
The procedure described here (https://metamug.com/amp/networking/unable-to-access-sudoers-owned-by-uid-1000.html) (which may itself be an imperfect copy of this Ask Ubuntu answer (https://askubuntu.com/a/1053617/77109)) performed the miracle. I'm copying it here, and adding some more explanations. ### Procedure - Open ...
# How to restore a broken sudoers file without being able to use sudo? **Tags:** <linux><sudo> **Question (score 29):** I'm getting the following error from `sudo`: ``` $ sudo ls sudo: /etc/sudoers is owned by uid 1000, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plug...
5,511
1,377
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
677,817
unix.stackexchange.com
Escape characters in sed transliterate
<p>I want to use <code>sed</code>'s transliterate (<code>y///</code>) to replace one set of characters by another.</p> <p>I would expect this to work just as well as using the <code>tr</code> program.</p> <pre><code>$ echo '[]{}abc' | tr '[ab}' 'gefh' g]{hefc </code></pre> <p>However, when I go to perform this same op...
I want to use `sed`'s transliterate (`y///`) to replace one set of characters by another. I would expect this to work just as well as using the `tr` program. ``` $ echo '[]{}abc' | tr '[ab}' 'gefh' g]{hefc ``` However, when I go to perform this same operation with sed, I see the following error: ``` $ echo '[]{}abc' | ...
7
145
2
0
1
[ "<sed><freebsd><string><macos><tr>" ]
2021-11-16T17:33:59.967
2021-11-22T16:47:24.290
259,874
677,824
[ { "id": 677824, "body": "<p>Assuming you are on macOS (the only system whose native <code>sed</code> I can get to display this issue, although I haven't checked on FreeBSD whence macOS's <code>sed</code> comes):</p>\n<pre class=\"lang-bsh prettyprint-override\"><code>$ echo '[]{}abc' | sed 'y/[ab}/gefh/'\ns...
Assuming you are on macOS (the only system whose native `sed` I can get to display this issue, although I haven't checked on FreeBSD whence macOS's `sed` comes): ``` $ echo '[]{}abc' | sed 'y/[ab}/gefh/' sed: 1: "y/[ab}/gefh/": unbalanced brackets ([]) ``` ``` $ echo '[]{}abc' | sed 'y/\[ab}/gefh/' sed: 1: "y/\[ab}/gef...
# Escape characters in sed transliterate **Tags:** <sed><freebsd><string><macos><tr> **Question (score 7):** I want to use `sed`'s transliterate (`y///`) to replace one set of characters by another. I would expect this to work just as well as using the `tr` program. ``` $ echo '[]{}abc' | tr '[ab}' 'gefh' g]{hefc ``...
3,799
949
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
677,909
unix.stackexchange.com
Unary test -v on an array element
<p>In bash, the conditional expression with the unary test <code>-v myvariable</code> tests wether the variable <code>myvariable</code> has been set. Note that <code>myvariable</code> should not be expanded by prefixing it with a dollar, so <strong>not</strong> <code>$myvariable</code>. Now I find that for array elemen...
In bash, the conditional expression with the unary test `-v myvariable` tests wether the variable `myvariable` has been set. Note that `myvariable` should not be expanded by prefixing it with a dollar, so not `$myvariable`. Now I find that for array elements the conditional expression `-v myarray[index]` works well too...
7
210
1
0
0
[ "<bash><array><test>" ]
2021-11-17T11:01:55.387
2021-11-18T14:28:35.747
376,817
677,920
[ { "id": 677920, "body": "<p>In <code>bash</code>, you can do:</p>\n<pre><code>[ -v 'a[2]' ]\n</code></pre>\n<p>or</p>\n<pre><code>[[ -v a[2] ]]\n</code></pre>\n<p>To test whether the array element of index 2, or the associative array element of key &quot;2&quot; is set (even if that's to an empty string), b...
In `bash`, you can do: ``` [ -v 'a[2]' ] ``` or ``` [[ -v a[2] ]] ``` To test whether the array element of index 2, or the associative array element of key "2" is set (even if that's to an empty string), but note: - When using the `[` (aka `test`) command, you need to quote the `[` and `]` characters as they are globbi...
# Unary test -v on an array element **Tags:** <bash><array><test> **Question (score 7):** In bash, the conditional expression with the unary test `-v myvariable` tests wether the variable `myvariable` has been set. Note that `myvariable` should not be expanded by prefixing it with a dollar, so not `$myvariable`. Now...
7,969
1,992
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
678,228
unix.stackexchange.com
Does linux kernel use virtual memory (for its data)?
<p>Does linux kernel make use of virtual memory for its data structures (page tables, descriptors, etc.)? More specifically:</p> <p>Are kernel space addresses translated in the MMU (pagetable walking)?</p> <p>Could kernel memory get swapped out?</p> <p>Could a memory access to a kernel data structure cause a page fault...
Does linux kernel make use of virtual memory for its data structures (page tables, descriptors, etc.)? More specifically: Are kernel space addresses translated in the MMU (pagetable walking)? Could kernel memory get swapped out? Could a memory access to a kernel data structure cause a page fault? Are there differences ...
9
875
1
0
1
[ "<linux><kernel><virtual-memory>" ]
2021-11-19T08:02:42.673
2021-11-20T08:46:47.600
501,953
678,229
[ { "id": 678229, "body": "<blockquote>\n<p>Are kernel space addresses translated in the MMU (pagetable walking)?</p>\n</blockquote>\n<p>Yes, all addresses are translated in the MMU; see <a href=\"https://unix.stackexchange.com/q/473274/86440\">Is the MMU inside of Unix/Linux kernel? or just in a hardware dev...
Are kernel space addresses translated in the MMU (pagetable walking)? Yes, all addresses are translated in the MMU; see Is the MMU inside of Unix/Linux kernel? or just in a hardware device with its own memory? (https://unix.stackexchange.com/q/473274/86440) for details. Could kernel memory get swapped out? A kernel cou...
# Does linux kernel use virtual memory (for its data)? **Tags:** <linux><kernel><virtual-memory> **Question (score 9):** Does linux kernel make use of virtual memory for its data structures (page tables, descriptors, etc.)? More specifically: Are kernel space addresses translated in the MMU (pagetable walking)? Coul...
1,730
432
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
678,461
unix.stackexchange.com
Finding duplicate files with same filename AND exact same size
<p>I have a huge songs folder with a messy structure and files duplicated in multiple folders.</p> <p>I need a recommendation for a tool or a script that can find and remove duplicates with simple two matches:</p> <ol> <li>Exact same file name</li> <li>Exact same file size</li> </ol> <p>In this case, <code>song.mp3</co...
I have a huge songs folder with a messy structure and files duplicated in multiple folders. I need a recommendation for a tool or a script that can find and remove duplicates with simple two matches: - Exact same file name - Exact same file size In this case, `song.mp3` with 1234 bytes of file size is stored in `/songs...
6
357
3
3
2
[ "<fedora><find><search><mp3><deduplication>" ]
2021-11-21T04:22:40.480
2021-11-24T09:30:50.723
101,463
null
[ { "id": 678470, "body": "<p><a href=\"https://github.com/pauldreik/rdfind\" rel=\"nofollow noreferrer\"><code>rdfind</code></a> may do what you want, but you'll need to depend on a cryptographic hash/checksum (md5, sha1 or sha256) in lieu of the filesize.</p>\n<p>The hash is a stronger criteria than filesiz...
`rdfind` (https://github.com/pauldreik/rdfind) may do what you want, but you'll need to depend on a cryptographic hash/checksum (md5, sha1 or sha256) in lieu of the filesize. The hash is a stronger criteria than filesize, but this may or may not be what you want. For example, consider all of the metadata in a music fil...
# Finding duplicate files with same filename AND exact same size **Tags:** <fedora><find><search><mp3><deduplication> **Question (score 6):** I have a huge songs folder with a messy structure and files duplicated in multiple folders. I need a recommendation for a tool or a script that can find and remove duplicates ...
2,035
508
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
678,664
unix.stackexchange.com
Why does man have its own user?
<p>I'm simply curious as to why <code>man</code> has its own user.</p> <pre><code>$ grep man /etc/passwd man:x:6:12:man:/var/cache/man:/usr/sbin/nologin </code></pre> <p>I'm using Debian Buster.</p>
I'm simply curious as to why `man` has its own user. ``` $ grep man /etc/passwd man:x:6:12:man:/var/cache/man:/usr/sbin/nologin ``` I'm using Debian Buster.
12
2,041
1
3
0
[ "<man>" ]
2021-11-22T23:51:37.870
2021-11-23T08:26:53.923
224,077
678,686
[ { "id": 678686, "body": "<p><code>man</code> (at least, <a href=\"https://www.nongnu.org/man-db/\" rel=\"noreferrer\">the version implemented in <code>man-db</code></a>) can be set up with its own user so that its “cache” (which includes indexes, as used <em>e.g.</em> by <code>whatis</code>) can be owned an...
`man` (at least, the version implemented in `man-db` (https://www.nongnu.org/man-db/)) can be set up with its own user so that its “cache” (which includes indexes, as used e.g. by `whatis`) can be owned and updated by that user (instead of `root`). Additionally, `man` can be setuid to that user, allowing it to write to...
# Why does man have its own user? **Tags:** <man> **Question (score 12):** I'm simply curious as to why `man` has its own user. ``` $ grep man /etc/passwd man:x:6:12:man:/var/cache/man:/usr/sbin/nologin ``` I'm using Debian Buster. ### Answer (score 18 · accepted) `man` (at least, the version implemented in `man-db...
2,185
546
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
678,854
unix.stackexchange.com
Why can't the extended glob */ be negated with !(*/)?
<p>In bash, if we activate the <code>extglob</code> shell option, we can do fancy stuff like negating a glob (from <code>man bash</code>):</p> <pre><code> If the extglob shell option is enabled using the shopt builtin, sev‐ eral extended pattern matching operators are recognized. In the fol‐ lowing descrip...
In bash, if we activate the `extglob` shell option, we can do fancy stuff like negating a glob (from `man bash`): ``` If the extglob shell option is enabled using the shopt builtin, sev‐ eral extended pattern matching operators are recognized. In the fol‐ lowing description, a pattern-list is a list of one or more patt...
6
257
1
0
0
[ "<bash><wildcards>" ]
2021-11-24T10:03:38.193
2021-11-24T17:52:23.787
22,222
null
[ { "id": 678859, "body": "<p>Because globs don't cross <code>/</code> boundaries. Except for the special case of <code>**/</code>¹ (originally from <code>zsh</code>, <a href=\"/a/62665\">now also found in a few other shells</a> often after setting an option (<code>shopt -s globstar</code> for bash)), a glob ...
Because globs don't cross `/` boundaries. Except for the special case of `**/`¹ (originally from `zsh`, now also found in a few other shells (/a/62665) often after setting an option (`shopt -s globstar` for bash)), a glob operator cannot match something that contains a `/` as they are applied on a directory listing. Th...
# Why can't the extended glob */ be negated with !(*/)? **Tags:** <bash><wildcards> **Question (score 6):** In bash, if we activate the `extglob` shell option, we can do fancy stuff like negating a glob (from `man bash`): ``` If the extglob shell option is enabled using the shopt builtin, sev‐ eral extended pattern ...
4,653
1,163
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
678,930
unix.stackexchange.com
How do you output a multi-line string that includes slashes and other special characters?
<p>I would like to output this on completion of my bash script.</p> <pre><code> /\_/\ ( o.o ) &gt; ^ &lt; </code></pre> <p>I have tried the following but all return errors.</p> <pre><code>echo /\\_/\\\n\( o.o \)\n &gt; ^ &lt; echo \/\\_\/\\\r\n( o.o )\r\n &gt; ^ &lt; echo /\\_/\\\n\( o.o \)\n \&gt; ^ &lt; </code></pr...
I would like to output this on completion of my bash script. ``` /\_/\ ( o.o ) > ^ ^ ^ ^ < ``` How do I escape these characters so that bash renders them as a string?
18
1,020
2
8
2
[ "<bash><shell-script><echo><escape-characters><here-document>" ]
2021-11-24T18:35:36.857
2021-11-29T10:29:54.163
465,869
678,931
[ { "id": 678931, "body": "<p>In this case, I'd use <code>cat</code> with a (quoted) here-document:</p>\n<pre class=\"lang-bsh prettyprint-override\"><code>cat &lt;&lt;'END_CAT'\n /\\_/\\\n( o.o )\n &gt; ^ &lt;\nEND_CAT\n</code></pre>\n<p>This is the best way of ensuring the ASCII art is outputted the way it ...
In this case, I'd use `cat` with a (quoted) here-document: ``` cat ^ ^ second argument to `printf`. The first argument to `printf` is always a single quoted formatting string, where backslashes are far from inactive. Or multiple strings with `printf` (one per line): ``` printf '%s\n' ' /\_/\' '( o.o )' ' > ^ ^ ^ <' ```...
# How do you output a multi-line string that includes slashes and other special characters? **Tags:** <bash><shell-script><echo><escape-characters><here-document> **Question (score 18):** I would like to output this on completion of my bash script. ``` /\_/\ ( o.o ) > ^ ^ ^ ^ < ``` How do I escape these characters s...
1,782
445
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
679,021
unix.stackexchange.com
Bash background execution not returning
<p>I am trying to write a script that has the purpose to parallelize an execution (a program that creates some files) running the processes in background and, when all commands in the for loop are done, will perform an extra command (namely move all produced files in another folder). This is what I came out with for th...
I am trying to write a script that has the purpose to parallelize an execution (a program that creates some files) running the processes in background and, when all commands in the for loop are done, will perform an extra command (namely move all produced files in another folder). This is what I came out with for the m...
5
117
1
4
1
[ "<bash><shell-script><parallelism>" ]
2021-11-25T10:42:13.383
2021-11-25T11:18:41.103
210,461
679,036
[ { "id": 679036, "body": "<p>If the csv files are generated by the java command, this will fail because the <code>mv</code> will run before any files have been generated. Since all java processes are sent to the background, the loop will finish almost immediately, so the script continues to the <code>mv</cod...
If the csv files are generated by the java command, this will fail because the `mv` will run before any files have been generated. Since all java processes are sent to the background, the loop will finish almost immediately, so the script continues to the `mv` which finds no files to move and so does nothing. A simple ...
# Bash background execution not returning **Tags:** <bash><shell-script><parallelism> **Question (score 5):** I am trying to write a script that has the purpose to parallelize an execution (a program that creates some files) running the processes in background and, when all commands in the for loop are done, will pe...
2,494
623
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
679,064
unix.stackexchange.com
LD_PRELOAD for setuid binary
<p>I'm trying to override malloc/free functions for the program, that requires setuid/setgid permissions. I use the LD_PRELOAD variable for this purpose. According to the <a href="https://linux.die.net/man/8/ld.so" rel="noreferrer">ld documentation</a>, I need to put my library into one of the standard search directori...
I'm trying to override malloc/free functions for the program, that requires setuid/setgid permissions. I use the LD_PRELOAD variable for this purpose. According to the ld documentation (https://linux.die.net/man/8/ld.so), I need to put my library into one of the standard search directories (I chose /usr/lib) and give i...
7
636
3
3
0
[ "<linux><rhel><ld>" ]
2021-11-25T16:03:03.820
2021-11-26T10:34:02.540
502,776
679,106
[ { "id": 679106, "body": "<blockquote>\n<p>According to the ld documentation, I need to put my library into one of the standard search directories (I chose <code>/usr/lib</code>)</p>\n</blockquote>\n<p>That was the mistake. You should've put it in <code>/usr/lib64</code> (assuming that your machine is a x86_...
According to the ld documentation, I need to put my library into one of the standard search directories (I chose `/usr/lib`) That was the mistake. You should've put it in `/usr/lib64` (assuming that your machine is a x86_64). I've just tried the recipe from the manpage on a Centos 7 VM (which should be ~identical to RH...
# LD_PRELOAD for setuid binary **Tags:** <linux><rhel><ld> **Question (score 7):** I'm trying to override malloc/free functions for the program, that requires setuid/setgid permissions. I use the LD_PRELOAD variable for this purpose. According to the ld documentation (https://linux.die.net/man/8/ld.so), I need to pu...
2,335
583
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
679,265
unix.stackexchange.com
How delete BILLIONS of files efficiently on linux?
<p>A storage system had collected 1.7 billion files from revision backups over a couple of years and was getting a bit full.</p> <p>So I started to delete all files older than five years. Which I assume are around 1.7 billion (!!!) files with around 90 TByte of data - I have to estimate because even a mere find or du w...
A storage system had collected 1.7 billion files from revision backups over a couple of years and was getting a bit full. So I started to delete all files older than five years. Which I assume are around 1.7 billion (!!!) files with around 90 TByte of data - I have to estimate because even a mere find or du would take ...
8
283
3
9
0
[ "<linux><files><delete>" ]
2021-11-27T04:48:37.097
2021-12-04T04:21:38.047
502,973
null
[ { "id": 679382, "body": "<p>Without access to the system and without experimentation, it would be Difficult to check what works, what helps and what is useless; but my way would be like this:</p>\n<p>In short : Do not Delete the unwanted files, rather <code>mv</code> them to Directories (which must be a fas...
Without access to the system and without experimentation, it would be Difficult to check what works, what helps and what is useless; but my way would be like this: In short : Do not Delete the unwanted files, rather `mv` them to Directories (which must be a fast operation) and then truncate the files here to 0 size (to...
# How delete BILLIONS of files efficiently on linux? **Tags:** <linux><files><delete> **Question (score 8):** A storage system had collected 1.7 billion files from revision backups over a couple of years and was getting a bit full. So I started to delete all files older than five years. Which I assume are around 1.7...
4,000
1,000
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
679,495
unix.stackexchange.com
Now that apt-key is deprecated, how do you add an Ubuntu PPA as a Debian APT source?
<h2>Background</h2> <p>In the past, if you wanted to install software from an Ubuntu PPA in Debian, the approach was to</p> <ol> <li><p>import/trust the developer's GPG key from keyserver.ubuntu.com,</p> <pre class="lang-bsh prettyprint-override"><code>$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com E58...
## Background In the past, if you wanted to install software from an Ubuntu PPA in Debian, the approach was to - import/trust the developer's GPG key from keyserver.ubuntu.com, ``` $ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com E58A9D36647CAE7F ``` - then add the repository to `/etc/apt/sources.list.d/...
13
501
1
0
2
[ "<debian><apt><gpg><ppa><apt-key>" ]
2021-11-29T07:23:41.947
2021-11-29T16:38:21.570
176,219
null
[ { "id": 679498, "body": "<p><code>apt-key adv</code> basically passes CLI arguments/options directly to <code>gpg</code>, but only after setting up a temporary keyring. You can do the same manually with:</p>\n<pre class=\"lang-bsh prettyprint-override\"><code>$ export GNUPGHOME=&quot;$(mktemp -d)&quot; # o...
`apt-key adv` basically passes CLI arguments/options directly to `gpg`, but only after setting up a temporary keyring. You can do the same manually with: ``` $ export GNUPGHOME="$(mktemp -d)" # optional (skipping this means keys will be imported to your GPG keyring) $ gpg --recv-keys --keyserver keyserver.ubuntu.com 54...
# Now that apt-key is deprecated, how do you add an Ubuntu PPA as a Debian APT source? **Tags:** <debian><apt><gpg><ppa><apt-key> **Question (score 13):** ## Background In the past, if you wanted to install software from an Ubuntu PPA in Debian, the approach was to - import/trust the developer's GPG key from keyserv...
4,085
1,021
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
679,569
unix.stackexchange.com
What is the difference between /lib and /usr/lib and /var/lib?
<p>What is the difference between <code>/lib</code> and <code>/usr/lib</code> and <code>/var/lib</code>? Some of the files are symbolic links that &quot;duplicate&quot; content of other directories.</p>
What is the difference between `/lib` and `/usr/lib` and `/var/lib`? Some of the files are symbolic links that "duplicate" content of other directories.
13
2,651
2
0
4
[ "<directory-structure>" ]
2021-11-29T23:08:03.487
2021-12-05T03:00:48.510
496,510
679,571
[ { "id": 679571, "body": "<p>Someone else can probably explain this with much more detail and historical reference but the short answer:</p>\n<h2><a href=\"https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s09.html\" rel=\"nofollow noreferrer\">/lib</a></h2>\n<p>is a place for the essential standard libra...
Someone else can probably explain this with much more detail and historical reference but the short answer: ## /lib (https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s09.html) is a place for the essential standard libraries. Think of libraries required for your system to run. If something in `/bin` or `/sbin` needs...
# What is the difference between /lib and /usr/lib and /var/lib? **Tags:** <directory-structure> **Question (score 13):** What is the difference between `/lib` and `/usr/lib` and `/var/lib`? Some of the files are symbolic links that "duplicate" content of other directories. ### Answer (score 14 · accepted) Someone ...
2,512
628
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
679,615
unix.stackexchange.com
Why does 'find' command on Alpine seem to require escaping '?' but not on Ubuntu?
<p>Is this related to a bug, etc. or this is how it should be?</p> <p><code>find ./frontend -mindepth 1 -regex '^./dir1/dir2\(/.*\)?'</code> works on Ubuntu but not Alpine (docker)</p> <p><code>find ./frontend -mindepth 1 -regex '^./dir1/dir2\(/.*\)\?'</code> works on Alpine (docker) but not Ubuntu</p> <p>Alpine: 3.14<...
Is this related to a bug, etc. or this is how it should be? `find ./frontend -mindepth 1 -regex '^./dir1/dir2\(/.*\)?'` works on Ubuntu but not Alpine (docker) `find ./frontend -mindepth 1 -regex '^./dir1/dir2\(/.*\)\?'` works on Alpine (docker) but not Ubuntu Alpine: 3.14 Ubuntu: 18.04
5
393
1
2
0
[ "<find><regular-expression><alpine-linux>" ]
2021-11-30T10:26:51.557
2021-11-30T11:58:35.247
503,315
679,630
[ { "id": 679630, "body": "<p>They use <a href=\"https://unix.stackexchange.com/questions/119905/why-does-my-regular-expression-work-in-x-but-not-in-y\">different syntaxes for regular expressions</a>.</p>\n<p><a href=\"https://www.gnu.org/software/findutils/manual/html_node/find_html/Full-Name-Patterns.html#i...
They use different syntaxes for regular expressions (https://unix.stackexchange.com/questions/119905/why-does-my-regular-expression-work-in-x-but-not-in-y). GNU find's `-regex` (https://www.gnu.org/software/findutils/manual/html_node/find_html/Full-Name-Patterns.html#index-_002dregex) uses Emacs regular expressions (ht...
# Why does 'find' command on Alpine seem to require escaping '?' but not on Ubuntu? **Tags:** <find><regular-expression><alpine-linux> **Question (score 5):** Is this related to a bug, etc. or this is how it should be? `find ./frontend -mindepth 1 -regex '^./dir1/dir2\(/.*\)?'` works on Ubuntu but not Alpine (docker...
3,349
837
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...
679,925
unix.stackexchange.com
Why does my dd Full Disk Copy Keep failing at 8 GB?
<p>I am trying to clone a 500 GB SSD to a 1TB SSD. For some reason, it keeps failing when the data being copied reaches 8GB. This is the third 1TB SSD I've tried this on and they all get stuck at the same place. I've ran the following command:</p> <pre><code>dd if=/dev/sda of=/dev/sdb bs=1024k status=progress </code...
I am trying to clone a 500 GB SSD to a 1TB SSD. For some reason, it keeps failing when the data being copied reaches 8GB. This is the third 1TB SSD I've tried this on and they all get stuck at the same place. I've ran the following command: ``` dd if=/dev/sda of=/dev/sdb bs=1024k status=progress ``` I've also tried to ...
11
1,850
2
3
0
[ "<linux><dd><gparted><clonezilla>" ]
2021-12-02T16:51:46.743
2021-12-03T19:15:57.007
289,356
679,934
[ { "id": 679934, "body": "<p>The error is, <code>dd: error reading '/dev/sda': Input/output error</code>, which tells you that the problem is <em>reading</em> the source disk and not writing to the destination. You can replace the destination disk as many times as you like and it won't resolve the issue of r...
The error is, `dd: error reading '/dev/sda': Input/output error`, which tells you that the problem is reading the source disk and not writing to the destination. You can replace the destination disk as many times as you like and it won't resolve the issue of reading the source. Instead of using `dd`, consider rescuing ...
# Why does my dd Full Disk Copy Keep failing at 8 GB? **Tags:** <linux><dd><gparted><clonezilla> **Question (score 11):** I am trying to clone a 500 GB SSD to a 1TB SSD. For some reason, it keeps failing when the data being copied reaches 8GB. This is the third 1TB SSD I've tried this on and they all get stuck at th...
3,811
952
{ "source": "stackexchange-archive.org", "license": "CC BY-SA 4.0", "dump_version": "2021-12-07", "extraction_date": "2026-07-02T12:57:40Z", "parser_version": "stackexchange-streaming-v1.0", "site_name": "unix.stackexchange.com", "original_7z_url": "https://archive.org/download/stack-exchange-2021-12-07/u...