Passing a command with double quotes to a function
Hi, I'm writing a noscript to create thumbnails and see them as preview for different types of files.
The problematic part is with passing to
Does somebody knows if I'm passing those commands to
https://redd.it/12kwbq8
@r_bash
Hi, I'm writing a noscript to create thumbnails and see them as preview for different types of files.
#!/bin/sh
file="$1"
w="$2"
h="$3"
x="$4"
y="$5"
mkdir -p '/tmp/lf'
cache() {
cache="/tmp/lf/$(echo "$file" | tr '/' '%')"
[ ! -f "$cache" ] && "$@" && echo '[SUCCESS]'
kitten icat --silent --transfer-mode file --stdin no --place "${w}x${h}@${x}x${y}" "$cache" < /dev/null > /dev/tty
}
case "$(file -Lb --mime-type "$file")" in
application/json) jq -C "$file" ;;
application/octet-stream|video/*)
cache ffmpegthumbnailer -i "$file" -o "$cache.jpg" -s 0 -q 4 ;;
application/pdf)
cache pdftoppm -singlefile -jpeg "$file" "$cache" ;;
application/x-7z-compressed) 7z l -p "$file" ;;
application/x-tar) tar rf "$1" ;;
application/x-rar) unrar lt -p- "$file" ;;
application/zip) unzip -l "$file" ;;
image/*) kitten icat --silent --transfer-mode file --stdin no --place "${w}x${h}@${x}x${y}" "$file" < /dev/null > /dev/tty ;;
text/*) cat "$file" ;;
*) echo '----- File Type Classification -----' && file -Lb "$file" ;;
esac
exit 1
The problematic part is with passing to
cache the command to create a thumbnail like in the case of application/pdf. I see the message [SUCCESS] on screen but the files doesn't get created at all. In the case of video/* I don't even see the message on screen.Does somebody knows if I'm passing those commands to
cache the wrong way? (Also if there is any other suggestion on style please tell me)https://redd.it/12kwbq8
@r_bash
Reddit
r/bash on Reddit: Passing a command with double quotes to a function
Posted by u/sicr0 - No votes and 4 comments
Brackets in sh noscript.
Hi!
I can't understand the code some noscript added to my rc.local when setting up vpn.
what are the "()" brackets for and why adding "&" at the end of the block? Wouldn't sh go line by line anyway? Rest of the code are clear to me. Could you clarify it for me? googling bash/sh brackets is like looking for a needle in the haystack.
https://redd.it/12kyyqt
@r_bash
Hi!
I can't understand the code some noscript added to my rc.local when setting up vpn.
(sleep 15service ipsec restartservice xl2tpd restartecho 1 > /proc/sys/net/ipv4/ip_forward)&what are the "()" brackets for and why adding "&" at the end of the block? Wouldn't sh go line by line anyway? Rest of the code are clear to me. Could you clarify it for me? googling bash/sh brackets is like looking for a needle in the haystack.
https://redd.it/12kyyqt
@r_bash
Reddit
r/bash on Reddit: Brackets in sh noscript.
Posted by u/arturkwiatkowski - No votes and 2 comments
What happened with wiki.bash-hackers.org?
This site was a great guide for me, does anyone know what happened?, today I tried to check the page and it seems to be dead 😢
https://redd.it/12lmqoy
@r_bash
This site was a great guide for me, does anyone know what happened?, today I tried to check the page and it seems to be dead 😢
https://redd.it/12lmqoy
@r_bash
Reddit
r/bash on Reddit: What happened with wiki.bash-hackers.org?
Posted by u/urely - No votes and 2 comments
Need help as an absolute beginner on directories and files
Hi everyone. I have a class this semester which requires me to work with bash. We have a homework and unfortunately my course does not provide any helpful infos on how bash works. Here is my homework
Consider the following output from /usr/bin/tree -p | sed -E "s/(\\[d?)([rxw-\]+)/\\1/g":
.
|- [d\] bars
| |- [d\] baz
| | |- [\] corge
| |- [\] quuz
|- [d\] corge
| |- [d\] grault
| |- [d\] garply
| | |- [\] version
| |- [\] partitions
|- [d\] foo
| |- [\] quux
|- [\] fstab
|- [\]qux
|- [\] rumo
6 directories, 8 files
Create the same structure consisting of 6 directories and 8 files using only shell commands. Give all the commands to solve this task in the correct order. For the version, partitions, and fstab files, use the appropriate /proc/version, /proc/partitions, and /etc/fstab files. All other files should be empty.
From all the research i have done on the internet i came up with something like
mkdir root_.
mkdir root_./bar
mkdir root_./bar/baz
mkdir root_./corge
mkdir root_./corge/grault
mkdir root_./corge/grault/graply
mkdir root_./foo
touch root_./baz/corge.txt
touch root_./bar/quuz.txt
... and so on
Am I on the right path here? It could be compeletly different than what they are asking. Would be amazing if i could learn what am i supposed to do and maybe what to study.
All helps are appreciated thank you!
https://redd.it/12lrj2o
@r_bash
Hi everyone. I have a class this semester which requires me to work with bash. We have a homework and unfortunately my course does not provide any helpful infos on how bash works. Here is my homework
Consider the following output from /usr/bin/tree -p | sed -E "s/(\\[d?)([rxw-\]+)/\\1/g":
.
|- [d\] bars
| |- [d\] baz
| | |- [\] corge
| |- [\] quuz
|- [d\] corge
| |- [d\] grault
| |- [d\] garply
| | |- [\] version
| |- [\] partitions
|- [d\] foo
| |- [\] quux
|- [\] fstab
|- [\]qux
|- [\] rumo
6 directories, 8 files
Create the same structure consisting of 6 directories and 8 files using only shell commands. Give all the commands to solve this task in the correct order. For the version, partitions, and fstab files, use the appropriate /proc/version, /proc/partitions, and /etc/fstab files. All other files should be empty.
From all the research i have done on the internet i came up with something like
mkdir root_.
mkdir root_./bar
mkdir root_./bar/baz
mkdir root_./corge
mkdir root_./corge/grault
mkdir root_./corge/grault/graply
mkdir root_./foo
touch root_./baz/corge.txt
touch root_./bar/quuz.txt
... and so on
Am I on the right path here? It could be compeletly different than what they are asking. Would be amazing if i could learn what am i supposed to do and maybe what to study.
All helps are appreciated thank you!
https://redd.it/12lrj2o
@r_bash
Reddit
r/bash on Reddit: Need help as an absolute beginner on directories and files
Posted by u/StarsAreCute - No votes and no comments
Keyboard Shortcut won't execute noscripts and commands which are easily executable on terminal.
So, I installed a package called pix2tex. I wrote a noscript to run it and there also was a pre-written noscript which would launch a window as you can see here in this video
However, though the noscripts and commands run perfectly fine on terminal, they won't run when they are called with a custom shortcut that I assigned them in keyboard settings.
I recorded another video to demonstrate this issue. The noscript which is being executed is
Pix2tex, takes the screenshot, a.png and converts into latex. It's saved in a.tex and then it's copied. Unfortunately, when I try it with keyboard shortcut, it won't even be saved in a.tex (but it will be for terminal executed noscript).
~Edit: I do want to know the answer for future purposes, but for now anyway to run
https://redd.it/12lv6hs
@r_bash
So, I installed a package called pix2tex. I wrote a noscript to run it and there also was a pre-written noscript which would launch a window as you can see here in this video
However, though the noscripts and commands run perfectly fine on terminal, they won't run when they are called with a custom shortcut that I assigned them in keyboard settings.
I recorded another video to demonstrate this issue. The noscript which is being executed is
#!/bin/bash
xfce4-screenshooter --region --save /home/bob/Pictures/Screenshots/a.png
#only the xfce4-screenshooter command would be executed
pix2tex /home/bob/Pictures/Screenshots/a.png | sed 's/.*: //' > /home/bob/Pictures/Screenshots/a.tex
xclip -selection clipboard /home/bob/Pictures/Screenshots/a.tex
exit 0
Pix2tex, takes the screenshot, a.png and converts into latex. It's saved in a.tex and then it's copied. Unfortunately, when I try it with keyboard shortcut, it won't even be saved in a.tex (but it will be for terminal executed noscript).
~Edit: I do want to know the answer for future purposes, but for now anyway to run
latexocr gui without actually having to open the terminal would suffice, is there a way to use a shortcut to do the same job as I am doing in the first video?~https://redd.it/12lv6hs
@r_bash
Imgur
Discover the magic of the internet at Imgur, a community powered entertainment destination. Lift your spirits with funny jokes, trending memes, entertaining gifs, inspiring stories, viral videos, and so much more from users.
Is it possible to make zsh look like GitBash without appealing to OhMyZsh?
Hi everyone!
Nothing to add to the noscript, it speaks by itself, but to give you as much informations as possible I tell you what I did!
So, I recently switched to Mac. I'm studying web development and until now I used GitBash for windows. I immediately realized that zsh style was pretty different so I tried to modify it to make it look as close as possible like GitBash. I created a .zshrc file in my home directory and with vscode I did the following modifications PS1="%F{green}%n@%m%f %F{yellow}%1\~%f $ "
The problem is that there is a lot of stuff that I'd like to modify but I wasn't still able to figure out how yet. These are the main things that I'd like to achieve:
\-When I do 'ls' the directories are not listed in blue with the '/' symbol. I have to 'ls -F' to identify them as a directories (and of course they still miss the color).
\-I didn't do anything regarding git yet but I'd like to have the branch names between brackets and coloured in blue
\-In git bash I had the whole paths listed. For example I had \~/one/two/current-directory. Now I just have the current-directory listed. I have to 'pwd' to see the whole path.
\-Finally, in GitBash the prompt $ started in a new line.
I looked online and some people suggest ohmyzsh. I'd like to achieve these results with out it. I also did 'man ls' to see what it says about colours. It talks about CLICOLOR and LSCOLORS but I wasn't able to understand how to apply them to get the result yet.
Could you guys help me?
Thank you!
https://redd.it/12lz3kb
@r_bash
Hi everyone!
Nothing to add to the noscript, it speaks by itself, but to give you as much informations as possible I tell you what I did!
So, I recently switched to Mac. I'm studying web development and until now I used GitBash for windows. I immediately realized that zsh style was pretty different so I tried to modify it to make it look as close as possible like GitBash. I created a .zshrc file in my home directory and with vscode I did the following modifications PS1="%F{green}%n@%m%f %F{yellow}%1\~%f $ "
The problem is that there is a lot of stuff that I'd like to modify but I wasn't still able to figure out how yet. These are the main things that I'd like to achieve:
\-When I do 'ls' the directories are not listed in blue with the '/' symbol. I have to 'ls -F' to identify them as a directories (and of course they still miss the color).
\-I didn't do anything regarding git yet but I'd like to have the branch names between brackets and coloured in blue
\-In git bash I had the whole paths listed. For example I had \~/one/two/current-directory. Now I just have the current-directory listed. I have to 'pwd' to see the whole path.
\-Finally, in GitBash the prompt $ started in a new line.
I looked online and some people suggest ohmyzsh. I'd like to achieve these results with out it. I also did 'man ls' to see what it says about colours. It talks about CLICOLOR and LSCOLORS but I wasn't able to understand how to apply them to get the result yet.
Could you guys help me?
Thank you!
https://redd.it/12lz3kb
@r_bash
Reddit
r/bash on Reddit: Is it possible to make zsh look like GitBash without appealing to OhMyZsh?
Posted by u/91Flavio91 - No votes and 4 comments
a Bash noscript to eliminate lines in a delimited text file
Hello !
I have a file in a format like this, but bigger:
0.5 00000 aaaaa K 00000 aaaaaaa
0.5 11111 bbbbb P 11111 bbbbbbb
0.5 22222 ccccc F 22222 ccccccc
0.02 33333 ddddd G 33333 ddddddd
0.01 44444 eeeee S 44444 eeeeeee
0.01 55555 fffff S1 55555 fffffff
0.5 66666 ggggg G 66666 ggggggg
0.5 77777 hhhhh S 77777 hhhhhhh
I want to write a Bash noscript, that enters the file, and looks for a line that has G in the fourth column, if it's the case, it returns to the first column of that line and compares it to 0,04. If it's lower, the line should be deleted.
If a line that contains G is deleted, the noscript should look for the lines under, if they contain S or S1, or S2 they should be deleted also if they contain anything except that, no deletion is needed.
For that input, I should have an output like this:
0.5 00000 aaaaa K 00000 aaaaaaa
0.5 11111 bbbbb P 11111 bbbbbbb
0.5 22222 ccccc F 22222 ccccccc
0.5 66666 ggggg G 66666 ggggggg
0.5 77777 hhhhh S 77777 hhhhhhh
Thanks in advance! Have a good day.
https://redd.it/12lzfos
@r_bash
Hello !
I have a file in a format like this, but bigger:
0.5 00000 aaaaa K 00000 aaaaaaa
0.5 11111 bbbbb P 11111 bbbbbbb
0.5 22222 ccccc F 22222 ccccccc
0.02 33333 ddddd G 33333 ddddddd
0.01 44444 eeeee S 44444 eeeeeee
0.01 55555 fffff S1 55555 fffffff
0.5 66666 ggggg G 66666 ggggggg
0.5 77777 hhhhh S 77777 hhhhhhh
I want to write a Bash noscript, that enters the file, and looks for a line that has G in the fourth column, if it's the case, it returns to the first column of that line and compares it to 0,04. If it's lower, the line should be deleted.
If a line that contains G is deleted, the noscript should look for the lines under, if they contain S or S1, or S2 they should be deleted also if they contain anything except that, no deletion is needed.
For that input, I should have an output like this:
0.5 00000 aaaaa K 00000 aaaaaaa
0.5 11111 bbbbb P 11111 bbbbbbb
0.5 22222 ccccc F 22222 ccccccc
0.5 66666 ggggg G 66666 ggggggg
0.5 77777 hhhhh S 77777 hhhhhhh
Thanks in advance! Have a good day.
https://redd.it/12lzfos
@r_bash
Reddit
r/bash on Reddit: a Bash noscript to eliminate lines in a delimited text file
Posted by u/Quick_Repeat7033 - No votes and 3 comments
A new, unprecedented approach to the command line
https://asciinema.org/a/577630
https://redd.it/12m6fan
@r_bash
https://asciinema.org/a/577630
https://redd.it/12m6fan
@r_bash
asciinema.org
A novel approach to a merged mc/pure-shell like command line
A new approach to the command line: - it's a merge of Midnight Commander and command line, - … because everything is panelized, greppable and remembered, - you enter commands like ls, mv, cp, cat a...
How do I use double quotes in a remote ssh this way?
Normally I would set the today variable like this:
today="$(date +'%m-%d-%Y %H:%M:%S')"
Since I'm doing it on a remote server I am doing it this way:
ssh -T root@192.168.1.4 << EOL
today=\$(date +'%m-%d-%Y %H:%M:%S')
echo "\$today"
EOL
But what if I wanted to use the double quotes like normal? How would I do that remotely?
https://redd.it/12m9e3x
@r_bash
Normally I would set the today variable like this:
today="$(date +'%m-%d-%Y %H:%M:%S')"
Since I'm doing it on a remote server I am doing it this way:
ssh -T root@192.168.1.4 << EOL
today=\$(date +'%m-%d-%Y %H:%M:%S')
echo "\$today"
EOL
But what if I wanted to use the double quotes like normal? How would I do that remotely?
https://redd.it/12m9e3x
@r_bash
Reddit
r/bash on Reddit: How do I use double quotes in a remote ssh this way?
Posted by u/ztrz55 - No votes and no comments
quick question
Hello, I am making a noscript that installs and configures a bunch of stuff and I am having a problem with an EOF statement in a function. I am not sure if it works but VsCode and ShellCheck have both flagged it.
Code:
#adds desktop entries for WM's
dotdesktop () {
cat << EOF > /usr/share/xsessions/qtile.desktop
Desktop Entry
Name=Qtile
Comment=Qtile Window Manager
Exec=qtile start
Type=Application
Keywords=wm;tiling
EOF
cat << PIG > /usr/share/wayland-sessions/hypr.desktop
Desktop Entry
Name=Hyprland
Comment=Hyprland Window Manager
Exec=exec Hyprland
Type=Application
Keywords=wm;tiling;wayland
PIG
}
the errors are :
Couldn't parse this here document. Fix to allow more checks.
Remove indentation before end token (or use <<- and indent with tabs).
https://redd.it/12mn1l9
@r_bash
Hello, I am making a noscript that installs and configures a bunch of stuff and I am having a problem with an EOF statement in a function. I am not sure if it works but VsCode and ShellCheck have both flagged it.
Code:
#adds desktop entries for WM's
dotdesktop () {
cat << EOF > /usr/share/xsessions/qtile.desktop
Desktop Entry
Name=Qtile
Comment=Qtile Window Manager
Exec=qtile start
Type=Application
Keywords=wm;tiling
EOF
cat << PIG > /usr/share/wayland-sessions/hypr.desktop
Desktop Entry
Name=Hyprland
Comment=Hyprland Window Manager
Exec=exec Hyprland
Type=Application
Keywords=wm;tiling;wayland
PIG
}
the errors are :
Couldn't parse this here document. Fix to allow more checks.
Remove indentation before end token (or use <<- and indent with tabs).
https://redd.it/12mn1l9
@r_bash
Reddit
r/bash on Reddit: quick question
Posted by u/04AE - No votes and 3 comments
Need help filtering the output after phrase "Only Texts:"
[SOLVED]
Edit:
#!/bin/bash
xfce4-screenshooter --region --save /home/$USER/"formula.jpg"
p2t predict -i ./formula.jpg > ./output 2>&1
sed -n '/Only texts:/,$p' /home/bob/output | grep -v 'Only te>
`This worked`
I wrote a noscript to execute a command and only get part of the output return out of it. But I failed, Now I need your help to make the noscript return output which is after the string "Only Texts:".
The Script I used it [ChatGPT helped with the selection part]
#!/bin/bash
xfce4-screenshooter --region --save /home/$USER/Pictures/Screenshots/"formula.jpg"
output=$(p2t predict -i ./formula.jpg)
out=$(echo "$output" | grep -oP 'Only texts:.*?\$\$')
echo "${out:12}"
The output I recieve if I echo `output` is
```
$ ./pic2text
[INFO 2023-04-15 11:09:48,368 select_device:104] YOLOv7 🚀 2023-4-14 torch 2.0.0+cu117 CPU
[INFO 2023-04-15 11:09:48,368 __init__:161] Use model: /home/bob/.cnstd/1.2/analysis/mfd-yolov7_tiny.pt
[INFO 2023-04-15 11:09:48,544 __init__:597]
[INFO 2023-04-15 11:09:48,682 _get_model:178] use model: /home/bob/.cnocr/2.2/densenet_lite_136-fc/cnocr-v2.2-densenet_lite_136-fc-epoch=039-complete_match_epoch=0.8597-model.onnx
[INFO 2023-04-15 11:09:48,713 _assert_and_prepare_model_files:135] use model: /home/bob/.cnstd/1.2/ppocr/ch_PP-OCRv3_det_infer.onnx
[INFO 2023-04-15 11:09:48,760 _assert_and_prepare_model_files:110] use model: /home/bob/.cnocr/2.2/ppocr/en_PP-OCRv3_rec_infer.onnx
[INFO 2023-04-15 11:09:48,825 _assert_and_prepare_model_files:135] use model: /home/bob/.cnstd/1.2/ppocr/en_PP-OCRv3_det_infer.onnx
[INFO 2023-04-15 11:09:48,866 download_checkpoints:50] use model weights.pth from path /home/bob/.pix2text/formular
[INFO 2023-04-15 11:09:48,866 download_checkpoints:50] use model image_resizer.pth from path /home/bob/.pix2text/formular
[WARNING 2023-04-15 11:09:49,419 _showwarnmsg:109] /home/bob/.local/lib/python3.9/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
[INFO 2023-04-15 11:09:49,422 _analyze_one:338] Done. (68.7ms) Inference, (0.6ms) NMS
[INFO 2023-04-15 11:09:50,266 predict:119] In image: ./formula.jpg
Outs:
[{'position': array([[ 8, 15],
[ 459, 15],
[ 459, 110],
[ 8, 110]]),
'text': '$$\n'
'\\operatorname{d}={\\sqrt{\\left(x_{2}-\\chi_{3}\\right)^{2}+\\left(y_{2}-\\mathbf{y}_{1}\\right)^{2}}}\n'
'$$',
'type': 'isolated'}]
Only texts:
$$
\operatorname{d}={\sqrt{\left(x_{2}-\chi_{3}\right)^{2}+\left(y_{2}-\mathbf{y}_{1}\right)^{2}}}
$$
output
```
All, I want is (stuff after Only texts:)
```
$$
\operatorname{d}={\sqrt{\left(x_{2}-\chi_{3}\right)^{2}+\left(y_{2}-\mathbf{y}_{1}\right)^{2}}}
$$
```
Any help would be greatly appreciated
https://redd.it/12mrm5e
@r_bash
[SOLVED]
Edit:
#!/bin/bash
xfce4-screenshooter --region --save /home/$USER/"formula.jpg"
p2t predict -i ./formula.jpg > ./output 2>&1
sed -n '/Only texts:/,$p' /home/bob/output | grep -v 'Only te>
`This worked`
I wrote a noscript to execute a command and only get part of the output return out of it. But I failed, Now I need your help to make the noscript return output which is after the string "Only Texts:".
The Script I used it [ChatGPT helped with the selection part]
#!/bin/bash
xfce4-screenshooter --region --save /home/$USER/Pictures/Screenshots/"formula.jpg"
output=$(p2t predict -i ./formula.jpg)
out=$(echo "$output" | grep -oP 'Only texts:.*?\$\$')
echo "${out:12}"
The output I recieve if I echo `output` is
```
$ ./pic2text
[INFO 2023-04-15 11:09:48,368 select_device:104] YOLOv7 🚀 2023-4-14 torch 2.0.0+cu117 CPU
[INFO 2023-04-15 11:09:48,368 __init__:161] Use model: /home/bob/.cnstd/1.2/analysis/mfd-yolov7_tiny.pt
[INFO 2023-04-15 11:09:48,544 __init__:597]
[INFO 2023-04-15 11:09:48,682 _get_model:178] use model: /home/bob/.cnocr/2.2/densenet_lite_136-fc/cnocr-v2.2-densenet_lite_136-fc-epoch=039-complete_match_epoch=0.8597-model.onnx
[INFO 2023-04-15 11:09:48,713 _assert_and_prepare_model_files:135] use model: /home/bob/.cnstd/1.2/ppocr/ch_PP-OCRv3_det_infer.onnx
[INFO 2023-04-15 11:09:48,760 _assert_and_prepare_model_files:110] use model: /home/bob/.cnocr/2.2/ppocr/en_PP-OCRv3_rec_infer.onnx
[INFO 2023-04-15 11:09:48,825 _assert_and_prepare_model_files:135] use model: /home/bob/.cnstd/1.2/ppocr/en_PP-OCRv3_det_infer.onnx
[INFO 2023-04-15 11:09:48,866 download_checkpoints:50] use model weights.pth from path /home/bob/.pix2text/formular
[INFO 2023-04-15 11:09:48,866 download_checkpoints:50] use model image_resizer.pth from path /home/bob/.pix2text/formular
[WARNING 2023-04-15 11:09:49,419 _showwarnmsg:109] /home/bob/.local/lib/python3.9/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
[INFO 2023-04-15 11:09:49,422 _analyze_one:338] Done. (68.7ms) Inference, (0.6ms) NMS
[INFO 2023-04-15 11:09:50,266 predict:119] In image: ./formula.jpg
Outs:
[{'position': array([[ 8, 15],
[ 459, 15],
[ 459, 110],
[ 8, 110]]),
'text': '$$\n'
'\\operatorname{d}={\\sqrt{\\left(x_{2}-\\chi_{3}\\right)^{2}+\\left(y_{2}-\\mathbf{y}_{1}\\right)^{2}}}\n'
'$$',
'type': 'isolated'}]
Only texts:
$$
\operatorname{d}={\sqrt{\left(x_{2}-\chi_{3}\right)^{2}+\left(y_{2}-\mathbf{y}_{1}\right)^{2}}}
$$
output
```
All, I want is (stuff after Only texts:)
```
$$
\operatorname{d}={\sqrt{\left(x_{2}-\chi_{3}\right)^{2}+\left(y_{2}-\mathbf{y}_{1}\right)^{2}}}
$$
```
Any help would be greatly appreciated
https://redd.it/12mrm5e
@r_bash
Reddit
r/bash on Reddit: Need help filtering the output after phrase "Only Texts:"
Posted by u/Secure_Tomatillo_375 - No votes and 2 comments
Execute local sh on remote machine
Hi guys, is there any way I can execute a noscript that's in my local machine on remote ones?
I need to run a series of test on several systems every day so, I made a noscript for It. Right now I have that noscript on a pen that I insert into each of those system, mount, and run but, if I could do this from my local machine it would be so much more efficient.
Any tips?
Thanks in advance.
https://redd.it/12n08ii
@r_bash
Hi guys, is there any way I can execute a noscript that's in my local machine on remote ones?
I need to run a series of test on several systems every day so, I made a noscript for It. Right now I have that noscript on a pen that I insert into each of those system, mount, and run but, if I could do this from my local machine it would be so much more efficient.
Any tips?
Thanks in advance.
https://redd.it/12n08ii
@r_bash
Reddit
r/bash on Reddit: Execute local sh on remote machine
Posted by u/stringburner - No votes and 1 comment
Pull variables, with specific prefix, from env and create request
I have a bunch of noscripts like this one with a bunch of variables defined.
I'm looking for a way to not define all of those and perhaps pull them from the
Any suggestions on how to...
1. Pull all the variables?
2. Create the request body string?
https://redd.it/12n0jrl
@r_bash
I have a bunch of noscripts like this one with a bunch of variables defined.
I'm looking for a way to not define all of those and perhaps pull them from the
env if there's a variable prefixed with IM_.Any suggestions on how to...
1. Pull all the variables?
2. Create the request body string?
https://redd.it/12n0jrl
@r_bash
GitHub
im-manager/deploy-dhis2.sh at master · dhis2-sre/im-manager
Contribute to dhis2-sre/im-manager development by creating an account on GitHub.
how to make a noscript write to a permission dienied file?
I want to make a noscript to change the brightness of my screen, but i cant seem to get permision to write to that file. ive tryed all sorts of sudoing, even tee , but notthing works. help. Also is it possible to make this write to the file without asking for sudo password everytime i want to use it, without haveing to change the permissions for the brightness file itself. ther is a program called brightnessctl that basicly does this and i wanted to try to write my own version.
\#!/bin/bash
echo "How bright do you want me? (0-255) : "
read brightnessAmount
echo $brightnessAmount | sudo tee /sys/class/backlight/brightness
https://redd.it/12o4tr9
@r_bash
I want to make a noscript to change the brightness of my screen, but i cant seem to get permision to write to that file. ive tryed all sorts of sudoing, even tee , but notthing works. help. Also is it possible to make this write to the file without asking for sudo password everytime i want to use it, without haveing to change the permissions for the brightness file itself. ther is a program called brightnessctl that basicly does this and i wanted to try to write my own version.
\#!/bin/bash
echo "How bright do you want me? (0-255) : "
read brightnessAmount
echo $brightnessAmount | sudo tee /sys/class/backlight/brightness
https://redd.it/12o4tr9
@r_bash
Reddit
r/bash on Reddit: how to make a noscript write to a permission dienied file?
Posted by u/Wise_Opportunity_857 - No votes and no comments
Curious, how long did it take you to learn bash?
Also, did you have any programming knowledge prior?
https://redd.it/12p1oit
@r_bash
Also, did you have any programming knowledge prior?
https://redd.it/12p1oit
@r_bash
Reddit
r/bash on Reddit: Curious, how long did it take you to learn bash?
Posted by u/corylbs - No votes and 1 comment
behaviour of GLOBIGNORE changed?
So far I have used GLOBIGNORE to prevent
For a few days now I notice that ssh-add complains about permissions
I changed the command to
I also tried the more generic
FWIW: our systems were upgraded from RHEL 7 to 8 recently, is there a connection?
https://redd.it/12p7218
@r_bash
So far I have used GLOBIGNORE to prevent
ssh-add from trying to load my public keys. My .bashrc contains (contained ...)GLOBIGNORE="*.pub"
ssh-add ~/.ssh/id*
For a few days now I notice that ssh-add complains about permissions
0644 for my *.pub files so obviously it's trying to load them.I changed the command to
GLOBIGNORE="/home/*/.ssh/*.pub" and this helps, but I'm wondering if, when and why this changed, or am I totally on the wrong track?I also tried the more generic
/*/.ssh/*.pub (which would also work for /root) and this does not match for user home directories (only /root).FWIW: our systems were upgraded from RHEL 7 to 8 recently, is there a connection?
https://redd.it/12p7218
@r_bash
Reddit
r/bash on Reddit: behaviour of GLOBIGNORE changed?
Posted by u/thseeling - No votes and no comments
A new paradigm file-manager
By accident I might stumble upon a new way of doing command line – in the project: [https://github.com/psprint/n-commodore](https://github.com/psprint/n-commodore). it is written in Zsh but can be run from any shell.
Basically it’s about 3 factors:
* panelize everything,
* grep everything,
* save everything.
Panelization is known from Midnight Commander - it means to capture command output into a list that can be browsed. Grepping is known from fzf. Screen saving is a new paradigm
In short, you have a new screen (a greppable panel) for each new command, which is saved to the disk (GDBM), and which can be fetched/navigated to, having also PWD dir and position in panel restored.
Asciicasts:
[https://asciinema.org/a/578076](https://asciinema.org/a/578076)
[https://asciinema.org/a/578088](https://asciinema.org/a/578088) (new features: 2 column view, man page viewing and ag/ripgrep/ack interface).
​
https://preview.redd.it/71toi7je0mua1.png?width=767&format=png&auto=webp&v=enabled&s=e0f08dcb1fa9245a5b4d38e4061fb21ab4f83490
https://redd.it/12qh07j
@r_bash
By accident I might stumble upon a new way of doing command line – in the project: [https://github.com/psprint/n-commodore](https://github.com/psprint/n-commodore). it is written in Zsh but can be run from any shell.
Basically it’s about 3 factors:
* panelize everything,
* grep everything,
* save everything.
Panelization is known from Midnight Commander - it means to capture command output into a list that can be browsed. Grepping is known from fzf. Screen saving is a new paradigm
In short, you have a new screen (a greppable panel) for each new command, which is saved to the disk (GDBM), and which can be fetched/navigated to, having also PWD dir and position in panel restored.
Asciicasts:
[https://asciinema.org/a/578076](https://asciinema.org/a/578076)
[https://asciinema.org/a/578088](https://asciinema.org/a/578088) (new features: 2 column view, man page viewing and ag/ripgrep/ack interface).
​
https://preview.redd.it/71toi7je0mua1.png?width=767&format=png&auto=webp&v=enabled&s=e0f08dcb1fa9245a5b4d38e4061fb21ab4f83490
https://redd.it/12qh07j
@r_bash
GitHub
GitHub - psprint/n-commodore: A next-generation file manager
A next-generation file manager. Contribute to psprint/n-commodore development by creating an account on GitHub.
Interesting grep behaviour after power outage
Flagged as help but just to draw an expert opinion if you care to comment. I am can sort this out with another pass of grep.
I have many folders called say “monthA, monthB, monthC… monthZ”
Each contains numerous text files either do or do not contain the pairs of letters AA, BB,CC. I only want to keep the ones that do have them.
I started a bit of grep and pipe with this:
It takes an hour to do each monthX file. We had a power cut. It stopped grepoing halfway through say monthD.
Power came back on. When I booted up and started the grep and pipe again it left monthD partially deleted and started on monthD.
I guess there’s a flag or algo decision somewhere and that is expected. I would have expected it to either start again at monthA or halfway through monthD. Anyone shed any light? I suppose it marks monthD as done when it closes it abruptly or something.
https://redd.it/12r1uj4
@r_bash
Flagged as help but just to draw an expert opinion if you care to comment. I am can sort this out with another pass of grep.
I have many folders called say “monthA, monthB, monthC… monthZ”
Each contains numerous text files either do or do not contain the pairs of letters AA, BB,CC. I only want to keep the ones that do have them.
I started a bit of grep and pipe with this:
-v -E -l -r ‘ AA| BB| CC’ month*/ | while read line; do ram “$line”; done;
It takes an hour to do each monthX file. We had a power cut. It stopped grepoing halfway through say monthD.
Power came back on. When I booted up and started the grep and pipe again it left monthD partially deleted and started on monthD.
I guess there’s a flag or algo decision somewhere and that is expected. I would have expected it to either start again at monthA or halfway through monthD. Anyone shed any light? I suppose it marks monthD as done when it closes it abruptly or something.
https://redd.it/12r1uj4
@r_bash
Reddit
r/bash on Reddit: Interesting grep behaviour after power outage
Posted by u/keithreid-sfw - No votes and no comments
Is it okay to include bash noscripting in an embedded systems end of studies project?
I would love to see if there is anyone here who included it in his/her end of studies project. I tried to only use python with Raspberry Pi, since it seems more known in my university, but I keep having problems with the Speech Recognition module.
Now I'm considering using a bash noscript (and a microphone) to record audio and turn it into text, and using python within the noscript to read (via speakers) the final output based on the text.
TLDR: Do you think the professors within the jury will approve of using bash in an embedded systems end of studies project?
https://redd.it/12rskkq
@r_bash
I would love to see if there is anyone here who included it in his/her end of studies project. I tried to only use python with Raspberry Pi, since it seems more known in my university, but I keep having problems with the Speech Recognition module.
Now I'm considering using a bash noscript (and a microphone) to record audio and turn it into text, and using python within the noscript to read (via speakers) the final output based on the text.
TLDR: Do you think the professors within the jury will approve of using bash in an embedded systems end of studies project?
https://redd.it/12rskkq
@r_bash
Reddit
r/bash on Reddit: Is it okay to include bash noscripting in an embedded systems end of studies project?
Posted by u/Sylerb - No votes and no comments