Measure the speed of source
The follow one show me the speed of the source "zero":
dd if=/dev/zero of=filename bs=1M count=1024 status=progress
But if my if my harddisk are not much faster than my source, I will measure not realy exact. Therefore, I would like to specify another target, which is probably faster. I think I have seen something that was written in dev 0 or similar. What do you take there and how do you specify that?
https://redd.it/11snkbm
@r_bash
The follow one show me the speed of the source "zero":
dd if=/dev/zero of=filename bs=1M count=1024 status=progress
But if my if my harddisk are not much faster than my source, I will measure not realy exact. Therefore, I would like to specify another target, which is probably faster. I think I have seen something that was written in dev 0 or similar. What do you take there and how do you specify that?
https://redd.it/11snkbm
@r_bash
Reddit
r/bash on Reddit: Measure the speed of source
Posted by u/TitleApprehensive360 - No votes and 5 comments
How to make a CLI?
I’m wondering how you make custom commands like docker command or mysql command or git command.
How do you make that custom keyword that you use to execute the command?
I would like to make a dummy CLI for a small hobby project just to see how it’s done.
Could someone point me in a direction of what to read?
https://redd.it/11soloo
@r_bash
I’m wondering how you make custom commands like docker command or mysql command or git command.
How do you make that custom keyword that you use to execute the command?
I would like to make a dummy CLI for a small hobby project just to see how it’s done.
Could someone point me in a direction of what to read?
https://redd.it/11soloo
@r_bash
Reddit
r/bash on Reddit: How to make a CLI?
Posted by u/vb_nm - No votes and 1 comment
-X option for compgen works as not expected
Here is my completion:
#!/usr/bin/env bash
__md_to_clip__complete() {
declare current="$2"
declare previous="$3"
case "$previous" in
--output-directory|-od)
mapfile -t COMPREPLY < <(compgen -o dirnames -- "$current")
;;
--special-placeholder-config|-spc)
mapfile -t COMPREPLY < <(compgen -o filenames -X '!*.yaml' -- "$current")
;;
*)
mapfile -t COMPREPLY < <(compgen -W "--help -h
--version -v
--author -a
--email -e
--no-file-save -nfs
--output-directory -od
--special-placeholder-config -spc" -- "$current")
;;
esac
}
complete -F __md_to_clip__complete md-to-clip
I expect just YAML files to be suggested for `--special-placeholder-config|-spc` options. But even I have *.yaml files in the current directory, nothing is suggested after `md-to-clip --special-placeholder-config <TAB>`. I don't understand what's wrong. The doc [says](https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html) that:
> A leading ‘!’ in filterpat negates the pattern; in this case, any completion not matching filterpat is removed.
What I am missing?
https://redd.it/11spfi1
@r_bash
Here is my completion:
#!/usr/bin/env bash
__md_to_clip__complete() {
declare current="$2"
declare previous="$3"
case "$previous" in
--output-directory|-od)
mapfile -t COMPREPLY < <(compgen -o dirnames -- "$current")
;;
--special-placeholder-config|-spc)
mapfile -t COMPREPLY < <(compgen -o filenames -X '!*.yaml' -- "$current")
;;
*)
mapfile -t COMPREPLY < <(compgen -W "--help -h
--version -v
--author -a
--email -e
--no-file-save -nfs
--output-directory -od
--special-placeholder-config -spc" -- "$current")
;;
esac
}
complete -F __md_to_clip__complete md-to-clip
I expect just YAML files to be suggested for `--special-placeholder-config|-spc` options. But even I have *.yaml files in the current directory, nothing is suggested after `md-to-clip --special-placeholder-config <TAB>`. I don't understand what's wrong. The doc [says](https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html) that:
> A leading ‘!’ in filterpat negates the pattern; in this case, any completion not matching filterpat is removed.
What I am missing?
https://redd.it/11spfi1
@r_bash
www.gnu.org
Programmable Completion Builtins (Bash Reference Manual)
Next: A Programmable Completion Example, Previous: Programmable Completion, Up: Command Line Editing [Contents][Index]
How to lint Bash code piece put in a Markdown file?
For instance, I've written Bash completion and placed it in a README file. Here are several questions:
- Is it possible to lint such Bash code (if it's inside README)?
- Is such wish is right at all? I just feel that all code put in README should be checked somehow not to permit some mistakes after copy-pasting written code from .sh files to Markdown.
- Is markdown suitable for a such task at all? Maybe there is something better?
P. S. Yeah, it's possible to write a solution by yourself to extract code and then lint it, but are there any ready to go tools?
https://redd.it/11sq7kv
@r_bash
For instance, I've written Bash completion and placed it in a README file. Here are several questions:
- Is it possible to lint such Bash code (if it's inside README)?
- Is such wish is right at all? I just feel that all code put in README should be checked somehow not to permit some mistakes after copy-pasting written code from .sh files to Markdown.
- Is markdown suitable for a such task at all? Maybe there is something better?
shellcheck can't extract code from Markdown files and check it.P. S. Yeah, it's possible to write a solution by yourself to extract code and then lint it, but are there any ready to go tools?
https://redd.it/11sq7kv
@r_bash
GitHub
v2-tooling/md-to-clip at feature/96 · command-line-interface-pages/v2-tooling
Tools for handling v2.*.* syntax. Contribute to command-line-interface-pages/v2-tooling development by creating an account on GitHub.
Baby in bash asking for feedbacks :)
Hello,
I'm a junior developer and since I use to work on both Mac and Windows, I was annoyed that I couldn't get my hand on a Windows alternative to the `fortune` command that would give you a quote, either by calling it or by setting up to display the quote each time you open a terminal.
So I tried to do something and got it to work.
But as mentioned above, I don't know bash so I'm not sure if this piece of command is good enough, reason I'm here to ask for some feedbacks and explanations if you got time.
screenshot
Repository
Thank you for your time and your help :).
Seb.
https://redd.it/11su6yv
@r_bash
Hello,
I'm a junior developer and since I use to work on both Mac and Windows, I was annoyed that I couldn't get my hand on a Windows alternative to the `fortune` command that would give you a quote, either by calling it or by setting up to display the quote each time you open a terminal.
So I tried to do something and got it to work.
But as mentioned above, I don't know bash so I'm not sure if this piece of command is good enough, reason I'm here to ask for some feedbacks and explanations if you got time.
screenshot
Repository
Thank you for your time and your help :).
Seb.
https://redd.it/11su6yv
@r_bash
ImgBB
Capture-d-cran-2023-03-16-141736 hosted at ImgBB
Image Capture-d-cran-2023-03-16-141736 hosted in ImgBB
-A directory vs -o dirnames in completion
I am confused, there are too very similar options:
https://redd.it/11sx6vs
@r_bash
I am confused, there are too very similar options:
-A directory and -o dirnames. What's the point of having them both in complete built-in? When they can be combined and why? Why Bash developers decided to implement them both, instead of one thing?https://redd.it/11sx6vs
@r_bash
www.gnu.org
Programmable Completion Builtins (Bash Reference Manual)
Next: A Programmable Completion Example, Previous: Programmable Completion, Up: Command Line Editing [Contents][Index]
Newbie at Bash
Hey guys, Im in the process of learning bash with Hack the Box and I find myself stuck at this question. i don't know if the python education is coming out to much in my thought process. I tried to google a lot but nothing seems to be working out for me. Any help would be amazing. Thank you!!
question: Create an "If-Else" condition in the "For"-Loop of the "Exercise Script" that prints you the number of characters of the 35th generated value of the variable "var". Submit the number as the answer.
#!/bin/bash
# Count number of characters in a variable:
# echo $variable | wc -c
# Variable to encode var="nef892na9s1p9asn2aJs71nIsm"
for counter in {1..40}
do var=$(echo $var | base64)
done
https://redd.it/11syvce
@r_bash
Hey guys, Im in the process of learning bash with Hack the Box and I find myself stuck at this question. i don't know if the python education is coming out to much in my thought process. I tried to google a lot but nothing seems to be working out for me. Any help would be amazing. Thank you!!
question: Create an "If-Else" condition in the "For"-Loop of the "Exercise Script" that prints you the number of characters of the 35th generated value of the variable "var". Submit the number as the answer.
#!/bin/bash
# Count number of characters in a variable:
# echo $variable | wc -c
# Variable to encode var="nef892na9s1p9asn2aJs71nIsm"
for counter in {1..40}
do var=$(echo $var | base64)
done
https://redd.it/11syvce
@r_bash
Reddit
r/bash on Reddit: Newbie at Bash
Posted by u/OrganizationWeird715 - No votes and 4 comments
cp .htaccess{.dist,} say what?
Hello. I am installing DokuWiki and one step is:
cp /var/www/html/dokuwiki/.htaccess{.dist,}
This copies and strips the file .htaccess.dist from the suffix to become .htaccess. Nothing else.
(To be more precise, the instructions was to do that "cp" line, but I of course got "Permission denied" because I was not superuser, so doing a "sudo cp" switched ownership to root:root, but I digress.)
I try to wrap my head about what is going on there with the braces and comma, but "man cp" and google brings up nothing but confusion. The braces are for expanding parameters from ".dist" to NULL? Why is there no destination? It makes no sense to me.
I assume it is some usage of regular expressions in bash? Can anyone explain what they do? Why not just "cp .htaccess.dist .hpaccess" ?
https://redd.it/11t3d2t
@r_bash
Hello. I am installing DokuWiki and one step is:
cp /var/www/html/dokuwiki/.htaccess{.dist,}
This copies and strips the file .htaccess.dist from the suffix to become .htaccess. Nothing else.
(To be more precise, the instructions was to do that "cp" line, but I of course got "Permission denied" because I was not superuser, so doing a "sudo cp" switched ownership to root:root, but I digress.)
I try to wrap my head about what is going on there with the braces and comma, but "man cp" and google brings up nothing but confusion. The braces are for expanding parameters from ".dist" to NULL? Why is there no destination? It makes no sense to me.
I assume it is some usage of regular expressions in bash? Can anyone explain what they do? Why not just "cp .htaccess.dist .hpaccess" ?
https://redd.it/11t3d2t
@r_bash
Reddit
r/bash on Reddit: cp .htaccess{.dist,} say what?
Posted by u/Derpygoras - No votes and no comments
Need help with debugging
Hey there! I was having trouble in regards to debugging a shell noscript running input tests for a code from java by comparing it to the output, I’m not really sure whether the I’m debugging it in git bash in the right way as I’m new to debugging in general, can anyone offer me any pointers in regards to how I should approach this situation? Any response/reply would be greatly appreciated.
https://redd.it/11t4lx1
@r_bash
Hey there! I was having trouble in regards to debugging a shell noscript running input tests for a code from java by comparing it to the output, I’m not really sure whether the I’m debugging it in git bash in the right way as I’m new to debugging in general, can anyone offer me any pointers in regards to how I should approach this situation? Any response/reply would be greatly appreciated.
https://redd.it/11t4lx1
@r_bash
Reddit
r/bash on Reddit: Need help with debugging
Posted by u/Portmanteau_ - No votes and no comments
I've run out of ideas on how to crawl a URL to check if a GitHub package has been updated
I have a noscript to compile FFmpeg and it requires a ton of other packages to build it the way I want it configured.
I have searched high and low for ways to crawl github to find out if a package has been updated since the last time the noscript was run.
So for example. If the packages libogg was updated from version x.x.x to a higher number then I want to export the version number into the noscript so that it shows the new update version when compiling along with naming the files appropriately as well.
Does anyone know of a way or some sort of manual in which I can do this? I really have run out of ideas on where to go from here.
Python maybe?
Help me out guys! =)
https://redd.it/11tjj09
@r_bash
I have a noscript to compile FFmpeg and it requires a ton of other packages to build it the way I want it configured.
I have searched high and low for ways to crawl github to find out if a package has been updated since the last time the noscript was run.
So for example. If the packages libogg was updated from version x.x.x to a higher number then I want to export the version number into the noscript so that it shows the new update version when compiling along with naming the files appropriately as well.
Does anyone know of a way or some sort of manual in which I can do this? I really have run out of ideas on where to go from here.
Python maybe?
Help me out guys! =)
https://redd.it/11tjj09
@r_bash
Reddit
r/bash on Reddit: I've run out of ideas on how to crawl a URL to check if a GitHub package has been updated
Posted by u/SAV_NC - No votes and 7 comments
Can you specify a bash version in shellcheck?
I've got a noscript that works perfectly on a device with bash 4.4.23 but it doesn't work correctly on a device with bash 4.3.48
So I was wondering if there was a way to tell shellcheck to check the noscript against bash 4.3.48
https://redd.it/11tmz3w
@r_bash
I've got a noscript that works perfectly on a device with bash 4.4.23 but it doesn't work correctly on a device with bash 4.3.48
So I was wondering if there was a way to tell shellcheck to check the noscript against bash 4.3.48
https://redd.it/11tmz3w
@r_bash
Reddit
r/bash on Reddit: Can you specify a bash version in shellcheck?
Posted by u/DaveR007 - No votes and no comments
Script to install 7-zip on multiple Linux architectures
This noscript will allow the user to install 7-zip on multiple Linux architectures. Sourced from 7-zip Official
It will prompt the user to choose from the following list of install options:
1. Linux x64
2. Linux x86
3. ARM x64
4. ARM x86
wget -qO 7z.sh https://7z.optimizethis.net; sudo bash 7z.sh
For me, the noscript is lightning-fast and seemingly completes the entire noscript as soon as you enter the command line.
If anyone has any ideas or suggestions let me know otherwise this is a pretty simple but (I think) very useful noscript! =)
Cheers
https://redd.it/11tundc
@r_bash
This noscript will allow the user to install 7-zip on multiple Linux architectures. Sourced from 7-zip Official
It will prompt the user to choose from the following list of install options:
1. Linux x64
2. Linux x86
3. ARM x64
4. ARM x86
wget -qO 7z.sh https://7z.optimizethis.net; sudo bash 7z.sh
For me, the noscript is lightning-fast and seemingly completes the entire noscript as soon as you enter the command line.
If anyone has any ideas or suggestions let me know otherwise this is a pretty simple but (I think) very useful noscript! =)
Cheers
https://redd.it/11tundc
@r_bash
Process an FFMpeg command whose filename features a single quotation character?
I have a video with the file name, Raymond's video file.mp4
I followed the advice [here](https://stackoverflow.com/a/28786747) to escape the single quotation character:
Raymond'\''s video file.mp4
I do the following:
ffmpeg -i "/media/veracrypt1/Raymond'\''s video file.mp4" -ss 00:00:07.000 -to 00:00:15.000 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -vf scale="-1:720" -an "./Split Video/Raymond'\''s video file_0007_0015.webm"
It successfully gets passed to FFMpeg, but now FFMpeg ends up looking for a file featuring `'\'` in its file name, which does not exist.
I also made a python noscript that takes the FFMpeg command and passes it to:
subprocess.check_output(shlex.split(ffmpeg_command_string_variable), stderr=open_logfile)
And no issue ever arose. Video was split successfully with the `ss 00:07 -to 00:15` command.
['ffmpeg', '-i', "/media/veracrypt1/Raymond's video file.mp4", '-ss', '00:00:07.000', '-to', '00:00:15.000', '-c:v', 'libvpx-vp9', '-crf', '30', '-b:v', '0', '-b:a', '128k', '-vf', 'scale=-1:720', '-an', "./Split Video/Raymond's video file_0007_0015.webm"]
I'd like to be able to enter the command directly in the terminal. Script is intended for many files to split.
https://redd.it/11u5y9n
@r_bash
I have a video with the file name, Raymond's video file.mp4
I followed the advice [here](https://stackoverflow.com/a/28786747) to escape the single quotation character:
Raymond'\''s video file.mp4
I do the following:
ffmpeg -i "/media/veracrypt1/Raymond'\''s video file.mp4" -ss 00:00:07.000 -to 00:00:15.000 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -vf scale="-1:720" -an "./Split Video/Raymond'\''s video file_0007_0015.webm"
It successfully gets passed to FFMpeg, but now FFMpeg ends up looking for a file featuring `'\'` in its file name, which does not exist.
I also made a python noscript that takes the FFMpeg command and passes it to:
subprocess.check_output(shlex.split(ffmpeg_command_string_variable), stderr=open_logfile)
And no issue ever arose. Video was split successfully with the `ss 00:07 -to 00:15` command.
['ffmpeg', '-i', "/media/veracrypt1/Raymond's video file.mp4", '-ss', '00:00:07.000', '-to', '00:00:15.000', '-c:v', 'libvpx-vp9', '-crf', '30', '-b:v', '0', '-b:a', '128k', '-vf', 'scale=-1:720', '-an', "./Split Video/Raymond's video file_0007_0015.webm"]
I'd like to be able to enter the command directly in the terminal. Script is intended for many files to split.
https://redd.it/11u5y9n
@r_bash
Stack Overflow
How can I escape a double quote inside double quotes?
How can I escape double quotes inside a double string in Bash?
For example, in my shell noscript
#!/bin/bash
dbload="load data local infile \"'gfpoint.csv'\" into table $dbtable FIELDS TERMINATED ...
For example, in my shell noscript
#!/bin/bash
dbload="load data local infile \"'gfpoint.csv'\" into table $dbtable FIELDS TERMINATED ...
Why
Here is a sample makefile:
.PHONY: test
test:
@echo "<$(intcmp 0,0)>"
@echo Why nothing is printed above inside angle brackets, instead of 0?
I expect
> If there are no further arguments, then the function expands to empty if the left-hand side and right-hand side do not compare equal, or to their numerical value if they do compare equal.
https://redd.it/11u6pdq
@r_bash
intcmp returns empty string instead of 0 when numbers are equal?Here is a sample makefile:
.PHONY: test
test:
@echo "<$(intcmp 0,0)>"
@echo Why nothing is printed above inside angle brackets, instead of 0?
I expect
<0> to be printed in the first line while <> is obtained. According to the doc (if I am not missing something) it should be <0>:> If there are no further arguments, then the function expands to empty if the left-hand side and right-hand side do not compare equal, or to their numerical value if they do compare equal.
https://redd.it/11u6pdq
@r_bash
www.gnu.org
GNU make
Next: Overview of make, Previous: (dir), Up: (dir) [Contents][Index]
go run command output does not get saved to variable.
I am trying to run the bash noscript below. It is expected to make you create a go file that returns an output to a variable. But the output of the (go run $fileName) command does not get returned to the variable word. Why does this happen?
​
echo "Hello $USER"
echo "You have to write a go program that returns the word cool"
sleep 2
echo "What do you want your file to be called?"
read fileName
nano $fileName
word=$(go run $fileName)
echo "you printed the word $word"
rm $fileName
https://redd.it/11umj1g
@r_bash
I am trying to run the bash noscript below. It is expected to make you create a go file that returns an output to a variable. But the output of the (go run $fileName) command does not get returned to the variable word. Why does this happen?
​
echo "Hello $USER"
echo "You have to write a go program that returns the word cool"
sleep 2
echo "What do you want your file to be called?"
read fileName
nano $fileName
word=$(go run $fileName)
echo "you printed the word $word"
rm $fileName
https://redd.it/11umj1g
@r_bash
Reddit
r/bash on Reddit: go run command output does not get saved to variable.
Posted by u/genius_dp - No votes and 2 comments
Git Bash Contents Different from File Explorer
Sorry if i'm a little noob but I have so many questions. Hope some of you can answer them...
I have just downloaded Git Bash and am confused as some of the stuff listed in GitBash are not found in the file explorer.
I'm at the right location C:\\Users\\user in file explorer so things should be the same right??
AppData is 'Application Data'?
No cookies, IntelGraphicsProfiles in the file explorer, local settings etc. in the file explorer but shown in Git Bash.
Why is the color different? Some green, some blue, some grey? Is there something I'm missing out?
Why is there an @ symbol at the end of some of them?
https://redd.it/11uok2i
@r_bash
Sorry if i'm a little noob but I have so many questions. Hope some of you can answer them...
I have just downloaded Git Bash and am confused as some of the stuff listed in GitBash are not found in the file explorer.
I'm at the right location C:\\Users\\user in file explorer so things should be the same right??
AppData is 'Application Data'?
No cookies, IntelGraphicsProfiles in the file explorer, local settings etc. in the file explorer but shown in Git Bash.
Why is the color different? Some green, some blue, some grey? Is there something I'm missing out?
Why is there an @ symbol at the end of some of them?
https://redd.it/11uok2i
@r_bash
Reddit
r/bash on Reddit: Git Bash Contents Different from File Explorer
Posted by u/jaynethrills - No votes and no comments
I wrote a stupid simple BASH noscript to bootstrap Arch Linux from an existing Linux system
https://github.com/wick3dr0se/archstrap
https://redd.it/11v2h4b
@r_bash
https://github.com/wick3dr0se/archstrap
https://redd.it/11v2h4b
@r_bash
GitHub
GitHub - wick3dr0se/archstrap: A stupid simple noscript to bootstrap Arch Linux from other Linux distributions
A stupid simple noscript to bootstrap Arch Linux from other Linux distributions - wick3dr0se/archstrap
This media is not supported in your browser
VIEW IN TELEGRAM
I wrote a stupid simple progress bar in pure BASH (source in comments)
https://redd.it/11vf0t7
@r_bash
https://redd.it/11vf0t7
@r_bash
This media is not supported in your browser
VIEW IN TELEGRAM
I was searching for the most SIMPLE way to take quick notes on my terminal with the current stack... no editor is needed + to be able to group them by topics, so I end up with this small bash function note!
https://redd.it/11vhlju
@r_bash
https://redd.it/11vhlju
@r_bash
How to execute all functions by mask?
Hi,I've got a number of functions in my
How can I execute them all at once by mask
https://redd.it/11vkbao
@r_bash
Hi,I've got a number of functions in my
.bashrc. () {blabla2} () {blabla4} () {blabla_n} How can I execute them all at once by mask
rdp-?
rdp-doesn't work.
https://redd.it/11vkbao
@r_bash
Reddit
r/bash on Reddit: How to execute all functions by mask?
Posted by u/turbuhale - No votes and 2 comments