Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
1
votes
1
answers
2092
views
LS_COLORS not respected on Cygwin
Whilst trying to configure ls' colors on Cygwin (specifically the distro babun), I found that the custom extension colors that were in the LS_COLORS environment variable weren't being used. Here's an example: `di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43:*.tar=...
Whilst trying to configure ls' colors on Cygwin (specifically the distro babun), I found that the custom extension colors that were in the LS_COLORS environment variable weren't being used. Here's an example:
di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43:*.tar=1;31
Normally, the ls
command should output white text for every file EXCEPT .tar files, which should be red. However, what I'm getting is white text for everything INCLUDING .tar files. I wonder if it's a problem with MSYS ls
, or if it's a problem with my shell (zsh).
Basically, the custom file extension colors that I try and define fall back to the default file color.
Here's the corresponding part of my .zshrc
where I've defined the ls
alias and run the output of dircolors
.
eval "dircolors /etc/DIR_COLORS
"
alias ls="/bin/ls --color=auto"
IllinoisJackson
(11 rep)
Mar 21, 2017, 09:14 PM
• Last activity: Jun 22, 2025, 03:05 PM
1
votes
0
answers
26
views
Msys64/mingw64 trouble, why its 'ln' command did `copy`
On Msys2 env.: $ cd /c/msys64/mingw64/lib/ $ ln -s libz.dll.a libzlib.dll.a But confusingly why ln command did `copy` instead of linking it symbolically ? $ ls -l libz* -rw-r--r-- 1 abdu None 108700 Jan 23 2024 libz.a -rw-r--r-- 1 abdu None 65914 Jan 23 2024 libz.dll.a -rw-r--r-- 1 abdu None 65914 J...
On Msys2 env.:
$ cd /c/msys64/mingw64/lib/
$ ln -s libz.dll.a libzlib.dll.a
But confusingly why
ln
command did
copy
instead of linking it symbolically ?
$ ls -l libz*
-rw-r--r-- 1 abdu None 108700 Jan 23 2024 libz.a
-rw-r--r-- 1 abdu None 65914 Jan 23 2024 libz.dll.a
-rw-r--r-- 1 abdu None 65914 Jan 23 2024 libzlib.dll.a
-rw-r--r-- 1 abdu None 2298 Dec 13 03:15 libzoneoc.a
Please one help out of confusion to solution
Dumb
(11 rep)
Dec 22, 2024, 12:18 AM
• Last activity: Dec 22, 2024, 07:00 AM
0
votes
1
answers
73
views
package a single text file into a .deb (possibly on MSYS2/MINGW64)?
I have found a similar question on https://askubuntu.com/questions/144547/how-to-package-a-single-text-file-into-a-deb - unfortunately there is no answer I can use. Basically, I want to manage a text file, say `myapp.txt.config`, in git; and then, I'd want to create a `.deb` package that copies it o...
I have found a similar question on https://askubuntu.com/questions/144547/how-to-package-a-single-text-file-into-a-deb - unfortunately there is no answer I can use.
Basically, I want to manage a text file, say
myapp.txt.config
, in git; and then, I'd want to create a .deb
package that copies it on Raspberry Pi in /usr/share/myapp/myapp.txt.config
. However, most of the work I do in this repository is in MSYS2/MINGW64 on Windows 10, so I would like to avoid the round-trip to a Raspberry Pi, just to build the .deb package. Since this is just a text file, I'd like a single .deb to be valid for all distributions (stretch, bookworm for Raspbian).
How would I go about implementing this? I can see that a .deb
file is an [ar archive with tar archives inside](https://en.wikipedia.org/wiki/Deb_(file_format)) - and there is working ar
, tar
, install
, bash
, python3
, perl
, make
on MSYS2/MINGW64, however there are no Debian tools in the MSYS2/MINGW64 repos, as MSYS2 uses pacman
instead.
I have seen in https://askubuntu.com/questions/90764/how-do-i-create-a-deb-package-for-a-single-python-script that the basic source package layout would be:
myapp-config/
-- myapp.txt.config
-- debian/
-- changelog
-- copyright
-- compat
-- rules
-- control
-- install
... but I'd have to run dch --create
to "create a properly formatted debian/changelog
entry", and debuild --no-tgz-check
to build; though dch
is a Perl script ([devscripts/scripts/debchange.pl](https://github.com/Debian/devscripts/blob/master/scripts/debchange.pl)) , and so is debuild
([devscripts/scripts/debuild.pl](https://github.com/Debian/devscripts/blob/master/scripts/debuild.pl)) ; but I cannot tell to what extent they will work on MSYS2/MINGW64.
I thought also of creating a Makefile with a [single install
entry](https://stackoverflow.com/questions/39892692/how-to-implement-make-install-in-a-makefile) :
install:
install -D -m 644 myapp.txt.config /usr/share/myapp/
... and then calling [checkinstall](https://github.com/ruxkor/checkinstall/blob/master/checkinstall) on it to create a deb package; checkinstall
seems to be bash, but I cannot tell if it will run on MSYS2/MINGW64, as it probably needs sudo
- also that github version is from 13 years ago, and it might even be that checkinstall
is [no longer being maintained](https://askubuntu.com/questions/1138384/why-is-checkinstall-no-longer-being-maintained) .
So, what would be the right approach to build a .deb package in my case? If there is no way to build a .deb package on MSYS2/MINGW64, what would be the right way to organize the project, so I build this single-text-file .deb on Raspberry Pi with least amount of effort?
sdbbs
(578 rep)
Aug 9, 2024, 12:47 PM
• Last activity: Dec 17, 2024, 05:42 PM
0
votes
0
answers
248
views
Starting processes is very slow in git bash on Windows
I'm running git bash 2.45.2.1 on a windows computer (for work) and I've noticed that running even basic processes can be extremely slow. For example, ``` $ time /usr/bin/echo 1 > /dev/null real 0m0.102s user 0m0.015s sys 0m0.015s ``` ``` $ time /usr/bin/echo 1 | wc > /dev/null real 0m0.151s user 0m0...
I'm running git bash 2.45.2.1 on a windows computer (for work) and I've noticed that running even basic processes can be extremely slow.
For example,
$ time /usr/bin/echo 1 > /dev/null
real 0m0.102s
user 0m0.015s
sys 0m0.015s
$ time /usr/bin/echo 1 | wc > /dev/null
real 0m0.151s
user 0m0.031s
sys 0m0.030s
Why would it take this version of bash a whole 0.1 s to spawn a process? Is this a Windows problem? Can this be fixed?
This can get **very** slow if I pipe even a hundred lines to xargs
.
I don't think the slowness can be the hardware's fault. This computer's processor is a 13th Gen Intel Core i9-13950HX.
SU3
(204 rep)
Nov 19, 2024, 01:44 AM
3
votes
2
answers
133
views
MinGW/MSys 2 doesn't seem to recognize TZ environment variable
I work on a legacy system originally written in C for 3b2 SVR3, later in C++ for Sun/Solaris, now mainly for Linux. We have a few users who require our apps to run on Windows Servers, so we have accommodated that for the last 18 years using MSys / MinGW, cross compiled from our *nix-based developmen...
I work on a legacy system originally written in C for 3b2 SVR3, later in C++ for Sun/Solaris, now mainly for Linux. We have a few users who require our apps to run on Windows Servers, so we have accommodated that for the last 18 years using MSys / MinGW, cross compiled from our *nix-based development machines. We're now trying to upgrade to MSys 2 and have run into what appears to be an intractable problem that no amount of searching has turned up an answer to.
Our application works across multiple time zones simultaneously. We can't rely on a static system time zone setting to operate properly. We get our time zone definitions from the IANA database, installed as zoneinfo files in the traditional locations, depending upon environment. We update zoneinfo for our users as the need arises.
For as long as I can remember (I've worked on this for nearly 30 years), it was adequate to
putenv("TZ=");
tzset();
to get methods like mktime() and localtime() to produce the information we needed. That has stopped working now that we've moved to MSys 2.
Additionally, most of our code doesn't care what the initial time zone is, but one method insists that the TZ variable have some value (any value, it doesn't care). It really doesn't matter why TZ must be set - that code exposes another symptom that we might not otherwise have noticed so quickly: upon entry to any of our programs, the TZ environment variable has been removed from the environment.
The final curiosity is that MSys 2 comes with a **date** program that seems to work just fine with the TZ environment variable, as do **printenv** and **ls**, seeming to indicate that what we need to do *can* be done.
We have a short test program we've been using to demonstrate the problem and with any luck, prove that we've found a solution:
#include
#include
#include
int
main(int argc, const char *const *argv)
{
const char *tz = getenv("TZ");
const char *ptz = tz ? tz : "TZ not set";
printf("at entry: %s\n", ptz);
time_t now = time(NULL);
putenv("TZ=US/Pacific");
tzset();
printf("in %s it is now %s", getenv("TZ"), ctime(&now));
putenv("TZ=US/Eastern");
tzset();
printf("in %s it is now %s", getenv("TZ"), ctime(&now));
return 0;
}
When I run the above on our Linux dev machine, I get the following output:
$ printenv TZ
US/Central
$ date "+%F %T %Z"
2024-08-15 10:20:55 CDT
$ ./msystest
at entry: US/Central
in US/Pacific it is now Thu Aug 15 08:20:55 2024
in US/Eastern it is now Thu Aug 15 11:20:55 2024
Under MSys 2, just seconds later, I get the following:
$ printenv TZ
US/Central
$ date "+%F %T %Z"
2024-08-15 10:20:57 CDT
$ ./msystest
at entry: TZ not set
in US/Pacific it is now Thu Aug 15 16:20:57 2024
in US/Eastern it is now Thu Aug 15 16:20:57 2024
Using **ldd** on MSys 2, we've noticed that there are different DLLs referenced by **date** and **msystest**:
$ ldd /usr/bin/date
ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff962d20000)
KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff961b30000)
KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff960340000)
msys-intl-8.dll => /usr/bin/msys-intl-8.dll (0x430b30000)
msys-2.0.dll => /usr/bin/msys-2.0.dll (0x180040000)
msys-iconv-2.dll => /usr/bin/msys-iconv-2.dll (0x5603f0000)
$ ldd msystest
ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff962d20000)
KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff961b30000)
KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff960340000)
msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff962790000)
So our question is - is our problem the result of the differing DLLs, and if so, how do we get the msys DLLs built into our programs rather than the msvcrt DLL?
We've done a lot of searching online to try to resolve this to little avail. We usually get 1 of 2 answers:
1. Windows doesn't work that way so you can't do what you want with MSys
2. This is how you build a DLL with MinGW
Needless to say, the answers are either (1) wrong, or (2) answering the wrong question. Any help anyone can provide/point us to would be invaluable.
monkboon's evil twin
(41 rep)
Aug 15, 2024, 04:33 PM
• Last activity: Sep 24, 2024, 10:43 PM
0
votes
1
answers
147
views
tmux scrolling enabling fails in msys2
I recently started using `tmux` (in addition to `screen`), both in a Linux environment and in `msys2` (which is also new to me and for which I cannot install `screen`). Very similar to `screen`, starting `tmux` disables the shift - PgUp scrolling (and the scroll bar in the terminal emulator). For bo...
I recently started using
tmux
(in addition to screen
), both in a Linux environment and in msys2
(which is also new to me and for which I cannot install screen
).
Very similar to screen
, starting tmux
disables the shift-PgUp scrolling (and the scroll bar in the terminal emulator). For both terminal multiplexers the Internet does provide an easy solution. In the case of tmux
it is adding this setting to the configuration:
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
This works fine in the Linux environment but not in msys2
. $TERM
is set to xterm
.
Unfortunately I am not familiar (yet) with the internal details of terminals so I neither understand why this setting is necessary nor why it could fail. After all before starting tmux
the msys2
terminal emulator does have this capability.
The Internet contains a lot of questions about tmux
scrolling but I could not find any for this problem with msys2
.
**Meta**
I was thinking about whether this is the most suitable site for this question (and it may well not be). So if this does not result in a sufficient answer but you have an idea where it might make more sense to ask this then feel free to let me know.
Hauke Laging
(93688 rep)
May 2, 2024, 10:31 AM
• Last activity: May 8, 2024, 10:05 AM
13
votes
5
answers
26946
views
Handling Bash script with CRLF (carriage return) in Linux as in MSYS2?
Let's say I have the following trivial script, `tmp.sh`: ``` echo "testing" stat . echo "testing again" ``` Trivial as it is, it has `\r\n` (that is, CRLF, that is carriage return+line feed) as line endings. Since the webpage will not preserve the line endings, here is a hexdump: ``` $ hexdump -C tm...
Let's say I have the following trivial script,
tmp.sh
:
echo "testing"
stat .
echo "testing again"
Trivial as it is, it has \r\n
(that is, CRLF, that is carriage return+line feed) as line endings. Since the webpage will not preserve the line endings, here is a hexdump:
$ hexdump -C tmp.sh
00000000 65 63 68 6f 20 22 74 65 73 74 69 6e 67 22 0d 0a |echo "testing"..|
00000010 73 74 61 74 20 2e 0d 0a 65 63 68 6f 20 22 74 65 |stat ...echo "te|
00000020 73 74 69 6e 67 20 61 67 61 69 6e 22 0d 0a |sting again"..|
0000002e
Now, it has CRLF line endings, because the script was started and developed on Windows, under MSYS2. So, when I run it on Windows 10 in MSYS2, I get the expected:
$ bash tmp.sh
testing
File: .
Size: 0 Blocks: 40 IO Block: 65536 directory
Device: 8e8b98b6h/2391513270d Inode: 281474976761067 Links: 1
Access: (0755/drwxr-xr-x) Uid: (197609/ USER) Gid: (197121/ None)
Access: 2020-04-03 10:42:53.210292000 +0200
Modify: 2020-04-03 10:42:53.210292000 +0200
Change: 2020-04-03 10:42:53.210292000 +0200
Birth: 2019-02-07 13:22:11.496069300 +0100
testing again
However, if I copy this script to an Ubuntu 18.04 machine, and run it there, I get something else:
$ bash tmp.sh
testing
stat: cannot stat '.'$'\r': No such file or directory
testing again
In other scripts with the same line endings, I have also gotten this error in Ubuntu bash:
line 6: $'\r': command not found
... likely from an empty line.
So, clearly, something in Ubuntu chokes on the carriage returns. I have seen https://unix.stackexchange.com/questions/355559/bash-and-carriage-return-behavior :
> it doesn’t have anything to do with Bash: \r and \n are interpreted by the terminal, not by Bash
... however, I guess that is only for stuff typed verbatim on the command line; here the \r
and \n
are already typed in the script itself, so it must be that Bash interprets the \r
here.
Here is the version of Bash in Ubuntu:
$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
... and here the version of Bash in MSYS2:
$ bash --version
GNU bash, version 4.4.23(2)-release (x86_64-pc-msys)
(they don't seem all that much apart ...)
Anyways, my question is - is there a way to persuade Bash on Ubuntu/Linux to ignore the \r
, rather than trying to interpret it as a (so to speak) "printable character" (in this case, meaning a character that could be a part of a valid command, which bash interprets as such)? EDIT: *without* having to convert the script itself (so it remains the same, with CRLF line endings, if it is checked in that way, say, in git)
EDIT2: I would prefer it this way, because other people I work with might reopen the script in Windows text editor, potentially reintroduce \r\n
again into the script and commit it; and then we might end up with an endless stream of commits which might be nothing else than conversions of \r\n
to \n
polluting the repository.
EDIT2: @Kusalananda in comments mentioned dos2unix
(sudo apt install dos2unix
); note that just writing this:
$ dos2unix tmp.sh
dos2unix: converting file tmp.sh to Unix format...
... will convert the file in-place; to have it output to stdout, one must setup stdin redirection:
$ dos2unix
... and then, in principle, one could run this on Ubuntu, which seems to work in this case:
$ dos2unix
However, - aside from the slightly messy command to remember - this also changes bash semantics, as stdin is no longer a terminal; this may have worked with this trivial example, but see e.g. https://stackoverflow.com/questions/23257247/pipe-a-script-into-bash for example of bigger problems.
sdaau
(7098 rep)
Apr 3, 2020, 09:01 AM
• Last activity: Nov 17, 2023, 10:15 PM
1
votes
0
answers
262
views
Tmux: Scroll buffer not working on MSYS2/MINGW64 (Git for Windows SDK)
I installed the [Git for Windows SDK](https://github.com/git-for-windows/build-extra) on Windows 11 to have the `pacman` package installer available to install `tmux`. A lot of stuff works like it used to be on other platforms, but scrolling back using PREFIX + [ does not really work. I can see how...
I installed the [Git for Windows SDK](https://github.com/git-for-windows/build-extra) on Windows 11 to have the
pacman
package installer available to install tmux
.
A lot of stuff works like it used to be on other platforms, but scrolling back using PREFIX+[ does not really work.
I can see how the terminal enters scroll mode (yellow counter in the top right), but I can't move at all and its frozen at 0/XX
. All I can do is exit scrolling with C-c
.
How can I fix this issue?
My .tmux.conf
:
# prefix
unbind C-b
set -g prefix C-t
bind C-t send-prefix
# behavior
set -g escape-time 10 # see https://github.com/tmux/tmux/issues/353#issuecomment-294570322
set -g repeat-time 550 # allows holding down array keys for continuous strokes on MacOS
# theme
set -g default-terminal "screen-256color"
set -g status-bg color234
set -g status-fg white
set-window-option -g window-status-current-style bg=color233
bind § command-prompt -p "(set status-bg)" "set status-bg %1"
# rename
bind $ command-prompt "rename-session '%%'"
bind , command-prompt "rename-window '%%'"
# persistent cwd
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
# reload config
bind r source-file ~/.tmux.conf
Martin Braun
(287 rep)
May 30, 2023, 03:22 AM
0
votes
1
answers
401
views
MSYS2: Command works fine in terminal, but syntax error `(' in script
On Windows, with MSYS2, I want to add the file extension for an executable back to the output of `which`, if it has one. Here's a one-liner: ```bash locAlt="$(which "mingw32-make")" ; echo "$locAlt" ; locAlt=("$locAlt"+(|.*)) ; echo "$locAlt" ``` When run in the MSYS2 MinGW terminal, this works just...
On Windows, with MSYS2, I want to add the file extension for an executable back to the output of
which
, if it has one. Here's a one-liner:
locAlt="$(which "mingw32-make")" ; echo "$locAlt" ; locAlt=("$locAlt"+(|.*)) ; echo "$locAlt"
When run in the MSYS2 MinGW terminal, this works just fine on my machine and prints:
/mingw64/bin/mingw32-make
/mingw64/bin/mingw32-make.exe
However, now I put the same line into a script (one-liner.sh
):
#/bin/bash
locAlt="$(which "mingw32-make")" ; echo "$locAlt" ; locAlt=("$locAlt"+(|.*)) ; echo "$locAlt"
I tried both nano
and Notepad++
(where you can choose line endings, and they're set to "UNIX (LF)", and checked the output of cat -v one-liner.sh
, which shows the file as above (no ^M
, as in this question ).
However, when trying to run the file with ./one-liner.sh
, I get the error
./one-liner.sh: line 2: syntax error near unexpected token `('
./one-liner.sh: line 2: `locAlt="$(which "mingw32-make")" ; echo "$locAlt" ; locAlt=("$locAlt"+(|.*)) ; echo "$locAlt"'
Why could that be?
RL-S
(141 rep)
Aug 12, 2022, 07:33 AM
2
votes
1
answers
658
views
git-bash window title issue
I started a git-bash window, and type following commands : ``` git-bash ~$ echo $BASH_VERSION 4.4.23(1)-release git-bash ~$ type cd cd is a shell builtin git-bash ~$ cd tmp git-bash ~/tmp$ # Change of directory is NOT refelected on git-bash window title git-bash ~/tmp$ ssh user@linux [user@linux ~]$...
I started a git-bash window, and type following commands :
git-bash ~$ echo $BASH_VERSION
4.4.23(1)-release
git-bash ~$ type cd
cd is a shell builtin
git-bash ~$ cd tmp
git-bash ~/tmp$
# Change of directory is NOT refelected on git-bash window title
git-bash ~/tmp$ ssh user@linux
[user@linux ~]$ echo $BASH_VERSION
4.4.20(1)-release
[user@linux ~]$ type cd
cd is a shell builtin
[user@linux ~]$ cd tmp
[user@linux ~/tmp]$
# Change of directory IS refelected on git-bash window title
Why does git-bash NOT update its own window title whereas a remote bash DOES ?
Philippe
(1505 rep)
Nov 25, 2021, 11:57 AM
• Last activity: Aug 3, 2022, 04:29 PM
1
votes
1
answers
75
views
Is it possible to use the magnet uri scheme in PKGBUILDs?
Is it possible to use resources exchanged with the BitTorrent protocol in `pacman`'s `PKGBUILD`s?
Is it possible to use resources exchanged with the BitTorrent protocol in
pacman
's PKGBUILD
s?
Scrooge McDuck
(1102 rep)
Jun 1, 2022, 02:53 PM
• Last activity: Jul 16, 2022, 11:26 AM
2
votes
1
answers
621
views
Exclude from rsync log file or output non-updated files
For `rsync`s that involve a large number of potentially transferred files, I mean to have a "clean" log, with only what was transferred. I worked with `stdout`, since: 1) I did not know how to configure the log output (if that is even possible). 2) I also want this to work with `--dry-run` (which fo...
For
rsync
s that involve a large number of potentially transferred files, I mean to have a "clean" log, with only what was transferred.
I worked with stdout
, since:
1) I did not know how to configure the log output (if that is even possible).
2) I also want this to work with --dry-run
(which forced me to work with something like this , since).
3) I mean to write scripts useful for transferring Linux-Linux, and Linux-msys2 (and viceversa) at least. Here, options for permissions (-p
), owner (-o
) and group (-g
) may complicate things.
I combined command
rsync --recursive --perms --group --owner --times --one-file-system --sparse --stats --progress --update --out-format='%t %p %i %n %M %l' --delete --dry-run --include="*" --exclude="*" --log-file=rsync.log ./ ../trg
with
... | grep -E -v ' \.[fdLDS][\.c][\.s][\.t][\.p][\.o][\.g][\.u][\.a][\.x]'
following the description here .
The first dot matches any item that is not being updated.
The second character matches any item type.
The remaining characters match any condition on the attributes (change/no change)
Flag -v
reverts matching. This presumably matches any item that is being updated, and only that. Items not updated, but with changed timestamp, would not be matched.
I finally combine this with tee
, as in
rsync --recursive --perms --group --owner --times --one-file-system --sparse --stats --progress --update --out-format='%t %p %i %n %M %l' --delete --dry-run --include="*" --exclude="*" --log-file=rsync.log ./ ../trg | grep -E -v ' \.[fdLDS][\.c][\.s][\.t][\.p][\.o][\.g][\.u][\.a][\.x]' | tee rsync.2.log
which produces the rsync
log file rsync.log
, and my "custom" log file rsync.2.log
.
Even if it seems to work, the 3 "weak" points of my approach are the following:
1. I am not sure there are cases I am missing, where this approach might fail (by "excessive" reporting or filtering files).
2. I would like to handle this natively via rsync
itself. Even better, getting the output in the rsync
log file (not only its output), rather than using the brute force grep
approach.
Note that using --itemize-changes
I get in stdout some files with e.g. status .f...p.....
, which should be filtered (as they are not updated, first character is a dot).
3. Using grep
I cannot see the partial progress. I am not sure if for very large output this can be a major problem.
**Related**:
1. https://unix.stackexchange.com/questions/203848/how-to-make-rsync-to-log-deleted-files
2. https://unix.stackexchange.com/questions/508331/how-to-make-rsync-display-only-files-being-copied-not-all-the-folders-which-are
3. https://unix.stackexchange.com/questions/44372/logging-only-transferred-files-with-rsync
4. https://superuser.com/questions/1002074/linux-command-line-to-create-a-log-file-for-rsync
5. https://serverfault.com/questions/401210/rsync-report-only-uploaded-files
**Note**:
The subtleties in this question (see also answer) make it slightly different from other similar questions posted/linked.
Whether this warrants a separate question is a blurred line, and subjective.
I personally find it useful to leave it as it is now.
sancho.s ReinstateMonicaCellio
(2998 rep)
Jan 24, 2022, 09:09 PM
• Last activity: Jan 28, 2022, 03:24 PM
0
votes
0
answers
23
views
scp from remote to remote does not work if not using -3
I mean to copy files from one remote server to another. If using `scp -3`, command succeeds (I have `remote1` and `remote2` in my `~/.ssh/config`) $ scp -p -3 remote1:dir1/file1 remote2:dir2/ but when not using `-3`, it fails $ scp -p remote1:dir1/file1 remote2:dir2/ ssh: Could not resolve hostname...
I mean to copy files from one remote server to another.
If using
scp -3
, command succeeds (I have remote1
and remote2
in my ~/.ssh/config
)
$ scp -p -3 remote1:dir1/file1 remote2:dir2/
but when not using -3
, it fails
$ scp -p remote1:dir1/file1 remote2:dir2/
ssh: Could not resolve hostname remote2: Temporary failure in name resolution
lost connection
**Why is that?**
As I understand from man scp
and other sources, -3
is not mandatory, but simply
-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.
I am using msys2, I wouldn't know if that makes any difference.
sancho.s ReinstateMonicaCellio
(2998 rep)
Jul 8, 2021, 08:20 AM
• Last activity: Jul 8, 2021, 08:55 AM
1
votes
1
answers
1255
views
Is there a convenient way to test if a given flag is supported on a command?
Okay, so I'm kinda stumped here. I'm in the midst of a deep-dive into BASH, for the purposes of writing some automation scripts for my employer. Also, full disclosure here: I'm a web guy; hitherto I've known JUST enough CLI to operate git. My issue is, **about half the staff are using MacOS, the oth...
Okay, so I'm kinda stumped here.
I'm in the midst of a deep-dive into BASH, for the purposes of writing some automation scripts for my employer. Also, full disclosure here: I'm a web guy; hitherto I've known JUST enough CLI to operate git.
My issue is, **about half the staff are using MacOS, the other half are using GitBash**, and it seems there are different flags supported (or, more relevantly, *not* supported) on the two different BASH instantiations. Further conundrum: what with everyone working from home and the world ending and all, I cannot reliably demand every one of our staff "switch to distro X"/"upgrade to version Y".
Now, I know how to test if a given program is installed (though, I confess: I'm not crystal-clear why one is preferable to the other, and please: correct me if either is a terrible way of handling this), in the forms of:
sh
type foo >/dev/null 2>&1 || { echo >&2 "COMMAND NOT FOUND"; }
...and...
sh
[ -x "$(command -v foo)" ] || echo 'COMMAND NOT FOUND'
...but in my specific case, BOTH platforms HAVE foo
installed, but, as a for-instance, only MacOS has a -b
/--bar
modifier flag. **So, how do I test to see if a given FEATURE of a command is supported?** Every time I try to pass a flag to one of the tests, the program PERFORMING the test seems to believe it's directed at IT, ignores it entirely, or errors out.
**How can I test to see if foo -b
/foo --bar
is a valid/installed/accessible command?**
# Update/Answer
Since the general consensus presented in the well-reasoned and honestly excellent answers received below appears to be a hybrid of "no, one cannot", punctuated with "there's simply too many factors to be able to reliably glean anything resembling conclusive, useful data", I'm closing out the question.
My intention here was to ascertain what the correct approach to employ was to verify the presence of a potentially non-existent flag between two different platforms - *known* platforms, fortunately, in my case - and the appropriate tact in this case would seem to be the one I'm currently taking: **maintain two separate scripts, one for each platform**.
Thank you to all who took the time to respond! It's much appreciated.
NerdyDeeds
(123 rep)
Aug 12, 2020, 01:06 AM
• Last activity: Aug 14, 2020, 11:06 AM
-2
votes
1
answers
414
views
To count the number of occurrences of first field in text file
i require to count the number of occurrences of first field in txt file and to print output file as two column file having first field of input file & no. of occurrences of fist field in input file
i require to count the number of occurrences of first field in txt file and to print output file as two column file having first field of input file & no. of occurrences of fist field in input file
SBM Anand
(1 rep)
Jun 25, 2020, 07:35 AM
• Last activity: Jun 25, 2020, 07:42 AM
1
votes
0
answers
952
views
Inspect/browse gzipped dd disk image from command line without decompressing and mounting?
I did a disk image, as per https://unix.stackexchange.com/questions/132797/how-to-dd-a-remote-disk-using-ssh-on-local-machine-and-save-to-a-local-dis : ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz` Now, I would just like to doublecheck this image - see the partitions included, possi...
I did a disk image, as per https://unix.stackexchange.com/questions/132797/how-to-dd-a-remote-disk-using-ssh-on-local-machine-and-save-to-a-local-dis :
ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz`
Now, I would just like to doublecheck this image - see the partitions included, possibly see files on the partition. However, I would also want to do this under either Cygwin or MSYS2, so I'd want to avoid mounting, and use some sort of a command line tool to inspect/browse the gzip compressed dd image.
From this question:
https://unix.stackexchange.com/questions/31669/is-it-possible-to-mount-a-gzip-compressed-dd-image-on-the-fly
... I learned about http://libguestfs.org/guestfish.1.html "a shell and command-line tool for examining and modifying virtual machine filesystems." - which looks like exactly what I need. Unfortunately, it is not available for Cygwin or MSYS2 as a binary (and I tried building from source, and cannot do it).
So I was wondering: limiting myself only to expected swap or ext2/ext3 partitions in the disk image, and gzip compression, and only read-only browsing, - is there any other command-line way to inspect partitions and files in
image.gz
from the command line, without decompressing to a new file and mounting; especially one that might work in Cygwin or MSYS2?
sdaau
(7098 rep)
Mar 22, 2020, 10:54 PM
0
votes
0
answers
51
views
Purpose of "!::=::\" `name=value pair` in `env` stdout
Inspecting the stdout the invocation of [`env`](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html) utility without supplying an operand it returned a `name=value` pair whose meaning I don't understand nor was able to find any documentation $ env ... !::=::\ ... TERM=cygwin MSYSTEM_...
Inspecting the stdout the invocation of [
env
](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html) utility without supplying an operand it returned a name=value
pair whose meaning I don't understand nor was able to find any documentation
$ env
...
!::=::\
...
TERM=cygwin
MSYSTEM_PREFIX=/mingw64
...
In the POSIX specification it is stated that
> STDOUT
> If no utility operand is specified, each name= value pair in the
> resulting environment shall be written in the form:
>
> "%s=%s\n", ,
I'm using msysgit
on a machine running Windows 10.
$ git --version
git version 2.22.0.windows.1
$ printf "%s\n" $BASH_VERSION
4.4.23(1)-release
Started a new session and the result is the same.
Executing the same env
command on cmd.exe returns
C:\>env
!::=::\
!C:=C:\
...
What is the meaning and purpose of this name=value
pair?
Paulo Tomé
(3832 rep)
Feb 28, 2020, 12:41 PM
• Last activity: Feb 28, 2020, 03:09 PM
3
votes
1
answers
1832
views
paste: /dev/fd/63: No such file or directory
I'm new to Unix command. I was trying to execute the following commands in Git Bash and it directs to error message: paste: /dev/fd/63: No such file or directory # Set Up Image Lists paste 5k.txt paste trainvalno5k.txt Could anyone help me understand what it means and what I should do?
I'm new to Unix command. I was trying to execute the following commands in Git Bash and it directs to error message: paste: /dev/fd/63: No such file or directory
# Set Up Image Lists
paste 5k.txt
paste trainvalno5k.txt
Could anyone help me understand what it means and what I should do?
scionx
(31 rep)
Nov 25, 2019, 06:09 AM
• Last activity: Nov 25, 2019, 07:22 AM
2
votes
2
answers
1747
views
Why does `ldd <dynamic_lib>` output "??? => ???" (question marks in both library and location)?
Running `ldd `, I noticed that there are some entries that read `??? => ???`. Searching for a variety of combinations of "Linux", "```ldd```" and "```??? => ???```", both via search engine and on this site did not turn up anything. Possibly relevant: the dynamic library in question was compiled on W...
Running
ldd
, I noticed that there are some entries that read ??? => ???
. Searching for a variety of combinations of "Linux", "
" and "??? => ???
", both via search engine and on this site did not turn up anything.
Possibly relevant: the dynamic library in question was compiled on Windows 10 under MSYS2 using the built-in GCC Suite.
JDQ
(315 rep)
Aug 13, 2019, 12:07 AM
• Last activity: Aug 15, 2019, 06:16 PM
3
votes
0
answers
122
views
What does it mean if a process has an O or an I at the start of the line?
After running `ps`, I noticed that a couple of the processes had an O at the start of the line. In all my years, I've never seen this. I thought that the meaning of the indicator might be common knowledge, but I asked my circle of software professionals and they had no idea either. The column isn't...
After running
And in text-based form:
ps
, I noticed that a couple of the processes had an O at the start of the line. In all my years, I've never seen this. I thought that the meaning of the indicator might be common knowledge, but I asked my circle of software professionals and they had no idea either. The column isn't labelled, either. I read the entire manual entry for ps
and couldn't find what it means; there's nothing about an O.
It might just be unique to MinGW. It appears even when ps
is the first command entered in a fresh console. Any ideas?

$ ps
PID PPID PGID WINPID TTY UID STIME COMMAND
9484 5176 17152 1172 cons0 4096 14:35:31 /usr/bin/sh
I 21164 17156 21164 4320 cons2 4096 16:11:48 /usr/bin/ssh-keygen
19220 1 19220 19220 cons0 4096 14:34:10 /usr/bin/bash
16344 1 16344 7392 cons3 4096 10:53:33 /usr/bin/bash
17156 1 17156 17156 cons2 4096 16:09:52 /usr/bin/bash
23660 23740 23660 18060 cons8 4096 08:28:14 /usr/bin/ps
17152 19220 17152 17152 cons0 4096 14:34:10 /usr/bin/bash
2552 1 2552 2552 cons6 4096 14:14:52 /usr/bin/bash
4904 9484 17152 4704 cons0 4096 14:35:31 /c/Program Files/nodejs/node
7396 1 7396 7396 cons7 4096 08:23:44 /usr/bin/bash
23740 1 23740 23740 cons8 4096 08:28:11 /usr/bin/bash
17020 1 17020 17020 cons1 4096 15:16:26 /usr/bin/bash
5176 17152 17152 12140 cons0 4096 14:34:15 /usr/bin/bash
I 15460 1 15460 15460 cons4 4096 16:18:14 /usr/bin/less
20616 1 20616 20616 cons5 4096 16:21:36 /usr/bin/bash
Erik Humphrey
(133 rep)
Jun 12, 2019, 07:42 PM
• Last activity: Jun 13, 2019, 05:40 PM
Showing page 1 of 20 total questions