Double dashes for options are replaced by "–" by pandoc, how to fix it?
Here is my makefile and there is my man page.
After conversion I obtain this:
SYNOPSIS
md-to-clip –help|-h
md-to-clip –version|-v
md-to-clip –author|-a
md-to-clip –email|-e
instead of double-dashes:
SYNOPSIS
md-to-clip --help|-h
md-to-clip --version|-v
md-to-clip --author|-a
md-to-clip --email|-e
How to fix it? I suppose it's the reason why VS Code Bash IDE extension can't parse my man page and suggest available flags for
https://redd.it/120k1ck
@r_bash
Here is my makefile and there is my man page.
After conversion I obtain this:
SYNOPSIS
md-to-clip –help|-h
md-to-clip –version|-v
md-to-clip –author|-a
md-to-clip –email|-e
instead of double-dashes:
SYNOPSIS
md-to-clip --help|-h
md-to-clip --version|-v
md-to-clip --author|-a
md-to-clip --email|-e
How to fix it? I suppose it's the reason why VS Code Bash IDE extension can't parse my man page and suggest available flags for
md-to-clip noscript.https://redd.it/120k1ck
@r_bash
GitHub
v2-tooling/makefile at main · 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.
Why my snippet code is not working?
So I'm trying to mess with bash making a really compressed code that shows you your network connection status and I came up with this:
#!/bin/bash
wifistate=$(cat /sys/class/net/wlp3s0/operstate)
ethernetstate=$(cat /sys/class/net/enp0s25/operstate)
if $wifi_state -eq "up" && STAT="up" || if $ethernet_state -eq "up" && STAT="up" || STAT="down"
echo "$STAT"
When compiling it I get the error
https://redd.it/121pypq
@r_bash
So I'm trying to mess with bash making a really compressed code that shows you your network connection status and I came up with this:
#!/bin/bash
wifistate=$(cat /sys/class/net/wlp3s0/operstate)
ethernetstate=$(cat /sys/class/net/enp0s25/operstate)
if $wifi_state -eq "up" && STAT="up" || if $ethernet_state -eq "up" && STAT="up" || STAT="down"
echo "$STAT"
When compiling it I get the error
line 9: syntax error: unexpected end of file . Can someone please enlighten me and tell me what is wrong with it?https://redd.it/121pypq
@r_bash
Reddit
r/bash on Reddit: Why my snippet code is not working?
Posted by u/Chyxo - No votes and 2 comments
Automatic Distro Downloader
I need help writing a bash shell noscript that can download some linux distros for me and also check for newer versions. I spend many hours every six months having to go to the websites to update to the newest version as I utilize many different versions of linux and switch commonly. I store these on local harddrives and it becomes time consuming downloading and etc. These distro's are : Kali Linux 64 and 32 bit bare metal & the 64 bit everything version, Arch Linux, CSI Linux, Debian Linux, Fedora, Linux Mint, Manjaro (Xfxe and KDE versions, Parrot Linux, Puppy Linux, Slackware Linux, Tails, Tiny Core, Trace Labs VM, Ubuntu, Whonix, GUIX, PUREOS, and Trisquel. Thanks.
https://redd.it/121tb2j
@r_bash
I need help writing a bash shell noscript that can download some linux distros for me and also check for newer versions. I spend many hours every six months having to go to the websites to update to the newest version as I utilize many different versions of linux and switch commonly. I store these on local harddrives and it becomes time consuming downloading and etc. These distro's are : Kali Linux 64 and 32 bit bare metal & the 64 bit everything version, Arch Linux, CSI Linux, Debian Linux, Fedora, Linux Mint, Manjaro (Xfxe and KDE versions, Parrot Linux, Puppy Linux, Slackware Linux, Tails, Tiny Core, Trace Labs VM, Ubuntu, Whonix, GUIX, PUREOS, and Trisquel. Thanks.
https://redd.it/121tb2j
@r_bash
Reddit
r/bash on Reddit: Automatic Distro Downloader
Posted by u/clarabel4999 - No votes and 1 comment
New to bash and crashed it -
No terminal, couldn't reinstall bash in Synaptic, looked all over for a solution but didn't have my installation usb stick to copy the folder I needed anymore. Accidentally discovered that opening the folder in nemo - as root - provided the permissions necessary to reinstall bash with Synaptic. Super simple since, apparently, you can't reinstall bash without bash - <face palm>
https://redd.it/1221nu5
@r_bash
No terminal, couldn't reinstall bash in Synaptic, looked all over for a solution but didn't have my installation usb stick to copy the folder I needed anymore. Accidentally discovered that opening the folder in nemo - as root - provided the permissions necessary to reinstall bash with Synaptic. Super simple since, apparently, you can't reinstall bash without bash - <face palm>
https://redd.it/1221nu5
@r_bash
Reddit
r/bash on Reddit: New to bash and crashed it -
Posted by u/whatmattersisfun - No votes and 1 comment
Problem with file paths in $REPLY
I've written a long beginner-level noscript to control my VPN connection. I've been able to find solutions for other problems but not this one, I hope someone can point me in the right direction.
I want to have a prompt for input like this:
read -r -p "nordvpn fileshare send --background "
the user should then complete the command with a destination IP address and one or more files. (From my file manager the files can be dragged to the terminal and it will add the single quotes.) The full command should look something like this:
nordvpn fileshare send --background 100.165.188.210 '/home/user/Downloads/Meshnet/test1.zip' '/home/user/Downloads/Meshnet/test2.zip'
That works fine from the terminal prompt. In the bash noscript I'm trying to run it this way:
read -r -p "nordvpn fileshare send --background "
nordvpn fileshare send --background $REPLY
but I get the error "File not found".
With "$REPLY" in quotes I get the error "The command you entered is not valid. Enter 'nordvpn send --help' to see the options."
I've used this same method of prompt and $REPLY in other parts of the noscript and it works OK but have not tried it with file paths before.
Thanks for any advice!
https://redd.it/1224ed7
@r_bash
I've written a long beginner-level noscript to control my VPN connection. I've been able to find solutions for other problems but not this one, I hope someone can point me in the right direction.
I want to have a prompt for input like this:
read -r -p "nordvpn fileshare send --background "
the user should then complete the command with a destination IP address and one or more files. (From my file manager the files can be dragged to the terminal and it will add the single quotes.) The full command should look something like this:
nordvpn fileshare send --background 100.165.188.210 '/home/user/Downloads/Meshnet/test1.zip' '/home/user/Downloads/Meshnet/test2.zip'
That works fine from the terminal prompt. In the bash noscript I'm trying to run it this way:
read -r -p "nordvpn fileshare send --background "
nordvpn fileshare send --background $REPLY
but I get the error "File not found".
With "$REPLY" in quotes I get the error "The command you entered is not valid. Enter 'nordvpn send --help' to see the options."
I've used this same method of prompt and $REPLY in other parts of the noscript and it works OK but have not tried it with file paths before.
Thanks for any advice!
https://redd.it/1224ed7
@r_bash
GitHub
GitHub - ph202107/nordlist: Bash noscript to use with the NordVPN Linux CLI.
Bash noscript to use with the NordVPN Linux CLI. Contribute to ph202107/nordlist development by creating an account on GitHub.
Why does it work this way?
Hello, so, it seems to me that an uninitialized variable is substituted with command line arguments, am I missing something, and why, why, why does it work this way?
cat >wtf
#!/bin/bash
for x
do
echo $x
done
Executing:
wtf runge kutta
Gives this result:
runge
kutta
Just as a proof of concept.
https://redd.it/122osie
@r_bash
Hello, so, it seems to me that an uninitialized variable is substituted with command line arguments, am I missing something, and why, why, why does it work this way?
cat >wtf
#!/bin/bash
for x
do
echo $x
done
Executing:
wtf runge kutta
Gives this result:
runge
kutta
Just as a proof of concept.
https://redd.it/122osie
@r_bash
Reddit
r/bash on Reddit: Why does it work this way?
Posted by u/McUsrII - No votes and 2 comments
Getting Context of a Loop in an Interactive Shell?
Apparently, zsh has the %_ prompt expansion variable which expands to, for example "for" if you are in the middle of writing a for loop, "dquote" if you are writing a continuation of a line using double quotes and you haven't closed it, and is useful in PS2 prompts. I was unable to find an equivalent in bash, so I'm trying to figure out a different way to determine that. My goal is to dynamically set PS2 so I know at a glance why I am getting a secondary prompt, so if I'm in an interactive shell, I want to see something like:
for i in {1..3}; do
for> # rest of my loop
for> done
I've tried using an alias for
https://redd.it/122zrx1
@r_bash
Apparently, zsh has the %_ prompt expansion variable which expands to, for example "for" if you are in the middle of writing a for loop, "dquote" if you are writing a continuation of a line using double quotes and you haven't closed it, and is useful in PS2 prompts. I was unable to find an equivalent in bash, so I'm trying to figure out a different way to determine that. My goal is to dynamically set PS2 so I know at a glance why I am getting a secondary prompt, so if I'm in an interactive shell, I want to see something like:
for i in {1..3}; do
for> # rest of my loop
for> done
I've tried using an alias for
for, a function, and a function to be used as a trap handler for DEBUG, nothing worked and I can't think of any other methods. Was hoping someone might have some other ideas. EDIT: I've also tried using history, but if there is a way to do it that way, I haven't figured it out.https://redd.it/122zrx1
@r_bash
Reddit
r/bash on Reddit: Getting Context of a Loop in an Interactive Shell?
Posted by u/brown_panick - No votes and no comments
ChatGPT Created a Bash Monster and I Need Help
Hi, all.
I have a large amount of data in 2 folders that I need to merge. Each folder has multiple files/folders in it. If the source folder doesn't exist in the destination, I want to move (not copy) it to the destination folder and move on. If it does exist, I need to check the contents of the folder against the destination and move everything that doesn't exist. If something exists, overwrite it with whatever is in the source. This should only leave duplicates in the source folder, and then we can delete them.
I wrote a very specific set of instructions and fed them to ChatGPT and built off of what I had. The code below seems to work except for the fact that it isn't deleting a folder although the log file says it did delete it.
I have zero bash noscripting experience and haven't coded anything in about 20 years so I'm a bit lost.
Any ideas as to what I can change to accomplish what I need?
Any help is greatly appreciated - thanks in advance!
​
​
​
​
​
https://redd.it/123buum
@r_bash
Hi, all.
I have a large amount of data in 2 folders that I need to merge. Each folder has multiple files/folders in it. If the source folder doesn't exist in the destination, I want to move (not copy) it to the destination folder and move on. If it does exist, I need to check the contents of the folder against the destination and move everything that doesn't exist. If something exists, overwrite it with whatever is in the source. This should only leave duplicates in the source folder, and then we can delete them.
I wrote a very specific set of instructions and fed them to ChatGPT and built off of what I had. The code below seems to work except for the fact that it isn't deleting a folder although the log file says it did delete it.
I have zero bash noscripting experience and haven't coded anything in about 20 years so I'm a bit lost.
Any ideas as to what I can change to accomplish what I need?
Any help is greatly appreciated - thanks in advance!
#!/bin/bash​
# Set source and destination folder pathssrc_folder="/path/to/source/folder"dest_folder="/path/to/destination/folder"​
# Set log file pathlog_file="/path/to/logfile.log"​
# Function to log messages to the log filelog() {echo "$(date): $1" >> "$log_file"}​
# Function to traverse directories and move/copy filestraverse_dir() {for file in "$1"/*; doif [ -d "$file" ]; then# If the file is a directory, create the directory in the destination if it doesn't existif [ ! -d "${2}/${file#$1/}" ]; thenmkdir -p "${2}/${file#$1/}"log "Created directory ${2}/${file#$1/}"fi# Traverse the directory recursivelytraverse_dir "$file" "${2}/${file#$1/}"# After traversing the directory, remove the directory from the sourcermdir "$file" 2>/dev/nulllog "Removed directory $file from source folder"# Check if the parent directory is empty and remove it if it isparent="$(dirname "$file")"rmdir "$parent" 2>/dev/nulllog "Removed directory $parent from source folder"elif [ -f "$file" ]; then# If the file is a regular file, check to see if it's the same in both foldersif cmp -s "$file" "${2}/${file#$1/}"; then# If the files are the same, delete the file from sourcerm "$file"log "Deleted file $file from source folder"else# If the files are different, copy/move the file to destinationcp -f "$file" "${2}/${file#$1/}"log "Copied file $file to ${2}/${file#$1/}"rm "$file"log "Deleted file $file from source folder"fifidone# Check if the source directory is empty and remove it if it isrmdir "$1" 2>/dev/nulllog "Removed directory $1 from source folder"}​
# Check if source folder exists in destination folderif [ ! -d "${dest_folder}/${src_folder##*/}" ]; then# If it does not, move entire folder to destinationmv "$src_folder" "$dest_folder"log "Moved folder $src_folder to $dest_folder"else# If it does, traverse the source folder and move/copy filestraverse_dir "$src_folder" "${dest_folder}/${src_folder##*/}"# After traversing the source folder, remove the source folder if it is emptyrmdir "$src_folder" 2>/dev/nulllog "Removed source folder $src_folder"fihttps://redd.it/123buum
@r_bash
Reddit
r/bash on Reddit: ChatGPT Created a Bash Monster and I Need Help
Posted by u/blockhead_76 - No votes and no comments
man-sections: Lets you peruse the different sections of f.x man bash trough fzf and batcat.
Usage:
man-sections COMMAND
man-sections takes a command as parameter
It will then let you choose which section you want to read
from the section list. Again and again, until you hit 'q'.
man-sections:
#!/bin/bash
set -o pipefail
set -e
if [ $# -lt 1 ] ; then
echo "${0##/} : I need a command to show the \
sections of a man page from.\nTerminating..." >&2
exit 2
fi
curs_off() {
COF='\e[?25l' #Cursor Off
printf "$COF"
}
curs_on() {
CON='\e[?25h' #Cursor On
printf "$CON"
}
clear_stdin()
(
old_tty_settings=`stty -g`
stty -icanon min 0 time 0
while read none; do :; done
stty "$old_tty_settings"
)
sections() {
man "$1" | sed -nE -e '/^[A-Z][A-Z]+[ ]/p' | sed -n -e '3,$p' | sed '$d'
}
showsection() {
echo -e "$1\n\n$2\n"
man "$1" | sed -nE -e '/'"$2"'/,/^[A-Z][A-Z]+[ ]*/ {
/'"$2"'/{p;n}
/^[A-Z][A-Z]+[ ]*/{q}
p
}
'
}
cursoff
stty -echo
# turns off the keyboard echo and cursor.
trap 'stty sane ; curson ' EXIT TERM INT
echo -e "\e[1;30mPress 'q' to quit, any key to continue...\e[0m" >&2
while true ; do
wanted="$(sections "$1" | fzf --with-nth 1 --ansi --no-preview \
--preview-window='up:0%')"
if [[ -n "$wanted" ]] ; then
showsection $1 "$wanted" | batcat -l manpage
else
exit
fi
clearstdin
read -s -r -N 1 input
if [[ "${input^^}" == "Q" ]] ; then
exit
fi
done
stty echo
curson
https://redd.it/123nlfc
@r_bash
Usage:
man-sections COMMAND
man-sections takes a command as parameter
It will then let you choose which section you want to read
from the section list. Again and again, until you hit 'q'.
man-sections:
#!/bin/bash
set -o pipefail
set -e
if [ $# -lt 1 ] ; then
echo "${0##/} : I need a command to show the \
sections of a man page from.\nTerminating..." >&2
exit 2
fi
curs_off() {
COF='\e[?25l' #Cursor Off
printf "$COF"
}
curs_on() {
CON='\e[?25h' #Cursor On
printf "$CON"
}
clear_stdin()
(
old_tty_settings=`stty -g`
stty -icanon min 0 time 0
while read none; do :; done
stty "$old_tty_settings"
)
sections() {
man "$1" | sed -nE -e '/^[A-Z][A-Z]+[ ]/p' | sed -n -e '3,$p' | sed '$d'
}
showsection() {
echo -e "$1\n\n$2\n"
man "$1" | sed -nE -e '/'"$2"'/,/^[A-Z][A-Z]+[ ]*/ {
/'"$2"'/{p;n}
/^[A-Z][A-Z]+[ ]*/{q}
p
}
'
}
cursoff
stty -echo
# turns off the keyboard echo and cursor.
trap 'stty sane ; curson ' EXIT TERM INT
echo -e "\e[1;30mPress 'q' to quit, any key to continue...\e[0m" >&2
while true ; do
wanted="$(sections "$1" | fzf --with-nth 1 --ansi --no-preview \
--preview-window='up:0%')"
if [[ -n "$wanted" ]] ; then
showsection $1 "$wanted" | batcat -l manpage
else
exit
fi
clearstdin
read -s -r -N 1 input
if [[ "${input^^}" == "Q" ]] ; then
exit
fi
done
stty echo
curson
https://redd.it/123nlfc
@r_bash
Reddit
r/bash on Reddit: man-sections: Lets you peruse the different sections of f.x man bash trough fzf and batcat.
Posted by u/McUsrII - No votes and no comments
Hey guyz!! I upgraded the bash noscript for termux app added battery function and some improvements Any ideas on self update the noscript on upcoming updates that i made...
https://redd.it/123scy0
@r_bash
https://redd.it/123scy0
@r_bash
Reddit
r/bash on Reddit: Hey guyz!! I upgraded the bash noscript for termux app added battery function and some improvements Any ideas on…
Posted by u/A_J07 - No votes and 3 comments
Need leetcode like questions + solution
Hey guys i need leet code like questions+solution or any questions+solution from basic to advanced in bash noscripting for practice.
https://redd.it/123ui7s
@r_bash
Hey guys i need leet code like questions+solution or any questions+solution from basic to advanced in bash noscripting for practice.
https://redd.it/123ui7s
@r_bash
Reddit
r/bash on Reddit: Need leetcode like questions + solution
Posted by u/Minute_Ad5775 - No votes and no comments
run bash noscript on remote server, I want the output on the local machine
Hi all,
I am trying to build a bash noscript that will go to a remote server within out domain. The noscript will run different small noscripts base on the selection the user makes from a case block of code. EG:
do a df -h, uptime and say cat /etc/fstab file. But I would like the output to display on the screen of the server I am working from. I have seen different ways, but none has worked for me. I have also seen the use of Localhost but not sure how this one works. Any links or feedback would be appreciated. thanks
https://redd.it/1242t11
@r_bash
Hi all,
I am trying to build a bash noscript that will go to a remote server within out domain. The noscript will run different small noscripts base on the selection the user makes from a case block of code. EG:
do a df -h, uptime and say cat /etc/fstab file. But I would like the output to display on the screen of the server I am working from. I have seen different ways, but none has worked for me. I have also seen the use of Localhost but not sure how this one works. Any links or feedback would be appreciated. thanks
https://redd.it/1242t11
@r_bash
Reddit
r/bash on Reddit: run bash noscript on remote server, I want the output on the local machine
Posted by u/Individual-Self-9533 - No votes and 1 comment
Please, help me write a bootstrap noscript to display ec2 instance metadata on a web page
I am a noob when it comes to coding/noscripting. I need to write a bootstrap noscript that will display the ec2 instance ID and availability zone on my web page. So far what I have is:
\#!/bin/bash
sudo yum update
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
sudo aws s3 cp s3://mybucket/index1.html /home/ec2-user/index2.html
INSTANCE-ID=curl http://169.254.169.254/latest/meta-data/instance-id
INSTANCE-AZ=curl http://169.254.169.254/latest/meta-data/placement/availability-zone
sed 's/instanceID/$INSTANCE-ID/' index2.html
sed 's/AZ/$INSTANCE-AZ/' index2.html
The curl command doesn't seem to be working, and the sed command keeps skipping over the $INSTANCE-ID part. Also, When I run the last four lines in the ec2 CLI it just echos the entire html file and only run's "sed 's/AZ/$INSTANCE-AZ/' index2.html".
Again, I'm trying to replace "instanceID" and "AZ" (Both inside of my html doc) with the values of $INSTANCE-ID and $INSTANCE-AZ (from my bootstrap noscript INSTANCE-ID=curl..., INSTANCE-AZ=curl...)
If there's a better way please let me know.
https://redd.it/1245ezx
@r_bash
I am a noob when it comes to coding/noscripting. I need to write a bootstrap noscript that will display the ec2 instance ID and availability zone on my web page. So far what I have is:
\#!/bin/bash
sudo yum update
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
sudo aws s3 cp s3://mybucket/index1.html /home/ec2-user/index2.html
INSTANCE-ID=curl http://169.254.169.254/latest/meta-data/instance-id
INSTANCE-AZ=curl http://169.254.169.254/latest/meta-data/placement/availability-zone
sed 's/instanceID/$INSTANCE-ID/' index2.html
sed 's/AZ/$INSTANCE-AZ/' index2.html
The curl command doesn't seem to be working, and the sed command keeps skipping over the $INSTANCE-ID part. Also, When I run the last four lines in the ec2 CLI it just echos the entire html file and only run's "sed 's/AZ/$INSTANCE-AZ/' index2.html".
Again, I'm trying to replace "instanceID" and "AZ" (Both inside of my html doc) with the values of $INSTANCE-ID and $INSTANCE-AZ (from my bootstrap noscript INSTANCE-ID=curl..., INSTANCE-AZ=curl...)
If there's a better way please let me know.
https://redd.it/1245ezx
@r_bash
Reddit
r/bash on Reddit: Please, help me write a bootstrap noscript to display ec2 instance metadata on a web page
Posted by u/Kumdongie - No votes and 1 comment
Having a hard time incrementing a variable, can someone show where I am wrong at? Thanks
So I set a variable to a uid that I pull from a server. I then want to increment this by 1 and echo that out.
I keep gettingsyntax error: invalid arithmetic operator (error token is "
​
My code so far is as:
uid=$(kubectl command | awk) <-- ultimately returns a value such as 2000
echo "UID = ${uid}"newuid=$((uid++))echo "New uid is $uid"
Any thought why I am recieving this error? I am 100% confident I am not getting a decimal and its returning 2000.
I created the below to test and it works as expected
uid=5000
echo "UID = ${uid}"
newuid=$((uid++))
echo "New uid is $uid"
This works when I set the uid to a number in the noscript instead of pulling it in via a variable.
I feel it has something to do with a character that kubectl is returning that is not showing in the echo commands.
https://redd.it/1246xtg
@r_bash
So I set a variable to a uid that I pull from a server. I then want to increment this by 1 and echo that out.
I keep gettingsyntax error: invalid arithmetic operator (error token is "
​
My code so far is as:
uid=$(kubectl command | awk) <-- ultimately returns a value such as 2000
echo "UID = ${uid}"newuid=$((uid++))echo "New uid is $uid"
Any thought why I am recieving this error? I am 100% confident I am not getting a decimal and its returning 2000.
I created the below to test and it works as expected
uid=5000
echo "UID = ${uid}"
newuid=$((uid++))
echo "New uid is $uid"
This works when I set the uid to a number in the noscript instead of pulling it in via a variable.
I feel it has something to do with a character that kubectl is returning that is not showing in the echo commands.
https://redd.it/1246xtg
@r_bash
Reddit
r/bash on Reddit: Having a hard time incrementing a variable, can someone show where I am wrong at? Thanks
Posted by u/Interested_Minds1 - No votes and 1 comment
how to send keystrokes
how can i register any other keystroke like <ENTER> key command in bash noscript
https://redd.it/124g02n
@r_bash
how can i register any other keystroke like <ENTER> key command in bash noscript
https://redd.it/124g02n
@r_bash
Reddit
r/bash on Reddit: how to send keystrokes
Posted by u/Old_Yak1 - No votes and no comments
Need help with simple brightness noscript.
Hey there, I am new to Linux and Bash and i was making a simple noscript to get my brightness level as a percentage but i keep getting the following output:
0%
With the expected output:
50%
It is impossible that the issue lies with the cat command since I do not need root privileges to cat the file and the file includes an integer:
$ cat /sys/class/backlight/intelbacklight/brightness
530
$ cat /sys/class/backlight/intelbacklight/maxbrightness
1060
Anyways, here is my noscript:
#!/bin/bash
brightness=$(cat /sys/class/backlight/intelbacklight/brightness)
maxbrightness=$(cat /sys/class/backlight/intelbacklight/maxbrightness)
brightnesspercentage=$(($brightness/$maxbrightness*100))
echo "$brightnesspercentage%"
Thanks in advance!
https://redd.it/124hfaa
@r_bash
Hey there, I am new to Linux and Bash and i was making a simple noscript to get my brightness level as a percentage but i keep getting the following output:
0%
With the expected output:
50%
It is impossible that the issue lies with the cat command since I do not need root privileges to cat the file and the file includes an integer:
$ cat /sys/class/backlight/intelbacklight/brightness
530
$ cat /sys/class/backlight/intelbacklight/maxbrightness
1060
Anyways, here is my noscript:
#!/bin/bash
brightness=$(cat /sys/class/backlight/intelbacklight/brightness)
maxbrightness=$(cat /sys/class/backlight/intelbacklight/maxbrightness)
brightnesspercentage=$(($brightness/$maxbrightness*100))
echo "$brightnesspercentage%"
Thanks in advance!
https://redd.it/124hfaa
@r_bash
Reddit
r/bash on Reddit: Need help with simple brightness noscript.
Posted by u/7_S3M_7 - No votes and 2 comments
Bash noobie here: What is $ used for ?
I tried to run $(uname -r)
to no avail.
https://redd.it/124hf5q
@r_bash
I tried to run $(uname -r)
to no avail.
https://redd.it/124hf5q
@r_bash
Reddit
r/bash on Reddit: Bash noobie here: What is $ used for ?
Posted by u/vaultRadon - No votes and 2 comments
a chatgpt discussion
Chat gpt seems to be pretty good at bash, I think the definite preference is python but it seems to be pretty good at building skeleton noscript that you can qa and unit test.
Gives pretty good explanations too.
Just don't get it using dd, it's a partition destroying liability.
How have you found it ?
https://redd.it/124h7gj
@r_bash
Chat gpt seems to be pretty good at bash, I think the definite preference is python but it seems to be pretty good at building skeleton noscript that you can qa and unit test.
Gives pretty good explanations too.
Just don't get it using dd, it's a partition destroying liability.
How have you found it ?
https://redd.it/124h7gj
@r_bash
Reddit
r/bash on Reddit: a chatgpt discussion
Posted by u/simonmcnair - No votes and 7 comments
Why can't I use !! in bash noscripts or in the bashrc ?
Ideally I would like be able to set an alias that does the same thing as !!, or call a noscript that does the same thing as !! . However i get "command not found" . The only way I am able to repeat a command is by directly typing !! into the prompt. Is there a way to get around this ?
https://redd.it/124vjzu
@r_bash
Ideally I would like be able to set an alias that does the same thing as !!, or call a noscript that does the same thing as !! . However i get "command not found" . The only way I am able to repeat a command is by directly typing !! into the prompt. Is there a way to get around this ?
https://redd.it/124vjzu
@r_bash
Reddit
r/bash on Reddit: Why can't I use !! in bash noscripts or in the bashrc ?
Posted by u/nesteajuicebox - No votes and no comments