Displaying stdout from continuously running program and run command if string present
Hi, I have a noscript that runs in a terminal window, and I need to see the displayed stdout from a program that it launches, which continues running. But I also need to monitor the program's stdout and run a command if a string eventually appears in the output. Once that condition is met then I don't want to see the terminal anymore so I kill the terminal, but the program keeps running until I exit its window. I would prefer to not have to write the stdout to a file for parsing. This is as close as I can get, but it doesn't show the program's output. Any tips? Thanks!
#!/bin/bash
thisPID="$(echo $$)"
docker container start Something
nohup xfreerdp /v:localhost |
grep --line-buffered 'PDUTYPEDATA' |
while read; do
wmctrl -c 'FreeRDP' -b toggle,maximizedvert,maximizedhorz;
kill $thisPID
done
https://redd.it/1dw291c
@r_bash
Hi, I have a noscript that runs in a terminal window, and I need to see the displayed stdout from a program that it launches, which continues running. But I also need to monitor the program's stdout and run a command if a string eventually appears in the output. Once that condition is met then I don't want to see the terminal anymore so I kill the terminal, but the program keeps running until I exit its window. I would prefer to not have to write the stdout to a file for parsing. This is as close as I can get, but it doesn't show the program's output. Any tips? Thanks!
#!/bin/bash
thisPID="$(echo $$)"
docker container start Something
nohup xfreerdp /v:localhost |
grep --line-buffered 'PDUTYPEDATA' |
while read; do
wmctrl -c 'FreeRDP' -b toggle,maximizedvert,maximizedhorz;
kill $thisPID
done
https://redd.it/1dw291c
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Text pasted to a file not parsed correctly (invisible characters)
I have a noscript which parses text on a line-by-line basis. Works as expected, except for text pasted from a particular webpage that involves both English text and foreign characters (cannot share more details than that), where it seems to parse every *other* line by the shell. However, if I `echo` *instead* of running `yt-dlp` on what's parsed, it still prints expected values of `$noscript` and `$url`. I was told there are invisible characters involved like `$'\r'` byte (0x0d) which bash does not consider as whitespaces to ignore, but how can I see if this is the case on a text editor (I use Neovim) and/or fix the cause of the issue? If I append a character manually to each line that was pasted, the noscript then parses each line as you would expect and is a workaround for the issue.
file="$2"
while IFS= read -r line || [[ -n "$line" ]]; do
noscript="${line#* }"
url="${line%% *}"
if [[ -n "$noscript" ]]; then
default_template="$noscript - %(uploader).12B (%(upload_date)s) %(id)s.%(ext)s"
else
default_template="%(noscript).140B - %(uploader).12B (%(upload_date)s) %(id)s.%(ext)s"
fi
yt-dlp --output "$default_template" "$url"
# echo "$url"
done < <( awk NF "$file" ) # Delete blank lines from $file
exit
https://redd.it/1dw8l6e
@r_bash
I have a noscript which parses text on a line-by-line basis. Works as expected, except for text pasted from a particular webpage that involves both English text and foreign characters (cannot share more details than that), where it seems to parse every *other* line by the shell. However, if I `echo` *instead* of running `yt-dlp` on what's parsed, it still prints expected values of `$noscript` and `$url`. I was told there are invisible characters involved like `$'\r'` byte (0x0d) which bash does not consider as whitespaces to ignore, but how can I see if this is the case on a text editor (I use Neovim) and/or fix the cause of the issue? If I append a character manually to each line that was pasted, the noscript then parses each line as you would expect and is a workaround for the issue.
file="$2"
while IFS= read -r line || [[ -n "$line" ]]; do
noscript="${line#* }"
url="${line%% *}"
if [[ -n "$noscript" ]]; then
default_template="$noscript - %(uploader).12B (%(upload_date)s) %(id)s.%(ext)s"
else
default_template="%(noscript).140B - %(uploader).12B (%(upload_date)s) %(id)s.%(ext)s"
fi
yt-dlp --output "$default_template" "$url"
# echo "$url"
done < <( awk NF "$file" ) # Delete blank lines from $file
exit
https://redd.it/1dw8l6e
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Is there any sense in quoting special vars like $? and $# ?
I mean, bash and other shells are aware
https://redd.it/1dwq3no
@r_bash
I mean, bash and other shells are aware
$? and $# cant contain any spaces or patterns, so I guess they treat $? and "$?" the same? Or do they still try to perform word splitting on $? ?https://redd.it/1dwq3no
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Trying to send multiple flags to rsync
So I use rsync over ssh to move files over my local network. I'm not worried about security too much, but use rsync over ssh so I can do it over internet sporadically.
This is what works:
export DEN=username@den.local
export USER=/home/kitchen
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -rptuv --delete --progress $DEN:/home/username/Music/English/A/ $USER/Music/Music/A/
I am trying to put all the flags in a variable.
The following variable doesn't work
export RSYNCFLAGS="-e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -rptuv --delete --progress"
rsync $RSYNCFLAGS $DEN:/home/username/Music/English/A/ $USER/Music/Music/A
I also tried using a variable array, but that didn't work as expected:
export RSYNCFLAGS=(-e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -rptuv --delete --progress)
rsync ${RSYNCFLAGS*} $DEN:/home/username/Music/English/A/ $USER/Music/Music/A
They both have problems with the -e at the beginning (it doesn't add it to the variable at all). When I move that later on, it still gives a problem. Can anyone help me out?
https://redd.it/1dwquoi
@r_bash
So I use rsync over ssh to move files over my local network. I'm not worried about security too much, but use rsync over ssh so I can do it over internet sporadically.
This is what works:
export DEN=username@den.local
export USER=/home/kitchen
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -rptuv --delete --progress $DEN:/home/username/Music/English/A/ $USER/Music/Music/A/
I am trying to put all the flags in a variable.
The following variable doesn't work
export RSYNCFLAGS="-e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -rptuv --delete --progress"
rsync $RSYNCFLAGS $DEN:/home/username/Music/English/A/ $USER/Music/Music/A
I also tried using a variable array, but that didn't work as expected:
export RSYNCFLAGS=(-e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -rptuv --delete --progress)
rsync ${RSYNCFLAGS*} $DEN:/home/username/Music/English/A/ $USER/Music/Music/A
They both have problems with the -e at the beginning (it doesn't add it to the variable at all). When I move that later on, it still gives a problem. Can anyone help me out?
https://redd.it/1dwquoi
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Experience customizing the colors on "ohmybash"?
I was wondering if anyone here has the experience of altering or modifying the provided themes in "Ohmybash" I'm trying to change the powerline and text color on my "agnoster" theme but no luck thus far.
https://redd.it/1dwyh4m
@r_bash
I was wondering if anyone here has the experience of altering or modifying the provided themes in "Ohmybash" I'm trying to change the powerline and text color on my "agnoster" theme but no luck thus far.
https://redd.it/1dwyh4m
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Parameter Substitution and Pattern Matching in bash
Hi. I may have misread the documentation, but why doesn't this work?
Suppose var="ciaomamma0comestai"
I'd like to print until the 0 (included)
I tried echo ${var%%[:alpha:\]} but it doesn't work
According to the Parameter Expansion doc
>
The word is expanded to produce a pattern and matched according to the rules described below (see Pattern Matching).
But Patter Matching doc clearly says
>Within ‘[’ and ‘\]’, character classes can be specified using the syntax [:class:\], where class is one of the following classes defined in the POSIX standard:
alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
So that above command should work...
I know there are other solutions, like {var%%0*} but it's not as elegant and does not cover cases where there could be other numbers instead of 0
https://redd.it/1dxix8c
@r_bash
Hi. I may have misread the documentation, but why doesn't this work?
Suppose var="ciaomamma0comestai"
I'd like to print until the 0 (included)
I tried echo ${var%%[:alpha:\]} but it doesn't work
According to the Parameter Expansion doc
>
${parameter%%word} The word is expanded to produce a pattern and matched according to the rules described below (see Pattern Matching).
But Patter Matching doc clearly says
>Within ‘[’ and ‘\]’, character classes can be specified using the syntax [:class:\], where class is one of the following classes defined in the POSIX standard:
alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
So that above command should work...
I know there are other solutions, like {var%%0*} but it's not as elegant and does not cover cases where there could be other numbers instead of 0
https://redd.it/1dxix8c
@r_bash
www.gnu.org
Shell Parameter Expansion (Bash Reference Manual)
Next: Command Substitution, Previous: Tilde Expansion, Up: Shell Expansions [Contents][Index]
a serialized dictionary argument parser for Bash (pip-installable)
Hey all, I built a serialized dictionary argument parser for Bash, that is pip-installable,
pip install blue_options
then add this line to your `~/.bash_profile` or `~/.bashrc`,
source $(python -m blue_options locate)/.bash/blue_options.sh
it can parse a serialized dictionary as an argument; for example,
area=<vancouver>,~batch,count=<-1>,dryrun,gif,model=<model-id>,~process,publish,~upload
like this,
function func() {
local options=$1
local var=$(abcli_options "$options" var default)
local key=$(abcli_options_int "$options" key 0)
[[ "$key" == 1 ]] &&
echo "var=$var"
}
more: [https://github.com/kamangir/blue-options](https://github.com/kamangir/blue-options) + [https://pypi.org/project/blue-options/](https://pypi.org/project/blue-options/)
https://redd.it/1dxmewr
@r_bash
Hey all, I built a serialized dictionary argument parser for Bash, that is pip-installable,
pip install blue_options
then add this line to your `~/.bash_profile` or `~/.bashrc`,
source $(python -m blue_options locate)/.bash/blue_options.sh
it can parse a serialized dictionary as an argument; for example,
area=<vancouver>,~batch,count=<-1>,dryrun,gif,model=<model-id>,~process,publish,~upload
like this,
function func() {
local options=$1
local var=$(abcli_options "$options" var default)
local key=$(abcli_options_int "$options" key 0)
[[ "$key" == 1 ]] &&
echo "var=$var"
}
more: [https://github.com/kamangir/blue-options](https://github.com/kamangir/blue-options) + [https://pypi.org/project/blue-options/](https://pypi.org/project/blue-options/)
https://redd.it/1dxmewr
@r_bash
GitHub
GitHub - kamangir/blue-options: 🌀 an options for Bash.
🌀 an options for Bash. Contribute to kamangir/blue-options development by creating an account on GitHub.
Help customizing "OhMyBash"?
How can I get the color #55c369 as the color for my prompts background on the agnoster theme , It seems like "OhMyBash" uses the 'ANSI' color code--So how would I get the color translated to ANSI if that possible? Currently my prompt is displaying the opposite color way I want
What I currently have\^
What I would like to have\^
https://redd.it/1dxnvzg
@r_bash
How can I get the color #55c369 as the color for my prompts background on the agnoster theme , It seems like "OhMyBash" uses the 'ANSI' color code--So how would I get the color translated to ANSI if that possible? Currently my prompt is displaying the opposite color way I want
What I currently have\^
What I would like to have\^
https://redd.it/1dxnvzg
@r_bash
Print missing sequence of files
I download files from filehosting websites and they are multi-volume archived files with the following naming scheme (note the suffix .part0..<ext>, not sure if this is the correct regex notation):
sampleA.XXXXX.part1.rar
sampleA.XXXXX.part2.rar
sampleA.XXXXX.part3.rar # empty file (result when file is still downloading)
sampleA.XXXXX.part5.rar
sampleB.XX.part03.rar
sampleC.part11.rar
sampleD.part002.rar
sampleE.part1.rar
sampleE.part2.rar # part2 is smaller size than its part1 file
sampleF.part1.rar
sampleF.part2.rar # part2 is same size as its part1 file
I would like a noscript whose output is this:
sampleA.XXXXX
- downloading: 3
- missing: 4
sampleB.XX
- missing: 01, 02
sampleC
- missing: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10
sampleD
- missing: 001
sampleE completed
sampleF
- likely requires: 3
I implemented this but it doesn't handle 1) partN naming scheme where there's variable amount of prepended 0's (mine doesn't support any prepended 0's) and 2) also assumes part1 of a volume must exist. This is what I have. I'm sure there's a simpler way to implement the above and don't think it's worth adjusting it to support these limitations (e.g. simpler to probably compare
Any ideas much appreciated.
https://redd.it/1dxn80x
@r_bash
I download files from filehosting websites and they are multi-volume archived files with the following naming scheme (note the suffix .part0..<ext>, not sure if this is the correct regex notation):
sampleA.XXXXX.part1.rar
sampleA.XXXXX.part2.rar
sampleA.XXXXX.part3.rar # empty file (result when file is still downloading)
sampleA.XXXXX.part5.rar
sampleB.XX.part03.rar
sampleC.part11.rar
sampleD.part002.rar
sampleE.part1.rar
sampleE.part2.rar # part2 is smaller size than its part1 file
sampleF.part1.rar
sampleF.part2.rar # part2 is same size as its part1 file
I would like a noscript whose output is this:
sampleA.XXXXX
- downloading: 3
- missing: 4
sampleB.XX
- missing: 01, 02
sampleC
- missing: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10
sampleD
- missing: 001
sampleE completed
sampleF
- likely requires: 3
I implemented this but it doesn't handle 1) partN naming scheme where there's variable amount of prepended 0's (mine doesn't support any prepended 0's) and 2) also assumes part1 of a volume must exist. This is what I have. I'm sure there's a simpler way to implement the above and don't think it's worth adjusting it to support these limitations (e.g. simpler to probably compare
find outputs with expected outputs to find the intersectionso I'm only posting it for reference. Any ideas much appreciated.
https://redd.it/1dxn80x
@r_bash
stdin
ls -1 | while IFS= read -r line; do
echo "$line"
read -p "Press Enter to continue..."
done
Why does this not prompt after every
It should pause after every line, cause thats how stdin &
And what would be a workaround to make this work as i exect?
https://redd.it/1dxlqb1
@r_bash
read questionls -1 | while IFS= read -r line; do
echo "$line"
read -p "Press Enter to continue..."
done
Why does this not prompt after every
ls line?It should pause after every line, cause thats how stdin &
read works?And what would be a workaround to make this work as i exect?
https://redd.it/1dxlqb1
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How do I handle window decoration offsets when positing windows with xdotool or wmctrl?
Here's two examples of positing windows to X=40 Y=40 and changing their size to 1000x600:
wmctrl -r :ACTIVE: -e '0,40,40,1000,600'
xdotool getactivewindow windowmove %@ 20 20 windowsize %@ 1000 600
Depending on the program both
I don't mind adding my own decoration offsets but I have no way of telling programmatically which windows should have that offest applied.
So far i've tried the following but neither gives me a property that distinguishes between them:
xdotool getactivewindow getwindowname getwindowgeometry --shell
xprop -id "$(xdotool getactivewindow)"
xwininfo -id "$(xdotool getactivewindow)"
Here's a list of programs based on how they're positioned realtive to decorations:
# Placement BEFORE decorations
krita
mpv
libreoffice {writer,calc,math,ect}
brave-browser
# Placement AFTER decorations
gimp
xarchiver
smplayer
alacritty
xfce4-terminal
thunar
chromium
firefox (with Title Bar enabled)
Glad for any insight, thank you.
https://redd.it/1dy6c7v
@r_bash
Here's two examples of positing windows to X=40 Y=40 and changing their size to 1000x600:
wmctrl -r :ACTIVE: -e '0,40,40,1000,600'
xdotool getactivewindow windowmove %@ 20 20 windowsize %@ 1000 600
Depending on the program both
wmctrl and xdotool will calculate that 40 X/Y position BEFORE or AFTER window decorations. So some programs will always be placed at X Y where others will always be placed at X+DEC_WIDTH_LEFT Y+DEC_HEIGHT_TOP.I don't mind adding my own decoration offsets but I have no way of telling programmatically which windows should have that offest applied.
So far i've tried the following but neither gives me a property that distinguishes between them:
xdotool getactivewindow getwindowname getwindowgeometry --shell
xprop -id "$(xdotool getactivewindow)"
xwininfo -id "$(xdotool getactivewindow)"
Here's a list of programs based on how they're positioned realtive to decorations:
# Placement BEFORE decorations
krita
mpv
libreoffice {writer,calc,math,ect}
brave-browser
# Placement AFTER decorations
gimp
xarchiver
smplayer
alacritty
xfce4-terminal
thunar
chromium
firefox (with Title Bar enabled)
Glad for any insight, thank you.
https://redd.it/1dy6c7v
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
noscript no work halp
while sleep 0.5; do find . -name '.c' -o -name '.h' | entr -d make; done &
sh -c 'while sleep 0.5; do find . -name '.c' -o -name '.h' | entr -d make; done' &
Why does this not keep running in a background?
Its a closed while loop, but it seems to exit in a first iteration of the loop.
but without the
also entr, its just a simplified version of inotify
http://eradman.com/entrproject/
https://redd.it/1dy6jvr
@r_bash
while sleep 0.5; do find . -name '.c' -o -name '.h' | entr -d make; done &
sh -c 'while sleep 0.5; do find . -name '.c' -o -name '.h' | entr -d make; done' &
Why does this not keep running in a background?
Its a closed while loop, but it seems to exit in a first iteration of the loop.
but without the
& it works as expectedalso entr, its just a simplified version of inotify
http://eradman.com/entrproject/
https://redd.it/1dy6jvr
@r_bash
.bash_history format
In bash, running the `history` command prints in a beautifully formatted output:
5625 [2024-06-22 12:22:38] F libdisplay-info
5626 [2024-06-22 12:22:50] p -Ssq libdisplay-info
5627 [2024-06-22 12:23:02] p -Fl libdisplay-info
5628 [2024-06-22 20:35:24] p -Flq libdisplay-info
5629 [2024-06-22 20:36:02] Q libdisplay-info
However, the .bash_history file looks like crap in comparison:
#1719084158
F libdisplay-info
#1719084170
p -Ssq libdisplay-info
#1719084182
p -Fl libdisplay-info
#1719113724
p -Flq libdisplay-info
#1719113762
Q libdisplay-info
I've hacked together an ugly, fragile bit of code to write a duplicate the first example to `"${HOME}"/.bash_history_dated`.
sed 'N;s/\n/ /' < "${HOME}"/.bash_history \
| cut -c2- \
| awk '{$1 = strftime("%F %r", substr($1,1,10))} 1 {print "["$1"] ",$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20}' \
> "${HOME}"/.bash_history_dated
This runs whenever I exit the shell via `trap "/home/jeff/bin/bash-history-timestamp" 0`, and the results (if there's not more than two lines input per command).
This is great, and I didn't want the command numbers included in this.
[2024-06-22 12:22:38 PM] F libdisplay-info
[2024-06-22 12:22:50 PM] p -Ssq libdisplay-info
[2024-06-22 12:23:02 PM] p -Fl libdisplay-info
[2024-06-22 08:35:24 PM] p -Flq libdisplay-info
[2024-06-22 08:36:02 PM] Q libdisplay-info
My questions are:
1) Why doesn't this work in place of the ugly code `history | cut -c 8- > "${HOME}"/.BASH_HIST_DATED`. This works in the shell, but only creates an empty file when ran in the noscript.
2) How to improve my ugly code to be cleaner and more robust to work with multiple cli input lines if it's the only solution.
https://redd.it/1dyl2ln
@r_bash
In bash, running the `history` command prints in a beautifully formatted output:
5625 [2024-06-22 12:22:38] F libdisplay-info
5626 [2024-06-22 12:22:50] p -Ssq libdisplay-info
5627 [2024-06-22 12:23:02] p -Fl libdisplay-info
5628 [2024-06-22 20:35:24] p -Flq libdisplay-info
5629 [2024-06-22 20:36:02] Q libdisplay-info
However, the .bash_history file looks like crap in comparison:
#1719084158
F libdisplay-info
#1719084170
p -Ssq libdisplay-info
#1719084182
p -Fl libdisplay-info
#1719113724
p -Flq libdisplay-info
#1719113762
Q libdisplay-info
I've hacked together an ugly, fragile bit of code to write a duplicate the first example to `"${HOME}"/.bash_history_dated`.
sed 'N;s/\n/ /' < "${HOME}"/.bash_history \
| cut -c2- \
| awk '{$1 = strftime("%F %r", substr($1,1,10))} 1 {print "["$1"] ",$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20}' \
> "${HOME}"/.bash_history_dated
This runs whenever I exit the shell via `trap "/home/jeff/bin/bash-history-timestamp" 0`, and the results (if there's not more than two lines input per command).
This is great, and I didn't want the command numbers included in this.
[2024-06-22 12:22:38 PM] F libdisplay-info
[2024-06-22 12:22:50 PM] p -Ssq libdisplay-info
[2024-06-22 12:23:02 PM] p -Fl libdisplay-info
[2024-06-22 08:35:24 PM] p -Flq libdisplay-info
[2024-06-22 08:36:02 PM] Q libdisplay-info
My questions are:
1) Why doesn't this work in place of the ugly code `history | cut -c 8- > "${HOME}"/.BASH_HIST_DATED`. This works in the shell, but only creates an empty file when ran in the noscript.
2) How to improve my ugly code to be cleaner and more robust to work with multiple cli input lines if it's the only solution.
https://redd.it/1dyl2ln
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Running a remote command using EOF but only getting a fraction of the output before the noscript completes. How do I keep stdout open until the command completes? Is there a way to inject a "wait" command into EOF?
I'm running a command on a remote system. The remote system is not linux and I can't send piped/chained commands, so I have to use EOF (unless there's another alternative I'm not aware of.
The below command outputs \~12k lines when I run it on the console directly, but when I run it from my unix host, it gets a couple hundred before it logs out.
I see the logout command being executed, so the remote system completed the show command, but the output isn't being captured on my side.
https://redd.it/1dz3jmk
@r_bash
I'm running a command on a remote system. The remote system is not linux and I can't send piped/chained commands, so I have to use EOF (unless there's another alternative I'm not aware of.
The below command outputs \~12k lines when I run it on the console directly, but when I run it from my unix host, it gets a couple hundred before it logs out.
{ ssh user@host << EOF \environment no more \show mobile-gateway bearer-context | match 9/10 \logout EOF } > $output I see the logout command being executed, so the remote system completed the show command, but the output isn't being captured on my side.
https://redd.it/1dz3jmk
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
how do I use mkdir -p for mkdir a and a/b and a/c and a/d? Why using -p?
Hi, Id like to learn how I should use mkdir -p for mkdir a a/b a/c a/d
I use actually mkdir -p a a/b a/c a/d
but what is the advantage of using the flag -p?
I can use the command mkdir a a/b a/c a/d without -p and get the same tree...
Thank you and regards!
https://redd.it/1dzckiu
@r_bash
Hi, Id like to learn how I should use mkdir -p for mkdir a a/b a/c a/d
I use actually mkdir -p a a/b a/c a/d
but what is the advantage of using the flag -p?
I can use the command mkdir a a/b a/c a/d without -p and get the same tree...
Thank you and regards!
https://redd.it/1dzckiu
@r_bash
Strange problem with [ -e ] on network share
Dear all
I've a Bash noscript that checks for the existence of a file-on-a-network. The file path starts
An initial
A second check, carried out immediately after the first check, gives the correct result, i.e., it reports (by evaluating as true) that the file exists.
Can anyone shed light?
I am on 6.5 kernel, on Linux Mint Cinnamon 21.3 (which is based on Ubuntu 22.04), with Bash version '5.1.16(1)-release'.
https://redd.it/1dzzrcq
@r_bash
Dear all
I've a Bash noscript that checks for the existence of a file-on-a-network. The file path starts
/run/user/1000/gvfs/smb-share:server=. When the file does exist, the following happens.An initial
-e check gives a false negative, i.e., it reports (by evaluating as false) that the file does not exist when it does.A second check, carried out immediately after the first check, gives the correct result, i.e., it reports (by evaluating as true) that the file exists.
Can anyone shed light?
I am on 6.5 kernel, on Linux Mint Cinnamon 21.3 (which is based on Ubuntu 22.04), with Bash version '5.1.16(1)-release'.
https://redd.it/1dzzrcq
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Ani-cli in another language.
didn't find a great place to post this, so i guess i'll ask here
i'm brazilian and would love to use ani-cli to watch anime with my brother sometimes, but he doesn't understand english. i found this which sounded like it would make ani-cli search through brazilian subbed animes but no, only english still.
does someone know how to make it work? or if there is a better substitute?
my guess is finding a lookalike with multiple languages support and hope for portuguese-brazilian being one of them, but haven't found one yet
https://redd.it/1e088yr
@r_bash
didn't find a great place to post this, so i guess i'll ask here
i'm brazilian and would love to use ani-cli to watch anime with my brother sometimes, but he doesn't understand english. i found this which sounded like it would make ani-cli search through brazilian subbed animes but no, only english still.
does someone know how to make it work? or if there is a better substitute?
my guess is finding a lookalike with multiple languages support and hope for portuguese-brazilian being one of them, but haven't found one yet
https://redd.it/1e088yr
@r_bash
GitHub
GitHub - leibnitzfermat/ani-cli-pt: A cli tool to browse and play anime in pt-br
A cli tool to browse and play anime in pt-br. Contribute to leibnitzfermat/ani-cli-pt development by creating an account on GitHub.
The escaping hell: can't get valid file references to pass between commands
The scenario is as follows:
I need references to the specific *mp4* files inside the subfolders of a folder. Despite being created in one shot, the modification, creation and access dates of the files don't match those of the subfolder, and these are the only parameters that can be used. To deal with this inconsistency, I set to collect the paths to the subfolders with the **find** utility and then the files with **mdfind**, directing it to each subfolder. The files are then handed over to **open** to open them with a default application.
This is a general strategy. The problem is the last step: I'm struggling with assembling the file references that would meet the acceptable escaping patterns for either a giving or receiving utility, as the filenames contain single quotes and question marks that, seemingly offend the parsers utilized by these commands. With or without xargs the shell would complain.
Here are the failed examples (I substituted **echo** for **open** in some of them temporarily):
HOST: ~login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -1d4h ) ; for f in "$dir" ; do file=$(echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed 's/.*/"&"/') ; echo "$file" ; done
-->"/Users/login_user/Movies/Downloaded From Internet/8 levels of politeness - can you open the window/8 levels of politeness - can you open the window ? #inglese #ingles #englishingleseperitaliani #english | Aurora's Online Language Lessons | Aurora's Online Language Lessons · Original audio.mp4"
"/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4"
"/Users/login_user/Movies/Downloaded From Internet/So hard to get them right sometimes TIP The/So hard to get them right sometimes! TIP: The i of the swear words sounds like a very short é (e chiusa), whilst the other one is like our i (come in... | By Aurora's Online Language LessonsFacebook.mp4"
"/Users/login_user/Movies/Downloaded From Internet/tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove/#tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove #teezeit #british #maggiesmith | Jens Bruenger | topflixinsta · Original audio.mp4"
The files were located.
However,
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed 's/.*/"&"/' | xargs -I {} echo {} ; done
-->{}
/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4
{}
{}
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed 's/.*/"&"/' | xargs -I {} echo "{}" ; done
-->{}
/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4
{}
{}
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed "s/.*/'&'/" | xargs -I {} echo "{}" ; done
-->{}
/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4
xargs: unterminated quote
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do file=$( echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed "s/.*/'&'/" ) ; open "$file" ; done
-->Unable to interpret ''/Users/login_user/Movies/Downloaded From Internet/8 levels of politeness - can you open the window/8
The scenario is as follows:
I need references to the specific *mp4* files inside the subfolders of a folder. Despite being created in one shot, the modification, creation and access dates of the files don't match those of the subfolder, and these are the only parameters that can be used. To deal with this inconsistency, I set to collect the paths to the subfolders with the **find** utility and then the files with **mdfind**, directing it to each subfolder. The files are then handed over to **open** to open them with a default application.
This is a general strategy. The problem is the last step: I'm struggling with assembling the file references that would meet the acceptable escaping patterns for either a giving or receiving utility, as the filenames contain single quotes and question marks that, seemingly offend the parsers utilized by these commands. With or without xargs the shell would complain.
Here are the failed examples (I substituted **echo** for **open** in some of them temporarily):
HOST: ~login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -1d4h ) ; for f in "$dir" ; do file=$(echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed 's/.*/"&"/') ; echo "$file" ; done
-->"/Users/login_user/Movies/Downloaded From Internet/8 levels of politeness - can you open the window/8 levels of politeness - can you open the window ? #inglese #ingles #englishingleseperitaliani #english | Aurora's Online Language Lessons | Aurora's Online Language Lessons · Original audio.mp4"
"/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4"
"/Users/login_user/Movies/Downloaded From Internet/So hard to get them right sometimes TIP The/So hard to get them right sometimes! TIP: The i of the swear words sounds like a very short é (e chiusa), whilst the other one is like our i (come in... | By Aurora's Online Language LessonsFacebook.mp4"
"/Users/login_user/Movies/Downloaded From Internet/tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove/#tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove #teezeit #british #maggiesmith | Jens Bruenger | topflixinsta · Original audio.mp4"
The files were located.
However,
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed 's/.*/"&"/' | xargs -I {} echo {} ; done
-->{}
/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4
{}
{}
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed 's/.*/"&"/' | xargs -I {} echo "{}" ; done
-->{}
/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4
{}
{}
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed "s/.*/'&'/" | xargs -I {} echo "{}" ; done
-->{}
/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4
xargs: unterminated quote
HOST:~ login_user$ dir=$( fd ~/Movies/Downloaded\ From\ Internet/ -d 1 -type d -Btime -20h ) ; for f in "$dir" ; do file=$( echo "$f" | xargs -I {} mdfind -onlyin '{}' kind:"MPEG-4 movie" | sed "s/.*/'&'/" ) ; open "$file" ; done
-->Unable to interpret ''/Users/login_user/Movies/Downloaded From Internet/8 levels of politeness - can you open the window/8
levels of politeness - can you open the window ? #inglese #ingles #englishingleseperitaliani #english | Aurora's Online Language Lessons | Aurora's Online Language Lessons · Original audio.mp4'
'/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4'
'/Users/login_user/Movies/Downloaded From Internet/So hard to get them right sometimes TIP The/So hard to get them right sometimes! TIP: The i of the swear words sounds like a very short é (e chiusa), whilst the other one is like our i (come in... | By Aurora's Online Language LessonsFacebook.mp4'
'/Users/login_user/Movies/Downloaded From Internet/tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove/#tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove #teezeit #british #maggiesmith | Jens Bruenger | topflixinsta · Original audio.mp4'' as a path or URL
I'm deadlocked.
Is there any method to reconcile them?
https://redd.it/1e0djn0
@r_bash
'/Users/login_user/Movies/Downloaded From Internet/Every single word? | Blackadder | BBC Comedy Greats/Every single word? | Blackadder | BBC Comedy Greats.mp4'
'/Users/login_user/Movies/Downloaded From Internet/So hard to get them right sometimes TIP The/So hard to get them right sometimes! TIP: The i of the swear words sounds like a very short é (e chiusa), whilst the other one is like our i (come in... | By Aurora's Online Language LessonsFacebook.mp4'
'/Users/login_user/Movies/Downloaded From Internet/tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove/#tea #the #tee #cha #teatime #tealover #tealovers #tealife #tealove #teezeit #british #maggiesmith | Jens Bruenger | topflixinsta · Original audio.mp4'' as a path or URL
I'm deadlocked.
Is there any method to reconcile them?
https://redd.it/1e0djn0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Autocompletions inside Gitbash
Hi, I'm a Windows user and ive recently came across git and github and gitbash, How can I get git auto completions inside the gitbash terminal, I don't want to use PowerShell or cmd , ive tried clink but i didn't find it useful, How can I get autocompletions inside gitbash
https://redd.it/1e0qmcd
@r_bash
Hi, I'm a Windows user and ive recently came across git and github and gitbash, How can I get git auto completions inside the gitbash terminal, I don't want to use PowerShell or cmd , ive tried clink but i didn't find it useful, How can I get autocompletions inside gitbash
https://redd.it/1e0qmcd
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community