Answer by Kamil Maciorowski for Loop of screens with a loop inside does not...
You can concatenate strings quoted differently (or not quoted at all). E.g. in "screen-${i}-"iter'-${j}' there is double-quoted screen-${i}-, unquoted iter and single quoted -${j}. This way you can...
View ArticleAnswer by Kamil Maciorowski for How to use the `tax[13]-eq-dc` regex in a...
tax[13]-eq-dc may look like a regex but in your code Bash does not treat it as such. Even if it did, a regex is to match something. What do you want to match?Bash treats your tax[13]-eq-dc as a...
View ArticleAnswer by Kamil Maciorowski for If I deleted a partition, will that delete...
If I deleted a partition, will that delete the data on this partition?Strictly: no. Deleting a partition means removing the relevant entry from the partition table. This does nothing to data inside the...
View ArticleAnswer by Kamil Maciorowski for Beaglebone Black filesystem resize -...
Partitions and filesystems are not the same. At no point the filesystem was destroyed.Partition is just a part of a larger device identified by some entry in the partition table. fdisk manipulates this...
View ArticleAnswer by Kamil Maciorowski for How to make bash script output compatible...
Use test -t 1 or test -t 2 to test if (respectively) stdout or stderr is associated with a terminal.-t file_descriptorTrue if file descriptor number file_descriptor is open and is associated with a...
View ArticleAnswer by Kamil Maciorowski for Syntax error near unexpected token ('
I don't know what dx run swiss-army-knife does, but you're passing -icmd="${my_command}", where ${my_command} expands to a string, where the already expanded ${vcf_file_dir} is. That contains (VCFs)...
View ArticleAnswer by Kamil Maciorowski for Linux shell command to replace path with file...
My idea is to convert the input file to a shell script in a form:cat <<EOF$…EOF$where … is the original content of the input file, but with <pathname> replaced by $(cat pathname), so when...
View ArticleAnswer by Kamil Maciorowski for Tmux tile layout arranges 8 panes into 3x3...
General approachThe select-layout tmux command allows you to specify a layout in the format used by window_layout or window_visible_layout tmux variable. This leads to the following solution:One-time...
View ArticleAnswer by Kamil Maciorowski for Passing variables to docker run from within a...
General informationThe quoting in your code is very wrong. Important information:An unquoted variable undergoes word splitting and filename generation.Quotes that appear from variable expansion are not...
View ArticleAnswer by Kamil Maciorowski for display path to files with same names
With awk:find . | awk -F / ' {t[$NF]=t[$NF] $0 ORS; c[$NF]++} END {for (k in t) if (c[k]>1) printf "%s", t[k]}'Notes:The above code processes pathnames as newline-terminated strings; pathnames with...
View ArticleAnswer by Kamil Maciorowski for chown -R exclude some directory
In Linux the most general tool to do something to files meeting some criteria is find. Few other answers base on the find … | xargs … idea, which is robust only if it uses null-terminated strings. This...
View ArticleAnswer by Kamil Maciorowski for Unix script with a trap inside ssh
Normally ssh is able to "relay" Ctrl+c and cause SIGINT on the remote side, when the following happens:ssh requests and gets a tty on the remote side,ssh configures the local tty, so Ctrl+c is not...
View ArticleAnswer by Kamil Maciorowski for Can I create an image with a specific size in...
Few other answers calculate how many trailing zeros you need to append, then they append. In Linux there's this simple way:truncate -s 5MB image(this assumes you want 5 MB, i.e. 5*1000*1000 bytes. For...
View ArticleAnswer by Kamil Maciorowski for Uses of single-partition disk configuration
Is there any reason why a partition would be used in this case rather than a whole disk?Few reasons I can think of:People (read: future admins) expect partition tables. Having them saves WTF moments....
View ArticleAnswer by Kamil Maciorowski for Windows does not mount USB NTFS superfloppy
I can reproduce your problem and explain it. And fix it, I think.Short explanationFor some reason the first sector of your disk, when interpreted as MBR, contains semi-valid partition table. Either OS...
View ArticleAnswer by Kamil Maciorowski for Safest way to back up old, failing drives?
In general there are at least two strategies:Copy the whole of the disk with a tool designated to deal with read errors. The standard tool is GNU ddrescue, I have used it many times to image block...
View ArticleAnswer by Kamil Maciorowski for Behavior of SIGINT with Bash
What you observed is a consequence of an approach called wait and cooperative exit (WCE). It's about handling SIGINT/SIGQUIT.You can read about WCE (and about alternative approaches) here: Proper...
View ArticleAnswer by Kamil Maciorowski for fdisk - Hex codes list - which ones are NTFS...
It depends on what exactly you are asking.If you're asking what partition types can hold a filesystem of the type NTFS or FAT32, the answer is any. The type of a partition is only to "encode" the...
View ArticleAnswer by Kamil Maciorowski for shell helper function wrapping `find` and...
The following function will convert each argument being exactly -exclude_hazards to arguments responsible for the desired exclusions:my_find () (#!/bin/shmark=for arg do [ -z "$mark" ] && { set...
View ArticleComment by Kamil Maciorowski on Inconsistent free space
What is the output of df /? (without -h). Please [edit] and post it as text, not image.
View Article